avatarTimothy Tan

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2170

Abstract

ownstream accuracy of your language models in more ways than you think.</p><p id="001c">Take an NLP task like sentiment analysis for example.</p><p id="7226">Would your sentiment model be better if the word embeddings used captured more of the <b>semantics </b>of the words (the meaning of the words) or the <b>syntactic </b>(English grammatical structure) relationships between them?</p><p id="e2ea">Readily available word embeddings such as Global Vectors (GloVe) by Stanford seem to perform better on <b>semantically </b>related tasks as shown in their <a href="https://nlp.stanford.edu/pubs/glove.pdf">research paper</a>.</p><figure id="3b26"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*5w7H-Y3leWU7bBd-4pSmGQ.png"><figcaption>Figure 1 — Example of a Semantic Relationship Task</figcaption></figure><p id="b810">Word2Vec by Google on the other hand, albeit does poorer than GloVe on most NLP task, seem to perform better on <b>syntactically </b>related tasks on its own (<a href="https://papers.nips.cc/paper/5021-distributed-representations-of-words-and-phrases-and-their-compositionality.pdf">source</a>).</p><figure id="91d8"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*JoI0F0TIM36fk485gzZxCA.png"><figcaption>Figure 2 — Example of Syntactic Relationship Task</figcaption></figure><p id="72a9">Having said that, <b>both </b>semantic and syntactic relationships are equally important for good performance in language models.</p><p id="a845" type="7">Alas, nothing is perfect in this world.</p><p id="ab35">There aren’t any pre-trained word embeddings that are superb at both. I think on a personal note, GloVe does an amazing job for most NLP tasks.</p><p id="115a">Besides, the world seemed to have moved away from pre-trained word embeddings already.</p><p id="27fa">Attention models are the “<b>in</b>” thing now.</p><p id="7901">Take a look at this recent article by Google on 25th October, <a href="https://blog.google/products/search/search-language-understanding-bert">Understanding searches better than ever before</a>.</p><p id="fc31">Google has recently implemented their famed algorithm “BERT” which is an atte

Options

ntion model — Attention models basically have the ability to give <b>different </b>word embeddings to the <b>same word</b> used in different context.</p><p id="ddfb">For example:</p><p id="f3b3"><i>“I went to the <b>bank </b>to deposit my paycheck. It was located by a river <b>bank</b>.”</i></p><p id="b27d">As a human, we know the first use of the word “bank” refers to the financial institution while the last instance of the word refers to the river.</p><p id="f254">Attention models gives different word embeddings to the word “bank” as in financial bank vs “bank” as in river bank.</p><p id="eccb">Pretty cool stuff eh?</p><p id="fb33">Just to be fair though, I would like to point out <a href="https://arxiv.org/abs/1905.07129"><b>ERNIE </b></a>by Baidu as well.</p><p id="bb4e">ERNIE is actually the latest and greatest attention model in the NLP world. Thus far, ERNIE outperforms BERT in <b>ALL </b>standard base-line NLP tasks and even works on Mandarin. Not sure why people aren’t talking about it much though.</p><p id="e055">Sorry got distracted talking about attention models.</p><p id="c16a">Let’s get back to the initial topic!</p><h1 id="3718">Ending Notes</h1><p id="652b">I think what I wanted to convey in this short article was this:</p><p id="22ed" type="7">There are no magical pre-trained word embeddings for ALL your NLP tasks.</p><p id="5e4a">You have to keep in mind the NLP task you are trying to solve and train the type of word embedding that is best for it.</p><p id="201c">Take my <a href="https://towardsdatascience.com/creating-word-embeddings-for-out-of-vocabulary-oov-words-such-as-singlish-3fe33083d466">Singlish article</a> for example, I am definitely not able to use GloVe or Word2Vec for it.</p><p id="948d">Remember, word embeddings will ultimately affect your downstream accuracy.</p><p id="f3ef"><b>Rubbish in, rubbish out.</b></p><p id="39e5">Hope this short article on the nuances involved when working with word embeddings gives you some food for thought!</p><p id="275f">Till next time, bye!</p><p id="5d69">LinkedIn Profile: <a href="https://www.linkedin.com/in/timothy-tan-97587190/">Timothy Tan</a></p></article></body>

Photo by Dan Gold on Unsplash

Nuances in the usage of Word Embeddings: Semantic and Syntactic Relationships

Note: Super short post ahead. Just food for thought I guess? :)

Introduction

In the past weeks, I’ve been writing about Word Embeddings.

How I created word embeddings from scratch for a colloquial language such as Singlish, and how I augmented it to handle misspellings or out-of-vocabulary words with translation vectors.

In the latter article, I tested the effects of my experiment on downstream text classification accuracy.

However, I have come to realise from more readings and research, the nuances in the usage of word embeddings and what it truly entails.

Allow me to elaborate.

You see, using word embeddings for Natural Language Processing (NLP) is one thing, everyone can do it.

But…

Understanding the implications it has on downstream tasks is another.

And to understand the implications it has, you first need to know what semantic and syntactic relationships were learned by the word embeddings being used.

What are Semantic and Syntactic relationships?

I think the “what” will be made clear when I talk about the “why”.

So why would this even matter?

It matters because it affects your downstream accuracy of your language models in more ways than you think.

Take an NLP task like sentiment analysis for example.

Would your sentiment model be better if the word embeddings used captured more of the semantics of the words (the meaning of the words) or the syntactic (English grammatical structure) relationships between them?

Readily available word embeddings such as Global Vectors (GloVe) by Stanford seem to perform better on semantically related tasks as shown in their research paper.

Figure 1 — Example of a Semantic Relationship Task

Word2Vec by Google on the other hand, albeit does poorer than GloVe on most NLP task, seem to perform better on syntactically related tasks on its own (source).

Figure 2 — Example of Syntactic Relationship Task

Having said that, both semantic and syntactic relationships are equally important for good performance in language models.

Alas, nothing is perfect in this world.

There aren’t any pre-trained word embeddings that are superb at both. I think on a personal note, GloVe does an amazing job for most NLP tasks.

Besides, the world seemed to have moved away from pre-trained word embeddings already.

Attention models are the “in” thing now.

Take a look at this recent article by Google on 25th October, Understanding searches better than ever before.

Google has recently implemented their famed algorithm “BERT” which is an attention model — Attention models basically have the ability to give different word embeddings to the same word used in different context.

For example:

“I went to the bank to deposit my paycheck. It was located by a river bank.”

As a human, we know the first use of the word “bank” refers to the financial institution while the last instance of the word refers to the river.

Attention models gives different word embeddings to the word “bank” as in financial bank vs “bank” as in river bank.

Pretty cool stuff eh?

Just to be fair though, I would like to point out ERNIE by Baidu as well.

ERNIE is actually the latest and greatest attention model in the NLP world. Thus far, ERNIE outperforms BERT in ALL standard base-line NLP tasks and even works on Mandarin. Not sure why people aren’t talking about it much though.

Sorry got distracted talking about attention models.

Let’s get back to the initial topic!

Ending Notes

I think what I wanted to convey in this short article was this:

There are no magical pre-trained word embeddings for ALL your NLP tasks.

You have to keep in mind the NLP task you are trying to solve and train the type of word embedding that is best for it.

Take my Singlish article for example, I am definitely not able to use GloVe or Word2Vec for it.

Remember, word embeddings will ultimately affect your downstream accuracy.

Rubbish in, rubbish out.

Hope this short article on the nuances involved when working with word embeddings gives you some food for thought!

Till next time, bye!

LinkedIn Profile: Timothy Tan

Machine Learning
Data Science
Naturallanguageprocessing
Text Analytics
NLP
Recommended from ReadMedium