245
votes
How does Keras 'Embedding' layer work?
In fact, the output vectors are not computed from the input using any mathematical operation. Instead, each input integer is used as the index to access a table that contains all possible vectors. ...
41
votes
Accepted
How does negative sampling work in word2vec?
The issue
There are some issues with learning the word vectors using an "standard" neural network. In this way, the word vectors are learned while the network learns to predict the next word given a ...
37
votes
How the embedding layer is trained in Keras Embedding layer
Embedding layers in Keras are trained just like any other layer in your network architecture: they are tuned to minimize the loss function by using the selected optimization method. The major ...
33
votes
Apply word embeddings to entire document, to get a feature vector
One simple technique that seems to work reasonably well for short texts (e.g., a sentence or a tweet) is to compute the vector for each word in the document, and then aggregate them using the ...
25
votes
Why is skip-gram better for infrequent words than CBOW?
Here is my oversimplified and rather naive understanding of the difference:
As we know, CBOW is learning to predict the word by the context. Or maximize the probability of the target word by looking ...
23
votes
What does average of word2vec vector mean?
You can think of it in terms of physical analogy. You can take a flat surface, like a table, and arrange 30 balls on it. Then you can cut legs from the table and replace it with a single leg. In order ...
19
votes
How does Keras 'Embedding' layer work?
I also had the same question and after reading a couple of posts and materials I think I figured out what embedding layer role is.
I think this post is also helpful to understand, however, I really ...
17
votes
What are the pros and cons of applying pointwise mutual information on a word cooccurrence matrix before SVD?
according to Dan Jurafsky and James H. Martin book:
"It turns out, however, that simple frequency isn’t
the best measure of association between words. One problem is that raw frequency
is very skewed ...
16
votes
Accepted
How to determine parameters for t-SNE for reducing dimensions?
I highly reccomend the article How to Use t-SNE Effectively. It has great animated plots of the tsne fitting process, and was the first source that actually gave me an intuitive understanding of what ...
16
votes
How does Keras 'Embedding' layer work?
If you're more interested in the "mechanics", the embedding layer is basically a matrix which can be considered a transformation from your discrete and sparse 1-hot-vector into a continuous and dense ...
15
votes
What does average of word2vec vector mean?
This means that embedding of all words are averaged, and thus we get a 1D vector of features corresponding to each tweet. This data format is what typical machine learning models expect, so in a sense ...
14
votes
Accepted
Inverse word embedding: vector to word
There is no one 'right' way to turn wordvectors back into words.
The issue is that the words themselves form a discrete set of points in the embedding space, and so the output of a model is very ...
10
votes
What is difference between keras embedding layer and word2vec?
Embeddings (in general, not only in Keras) are methods for learning vector representations of categorical data. They are most commonly used for working with textual data. Word2vec and GloVe are two ...
10
votes
What is the intuition behind the positional cosine encoding in the transformer network?
In positional encoding you encode the dimension with different frequency waves. Together with a position (on this wave) this gives you encoding that corresponds to each input. The encoding is ...
9
votes
Accepted
How to train sentence/paragraph/document embeddings?
There are dozens of ways to produce sentence embedding.
We can group them into 3 types:
Unordered/Weakly Ordered:
things like Bag of Words, Bag of ngrams
Dimentionality reduced versions of the above ...
8
votes
What does word embedding weighted by tf-idf mean?
This quote is clearly talking about sentence embeddings, obtained from word embeddings.
If the sentence $s$ consists of words $(w_1, ..., w_n)$, we'd like to define an embedding vector $Emb_s(s) \in \...
7
votes
Accepted
Understanding Word2Vec
what are my actual word vectors in the end?
The actual word vectors are the hidden representations $h$
Basically, multiplying a one hot vector with $\mathbf{W_{V\times N}}$ will give you a $1$$\times$...
7
votes
Accepted
What is Contextual Embedding?
The contextual embedding of a word is just the corresponding hidden state of a bi-GRU:
In our model the document encoder $f$ is implemented as a bidirectional Gated Recurrent Unit (GRU) network ...
7
votes
Word embeddings with logistic regression
While it's possible to combine word embeddings using weighted average or a concatenation of min / max values across word vectors as described in this post, the output vector loses semantic information....
7
votes
merging two word embedding models?
Let's call word2vec vector model $W$ & glove $G$.
Now, an embedding is just a vector and $W$ is a vector space. These two embeddings are in different vector spaces. You need to either
align the ...
7
votes
How the embedding layer is trained in Keras Embedding layer
The embedding layer is just a projection from discrete and sparse 1-hot-vector into a continuous and dense latent space. It is a matrix of size (n,...
7
votes
Accepted
Word2Vec : Difference between the two Weight matrices
They both capture the word semantics. Not only W, sometimes W' is also used as word vectors. Even in somecases (W+W')/2 has also been used and better results in ...
7
votes
Accepted
Facebook's infersent intuition
First of all, many tricks in deep learning are used because they were "proved to work", with post factum theoretical rationalizations. So in many cases the "why" questions can be only answered in ...
7
votes
Accepted
Why does BERT has a limitation of only allowing the maximum length of the input tokens as 512?
It's an arbitrary value. It is the longest length of input vector they assumed to be possible. Presumably, they didn't have longer vectors in the training set. Moreover, you can always truncate a ...
7
votes
How to compare the semantic similarity of text generated by large language models (GPT-3, BLOOM etc) to reference text?
How can I compare the semantic similarity of the answer it provides me with a reference question?
With a text generation metric. See Evaluation of Text Generation: A Survey. Typical metrics: TF-IDF ...
6
votes
deep learning - word embedding with parts of speech
1. Concatenating word2vec and POS features
Adding POS information to your classifier is fine. You will of course want to create a train/dev/test split, eg 5-way cross-validation, to test to what ...
6
votes
Accepted
What exactly is meant by isotropic and anisotropic with word vectors
It seems that the authors are writing about all words in the vocabulary. From the paper:
In all layers of all three models, the contextualized word representations of all words
are not isotropic: ...
5
votes
Word2vec that can distinguish words with different meanings
You're right that word2vec can't distinguish between 'palm' the tree and 'palm' the part of a hand, and related problems. More broadly, it struggles to handle polysemy and homonymy.
The typical way to ...
5
votes
What does average of word2vec vector mean?
You have a tweet $T$, which is composed of words $w_1,w_2,\cdots,w_n$. Each word has a word2vec embedding $u_{w_1},u_{w_2},..,u_{w_n}$. So you define the tweet embedding as: $u_T:=\frac{1}{n}\sum_{i=1}...
5
votes
Accepted
Negative values in word vectorizations
I'm unclear why this is exactly the case- why are non-negative
elements not useful for comparing documents that don't share terms?
Just because two documents don't share terms doesn't mean they're ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
word-embeddings × 283natural-language × 139
word2vec × 115
neural-networks × 92
machine-learning × 68
embeddings × 23
lstm × 18
recurrent-neural-network × 14
transformers × 13
classification × 12
keras × 12
language-models × 12
python × 11
text-mining × 11
tensorflow × 9
cosine-similarity × 9
topic-models × 7
bag-of-words × 7
llm × 7
clustering × 5
feature-engineering × 5
categorical-encoding × 5
autoencoders × 5
softmax × 5
sentiment-analysis × 5