Word Embeddings in NLP
- 20Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the Euclidean distance between any two distinct one-hot vectors in a vocabulary of size V?
What is the Euclidean distance between any two distinct one-hot vectors in a vocabulary of size V?
20 questions
- 1
What is the Euclidean distance between any two distinct one-hot vectors in a vocabulary of size V?
- A
0
- B
1
- C
2
- D
V
Correct answer
C2
Explanation
Two distinct one-hot vectors have a 1 in different positions, so the squared differences sum to 12+12=2, giving distance 2.
- A
- 2
What is a major shortcoming of one-hot encoding for representing word meaning?
- A
Vectors are too short to capture meaning.
- B
They inherently capture contextual relationships between words.
- C
The distance between any two distinct word vectors is identical.
- D
They produce dense vectors that are hard to store.
Correct answer
CThe distance between any two distinct word vectors is identical.
Explanation
Any two distinct one-hot vectors have the same Euclidean distance (2), so they fail to encode semantic similarity.
- A
- 3
In the context of one-hot vectors, what is the Euclidean distance between the vectors for 'good' and 'bad'?
- A
1
- B
0
- C
2
- D
It depends on the vocabulary size.
Correct answer
C2
Explanation
The vectors are one-hot, so regardless of the words, the distance is always 2.
- A
- 4
What does the co-occurrence matrix X in GloVe represent?
- A
The frequency of each word in the corpus.
- B
The pointwise mutual information between words.
- C
The number of times each pair of words appears in the same sentence across the corpus.
- D
The TF-IDF score for each word pair.
Correct answer
CThe number of times each pair of words appears in the same sentence across the corpus.
Explanation
Each entry Xij counts how many times word i and word j co-occur in the same sentence in the entire corpus.
- A
- 5
According to the GloVe model, how is the logarithm of the co-occurrence count logXij modeled?
- A
wi+wj
- B
bi+bj
- C
wi⋅wj+bi+bj
- D
wi⋅wj
Correct answer
Cwi⋅wj+bi+bj
Explanation
The GloVe model posits logXij=wi⋅wj+bi+bj, where w are embedding vectors and b are bias terms.
- A
- 6
Why is the logarithm of co-occurrence counts used in the GloVe model?
- A
To avoid the problem of zero counts.
- B
To squash the wide range of counts and make regression better behaved.
- C
To ensure all values are positive.
- D
To make the data normally distributed.
Correct answer
BTo squash the wide range of counts and make regression better behaved.
Explanation
Co-occurrence counts have a long-tailed distribution; taking the logarithm compresses the range, making the regression model more stable and effective.
- A
- 7
In GloVe, what do the bias terms bi represent?
- A
The total number of co-occurrences of word i with all other words.
- B
The embedding vector for word i.
- C
The inherent popularity or natural frequency of word i.
- D
The dot product of the embedding of word i with itself.
Correct answer
CThe inherent popularity or natural frequency of word i.
Explanation
The bias bi captures the overall frequency of word i, independent of its relationship to other words.
- A
- 8
How are the embedding vectors in GloVe learned?
- A
By applying singular value decomposition to the co-occurrence matrix.
- B
By maximizing the likelihood of word sequences in a corpus.
- C
By minimizing the mean squared error between predicted and actual log co-occurrence counts.
- D
By solving a system of linear equations.
Correct answer
CBy minimizing the mean squared error between predicted and actual log co-occurrence counts.
Explanation
GloVe treats the model as a regression problem: it minimizes the sum of squared differences between logXij and wi⋅wj+bi+bj.
- A
- 9
What optimization algorithm is commonly used to learn GloVe embeddings?
- A
Newton's method
- B
Genetic algorithm
- C
Gradient descent or stochastic gradient descent
- D
Expectation-Maximization
Correct answer
CGradient descent or stochastic gradient descent
Explanation
Gradient descent (often stochastic) is used because the objective function is differentiable and the problem is large-scale.
- A
- 10
What is a key advantage of word embeddings over one-hot vectors?
- A
They are sparse and memory efficient.
- B
They are high-dimensional and preserve all information.
- C
They are easier to compute for large vocabularies.
- D
They capture semantic relationships between words via vector geometry.
Correct answer
DThey capture semantic relationships between words via vector geometry.
Explanation
Word embeddings are dense and learned so that similar words have similar vectors, enabling semantic operations like analogy solving.
- A
- 11
The embedding analogy 'king - man + woman ≈ queen' demonstrates what property?
- A
Embeddings are only capable of representing nouns.
- B
Embeddings are random and unpredictable.
- C
Embeddings capture analogical relationships through vector arithmetic.
- D
Embeddings are linearly separable.
Correct answer
CEmbeddings capture analogical relationships through vector arithmetic.
Explanation
Such analogies show that the learned embedding space encodes meaningful semantic directions, e.g., gender, royalty.
- A
- 12
When is it most beneficial to use pre-trained word embeddings like GloVe?
- A
When you have a small dataset and want to leverage general language knowledge.
- B
When you have a very large dataset for your specific task.
- C
Only when you cannot train your own embeddings.
- D
When you do not care about domain-specific vocabulary.
Correct answer
AWhen you have a small dataset and want to leverage general language knowledge.
Explanation
Pre-trained embeddings provide a good starting point learned from massive corpora, which helps when task-specific data is limited.
- A
- 13
What is a potential drawback of using pre-trained GloVe embeddings for a medical text classification task?
- A
They may not accurately capture domain-specific medical jargon.
- B
They require more training data than available.
- C
They cannot be fine-tuned for the specific task.
- D
The embeddings are too large to load.
Correct answer
AThey may not accurately capture domain-specific medical jargon.
Explanation
Pre-trained embeddings are trained on general text (e.g., Wikipedia) and may not represent specialized terminology well.
- A
- 14
How does the choice of embedding dimension (e.g., 100 vs 300) affect model capacity?
- A
Lower dimension is always better to avoid overfitting.
- B
Higher dimension always reduces capacity.
- C
Higher dimension increases capacity but also the risk of overfitting.
- D
Dimension has no effect on capacity.
Correct answer
CHigher dimension increases capacity but also the risk of overfitting.
Explanation
Increasing the embedding dimension adds more parameters, increasing capacity to capture nuances but also the risk of overfitting, especially with limited data.
- A
- 15
In Keras, after applying the TextVectorization layer with
output_mode='int', what does the Embedding layer do?- A
It converts integers back to one-hot vectors.
- B
It applies a linear transformation to the integers.
- C
It averages the input sequence of integers.
- D
It looks up the embedding vector for each integer token from a learned table.
Correct answer
DIt looks up the embedding vector for each integer token from a learned table.
Explanation
The Embedding layer is a lookup table that maps each integer index to a dense vector (the embedding).
- A
- 16
What is the purpose of padding sequences in natural language processing?
- A
To add contextual information to each token.
- B
To remove stop words from the input.
- C
To reduce the size of the vocabulary.
- D
To ensure all input sequences have the same length for batch processing.
Correct answer
DTo ensure all input sequences have the same length for batch processing.
Explanation
Neural networks expect fixed-size inputs; padding (and truncation) standardizes sequence lengths so they can be processed together in batches.
- A
- 17
In a Keras Embedding layer, what does the
max_tokensparameter specify?- A
The number of training epochs.
- B
The size of the vocabulary (number of rows in the embedding matrix).
- C
The maximum length of input sequences.
- D
The dimensionality of each embedding vector.
Correct answer
BThe size of the vocabulary (number of rows in the embedding matrix).
Explanation
max_tokenssets the vocabulary size, i.e., the number of distinct tokens for which the layer will store an embedding vector. - A
- 18
What is the effect of setting
trainable=Falseon an Embedding layer initialized with pre-trained weights?- A
The pre-trained weights will be randomly reinitialized.
- B
The embeddings will be used only for testing.
- C
The embeddings will not be updated during backpropagation.
- D
The layer will be removed from the model.
Correct answer
CThe embeddings will not be updated during backpropagation.
Explanation
Setting
trainable=Falsefreezes the weights, so they remain fixed during training, preserving the pre-trained values. - A
- 19
What does a GlobalAveragePooling1D layer do to a sequence of embedding vectors?
- A
It concatenates all vectors into one long vector.
- B
It computes the average of each feature dimension across all time steps.
- C
It reduces the sequence length by half.
- D
It applies a 1D convolutional filter over the sequence.
Correct answer
BIt computes the average of each feature dimension across all time steps.
Explanation
GlobalAveragePooling1D takes the mean over the time axis, producing a single vector that is the element-wise average of all embedding vectors in the sequence.
- A
- 20
In the lecture, why did training the whole model (including embeddings) from scratch outperform using frozen GloVe embeddings on the song lyrics dataset?
- A
The dataset was large enough to learn domain-specific representations from scratch.
- B
GloVe embeddings are inherently low quality.
- C
The vocabulary size was too small for GloVe.
- D
The model began to overfit with frozen embeddings.
Correct answer
AThe dataset was large enough to learn domain-specific representations from scratch.
Explanation
With 50,000 examples, the model could learn embeddings tailored to the lyrics domain, whereas frozen GloVe embeddings (trained on Wikipedia) were less suited for the task.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.