Transformers and Large Language Models
- 66Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
Which description best captures the three broad categories of NLP tasks discussed?
Which description best captures the three broad categories of NLP tasks discussed?
66 questions
- 1
Which description best captures the three broad categories of NLP tasks discussed?
- A
Classification predicts one label, multi-classification predicts labels for multiple items, and generation produces variable-length text.
- B
Classification produces variable-length text, multi-classification predicts one label, and generation predicts labels for multiple items.
- C
Classification predicts one label, multi-classification produces variable-length text, and generation predicts labels for multiple items.
- D
Classification predicts labels for multiple items, multi-classification produces variable-length text, and generation predicts one label.
Correct answer
AClassification predicts one label, multi-classification predicts labels for multiple items, and generation produces variable-length text.
Explanation
The lecture groups NLP tasks into classification, multi-classification, and generation. Generation takes text as input and produces text whose length may vary.
- A
- 2
A system labels a movie review as positive, negative, or neutral. Which task category does this illustrate?
- A
Parsing, because the system identifies relationships between words.
- B
Generation, because the system produces text based on the review.
- C
Multi-classification, because the system must label every word in the review.
- D
Classification, because the system predicts one sentiment label for the review.
Correct answer
DClassification, because the system predicts one sentiment label for the review.
Explanation
Sentiment prediction assigns a review a sentiment category, making it a classification task.
- A
- 3
A voice assistant identifies that “Create an alarm for tomorrow” expresses the intent to create an alarm. What kind of task is this?
- A
Machine translation, a task that maps text between languages.
- B
Named Entity Recognition, a task that labels words as entities.
- C
Summarization, a task that condenses a longer text.
- D
Intent detection, a classification task that assigns an input to an intent.
Correct answer
DIntent detection, a classification task that assigns an input to an intent.
Explanation
Intent detection identifies what a person wants to do and is presented as an example of classification.
- A
- 4
What distinguishes Named Entity Recognition from sentence-level sentiment classification?
- A
NER estimates a sequence’s probability, while sentiment classification compares it with a reference translation.
- B
NER labels specific words or tokens, such as locations or times, rather than assigning one label to the whole sentence.
- C
NER predicts one sentiment label for a review, while sentiment classification labels each entity in a sentence.
- D
NER generates a variable-length response, while sentiment classification translates between languages.
Correct answer
BNER labels specific words or tokens, such as locations or times, rather than assigning one label to the whole sentence.
Explanation
NER identifies and categorizes specific words or spans in a text, whereas sentiment classification commonly assigns a label to the whole input.
- A
- 5
Which set contains examples of linguistic tasks mentioned alongside NER?
- A
Sentiment scoring and product-review classification.
- B
Intent detection and language identification.
- C
Machine translation and article summarization.
- D
Part-of-speech tagging and dependency or constituency parsing.
Correct answer
DPart-of-speech tagging and dependency or constituency parsing.
Explanation
Part-of-speech tagging identifies grammatical roles, while dependency and constituency parsing analyze sentence structure.
- A
- 6
Why can accuracy be misleading on a dataset with ninety-nine percent positive examples and one percent negative examples?
- A
Accuracy requires a reference text for every positive and negative example.
- B
A model that always predicts positive can score highly despite failing to identify the minority class.
- C
Accuracy measures only the model’s confidence, not whether its predictions are correct.
- D
Accuracy ignores correct predictions whenever the dataset has more than two classes.
Correct answer
BA model that always predicts positive can score highly despite failing to identify the minority class.
Explanation
With severe class imbalance, predicting only the majority class can yield high accuracy while performing poorly on the minority class.
- A
- 7
A classifier predicts many examples as positive. Which question does precision answer?
- A
How closely did the model’s generated text match a reference passage?
- B
Of all truly positive examples, what proportion did the model predict as positive?
- C
What proportion of all examples did the model classify correctly?
- D
Of the examples predicted positive, what proportion were truly positive?
Correct answer
DOf the examples predicted positive, what proportion were truly positive?
Explanation
Precision evaluates the correctness of positive predictions: it asks how many predicted positives are actually positive.
- A
- 8
Which description correctly distinguishes recall from precision?
- A
Recall measures the majority class; precision measures the minority class exclusively.
- B
Recall asks what fraction of predictions were correct overall; precision asks what fraction of actual positives were found.
- C
Recall compares a translation with a reference; precision measures the model’s output probabilities.
- D
Recall asks what fraction of actual positives were found; precision asks what fraction of predicted positives were correct.
Correct answer
DRecall asks what fraction of actual positives were found; precision asks what fraction of predicted positives were correct.
Explanation
Recall is calculated with respect to all true positive examples, while precision is calculated with respect to the model’s positive predictions.
- A
- 9
What does the F1 score provide when evaluating a classifier?
- A
A single measure that combines precision and recall using their harmonic mean.
- B
A measure of how surprised a language model is by its output.
- C
A comparison between generated text and several reference translations.
- D
A measure of how often the model predicts the dataset’s majority class.
Correct answer
AA single measure that combines precision and recall using their harmonic mean.
Explanation
The F1 score combines precision and recall through their harmonic mean, providing one summary measure of both.
- A
- 10
Which evaluation approach is most directly associated with NER in the lecture?
- A
Assessing sentiment accuracy only at the document level.
- B
Assessing translation quality by comparing whole sentences to references.
- C
Assessing language-model surprise using output probabilities alone.
- D
Assessing classification performance at the token or entity-type level.
Correct answer
DAssessing classification performance at the token or entity-type level.
Explanation
NER predictions concern words or entities, so the lecture describes evaluating them at the token level or by entity type.
- A
- 11
Why is evaluating machine translation more difficult than evaluating a single-label classification task?
- A
Translation inputs cannot be divided into tokens before evaluation.
- B
Translation models cannot produce probabilities for their output tokens.
- C
Translation datasets contain only unpaired texts, never source and target examples.
- D
Many different translations can express the same meaning, so there may be no single exact output.
Correct answer
DMany different translations can express the same meaning, so there may be no single exact output.
Explanation
A translation can be phrased in many valid ways, making exact matching to one expected answer difficult.
- A
- 12
What do BLEU and ROUGE have in common as translation or text-generation evaluation approaches?
- A
They evaluate a model using only its output probabilities, without reference text.
- B
They measure only whether a model correctly predicts the majority class.
- C
They are tokenization methods that reduce out-of-vocabulary errors.
- D
They compare a model’s output with reference text and therefore depend on references.
Correct answer
DThey compare a model’s output with reference text and therefore depend on references.
Explanation
The lecture describes BLEU and ROUGE as reference-based metrics, which means they require labeled reference text.
- A
- 13
How is perplexity characterized in the lecture?
- A
It measures the proportion of positive predictions that are correct, with lower values preferred.
- B
It measures the number of named entities identified, with higher values preferred.
- C
It compares a translation with reference text, with higher values preferred.
- D
It uses probabilities output by the model to quantify how surprised the model is, with lower values preferred.
Correct answer
DIt uses probabilities output by the model to quantify how surprised the model is, with lower values preferred.
Explanation
Perplexity is based on the model’s output probabilities and reflects how surprised it is; lower perplexity is better.
- A
- 14
What does tokenization do before text is processed by a model?
- A
It assigns a sentiment label to each sentence in a document.
- B
It divides text into units called tokens according to a chosen scheme.
- C
It converts model predictions into probabilities over output labels.
- D
It combines a sequence’s tokens into a single reference translation.
Correct answer
BIt divides text into units called tokens according to a chosen scheme.
Explanation
Tokenization divides text into units called tokens, which are then represented for model processing.
- A
- 15
Why can word-level tokenization create out-of-vocabulary problems?
- A
A word-level tokenizer prevents the model from learning any token representations.
- B
A word-level tokenizer merges all words with similar meanings into one token.
- C
A word-level tokenizer always breaks words into single characters.
- D
A word not seen during training may appear at inference and have no known vocabulary entry.
Correct answer
DA word not seen during training may appear at inference and have no known vocabulary entry.
Explanation
With word-level tokenization, an unseen word may not be in the training vocabulary and must be treated as unknown.
- A
- 16
What is one key advantage of subword tokenization over word-level tokenization?
- A
It guarantees the shortest possible sequence for every sentence.
- B
It represents every token with a unique orthogonal one-hot vector.
- C
It can represent related word forms using shared parts, reducing the risk of unknown words.
- D
It eliminates the need to build a vocabulary or learn embeddings.
Correct answer
CIt can represent related word forms using shared parts, reducing the risk of unknown words.
Explanation
Subword tokenization can share roots across related forms, such as “bear” and “bears,” and lowers—but does not eliminate—the risk of out-of-vocabulary items.
- A
- 17
What is a common trade-off of subword tokenization?
- A
It captures spelling errors, but cannot represent common word roots.
- B
It can capture shared word roots, but may create longer sequences than word-level tokenization.
- C
It shortens every sequence, but makes related word forms entirely unrelated.
- D
It prevents unknown words, but requires one token for every possible sentence.
Correct answer
BIt can capture shared word roots, but may create longer sequences than word-level tokenization.
Explanation
Subword units help reuse common word parts, but a word may be split into multiple tokens, increasing sequence length.
- A
- 18
Why can character-level tokenization be useful for misspellings or casing errors?
- A
It ensures that a word has the same tokenization regardless of its characters.
- B
It maps every misspelled word to the correct whole-word vocabulary entry.
- C
It uses sentence-level labels to infer the spelling of every token.
- D
It represents text at the character level, making it more robust to unfamiliar word forms.
Correct answer
DIt represents text at the character level, making it more robust to unfamiliar word forms.
Explanation
Because it operates on characters, this approach can handle forms that a word- or subword-level vocabulary may not recognize.
- A
- 19
What is a major cost of character-level tokenization?
- A
It produces shorter sequences, but requires reference translations for every input.
- B
It forces all words to share the same representation.
- C
It eliminates the ability to handle misspellings and casing variation.
- D
It produces much longer sequences, increasing processing time and making individual representations less meaningful.
Correct answer
DIt produces much longer sequences, increasing processing time and making individual representations less meaningful.
Explanation
Character-level sequences contain many more units, which raises computation and makes it harder for an individual character representation to carry rich meaning.
- A
- 20
Why does increasing sequence length tend to increase a model’s processing cost?
- A
The model must discard all previously learned token representations.
- B
The model must convert each token into a different language.
- C
The model must process more tokens, and model complexity can depend on sequence length.
- D
The model must replace every token with a separate labeled reference text.
Correct answer
CThe model must process more tokens, and model complexity can depend on sequence length.
Explanation
Longer sequences require the model to process more tokens, which can increase runtime and computation.
- A
- 21
What limitation of one-hot token representations makes them poor for expressing similarity?
- A
One-hot vectors assign the same value to every token, so they cannot distinguish vocabulary items.
- B
Different one-hot vectors are orthogonal, so they do not naturally show that similar tokens are related.
- C
One-hot vectors encode word order but cannot encode token identity.
- D
One-hot vectors represent only characters and cannot represent words.
Correct answer
BDifferent one-hot vectors are orthogonal, so they do not naturally show that similar tokens are related.
Explanation
Each distinct one-hot vector points in an orthogonal direction, so even semantically related tokens do not have high similarity under this representation.
- A
- 22
What does cosine similarity primarily compare between two token vectors?
- A
The difference between the vectors’ vocabulary indices.
- B
The number of characters in the tokens represented by the vectors.
- C
The angle between their directions, with vectors pointing in similar directions having greater similarity.
- D
The order in which the tokens appeared in the training data.
Correct answer
CThe angle between their directions, with vectors pointing in similar directions having greater similarity.
Explanation
Cosine similarity compares vector directions through the angle between them, rather than relying primarily on their lengths.
- A
- 23
In the lecture’s illustrative example, which pair of token representations should ideally have high similarity?
- A
“Book” and every other token, because all tokens should be equally similar.
- B
“Teddy bear” and “soft,” because the example treats them as related.
- C
“Soft” and every other token, because all tokens should be orthogonal.
- D
“Teddy bear” and “book,” because the example treats them as unrelated.
Correct answer
B“Teddy bear” and “soft,” because the example treats them as related.
Explanation
The example uses the association between a teddy bear and softness to illustrate why semantically related tokens should have similar representations.
- A
- 24
Why might a tokenizer’s vocabulary be larger for a multilingual model than for a model focused on one language?
- A
It must represent each sentence as one unique vocabulary item.
- B
It must accommodate tokens from multiple languages and potentially other content such as code.
- C
It must avoid using subword units across all languages.
- D
It must use a separate token for every position in every input sequence.
Correct answer
BIt must accommodate tokens from multiple languages and potentially other content such as code.
Explanation
The lecture gives an order of tens of thousands of vocabulary items for one language and hundreds of thousands for multilingual or broader models.
- A
- 25
What central idea made Word2vec embeddings useful for representing word meaning?
- A
Words are represented only by their spelling and never by their contexts.
- B
Every word receives a unique one-hot vector that is guaranteed to encode its full definition.
- C
Words used in meaningful relationships can receive representations whose geometry reflects those relationships.
- D
Every word is assigned a fixed sentiment label during tokenization.
Correct answer
CWords used in meaningful relationships can receive representations whose geometry reflects those relationships.
Explanation
Word2vec helped produce interpretable embeddings in which relationships such as king–queen and Paris–France could be reflected in the learned representations.
- A
- 26
How do Continuous Bag of Words and Skip-gram differ in their prediction direction?
- A
CBOW predicts a sentence’s sentiment, while Skip-gram predicts its language.
- B
CBOW predicts surrounding words from a target word, while Skip-gram predicts a target word from surrounding words.
- C
CBOW predicts a translation, while Skip-gram predicts a named entity.
- D
CBOW predicts a target word from surrounding words, while Skip-gram predicts surrounding words from a target word.
Correct answer
DCBOW predicts a target word from surrounding words, while Skip-gram predicts surrounding words from a target word.
Explanation
CBOW uses the surrounding context to predict a target; Skip-gram starts with a target word and predicts its context.
- A
- 27
Why are next-word prediction and similar objectives called proxy tasks when learning embeddings?
- A
The task provides a training signal for learning useful representations, even when predicting the next word is not the ultimate goal.
- B
The task is used only to evaluate finished translations against reference sentences.
- C
The task replaces the need to train a model on text.
- D
The task ensures that every learned embedding has a manually supplied definition.
Correct answer
AThe task provides a training signal for learning useful representations, even when predicting the next word is not the ultimate goal.
Explanation
A proxy task makes it possible to learn representations from text; the intended goal may be useful embeddings rather than the proxy prediction itself.
- A
- 28
In a neural next-word prediction setup, what role does the vocabulary size play in the model’s output?
- A
The output assigns a probability to each possible next token in the vocabulary.
- B
The output determines the number of epochs required for convergence.
- C
The output gives one probability for the entire training dataset.
- D
The output specifies how many context words must precede the input.
Correct answer
AThe output assigns a probability to each possible next token in the vocabulary.
Explanation
The model’s final probabilities range over the vocabulary, since any vocabulary token may be predicted as the next word.
- A
- 29
How is the token embedding obtained in the simple one-hot-input neural network described in the lecture?
- A
The model averages the output probabilities for all vocabulary items.
- B
The token is compared with a reference sentence and assigned its similarity score.
- C
The one-hot input selects the corresponding learned representation through the network’s weights.
- D
The token’s position in the sentence is used as its one-hot representation.
Correct answer
CThe one-hot input selects the corresponding learned representation through the network’s weights.
Explanation
Multiplying a one-hot vector by learned weights selects the representation associated with that token.
- A
- 30
How does training update a next-word prediction model when its prediction differs from the true next token?
- A
It replaces the true token with the model’s highest-probability prediction.
- B
It changes the tokenizer so the predicted token is removed from the vocabulary.
- C
It computes a loss, such as cross-entropy, and uses backpropagation to adjust weights toward the target.
- D
It stops training immediately and assigns a fixed embedding to the input.
Correct answer
CIt computes a loss, such as cross-entropy, and uses backpropagation to adjust weights toward the target.
Explanation
The lecture describes comparing the prediction with the true token, computing a loss, and updating weights through backpropagation.
- A
- 31
What is one typical way to decide when to stop training a model on a proxy task for embeddings?
- A
Stop when every possible vocabulary token has appeared exactly once.
- B
Continue until the training loss becomes exactly zero.
- C
Track training behavior, such as loss across epochs, and stop when it converges while considering the downstream task.
- D
Stop as soon as the model correctly predicts one next token.
Correct answer
CTrack training behavior, such as loss across epochs, and stop when it converges while considering the downstream task.
Explanation
The lecture suggests monitoring loss across epochs and using convergence as a reasonable stopping signal, while also considering the downstream task.
- A
- 32
What factors can guide the choice of embedding or hidden-layer dimension?
- A
The complexity of the downstream task and the trade-off between representational capacity, latency, and cost.
- B
The number of characters in the shortest input sentence.
- C
The number of reference translations available for the dataset.
- D
The sentiment distribution alone, regardless of the task or model.
Correct answer
AThe complexity of the downstream task and the trade-off between representational capacity, latency, and cost.
Explanation
A larger dimension can provide richer representations but costs more computation; the choice depends on task complexity and practical constraints.
- A
- 33
What is the limitation of simply averaging token embeddings to represent a sentence?
- A
Averaging prevents embeddings from being used for classification.
- B
Averaging can lose word order and other aspects of sentence meaning.
- C
Averaging requires the sentence to have a reference translation.
- D
Averaging automatically gives every token a context-specific representation.
Correct answer
BAveraging can lose word order and other aspects of sentence meaning.
Explanation
A simple average of token vectors discards order and can lose important meaning carried by how words occur in sequence.
- A
- 34
How does an RNN process a sequence of tokens?
- A
It processes tokens one at a time and updates a hidden state representing the sequence so far.
- B
It predicts only the sentiment of the final token.
- C
It processes all tokens independently and discards their order.
- D
It represents the entire sequence with a single one-hot vector.
Correct answer
AIt processes tokens one at a time and updates a hidden state representing the sequence so far.
Explanation
An RNN carries a hidden state forward as it processes each token, allowing the state to represent information from the sequence so far.
- A
- 35
What does an RNN hidden state represent at a given point in a sequence?
- A
A fixed label for the entire vocabulary.
- B
A summary of the sequence processed so far.
- C
A list of every possible future token.
- D
The reference translation for the next sentence.
Correct answer
BA summary of the sequence processed so far.
Explanation
The hidden state is intended to encode the sequence processed up to that point.
- A
- 36
How can an RNN use its representation for sentence-level classification?
- A
Use a reference translation to assign a label to every sentence.
- B
Use the hidden state at the end of the sentence to predict a label such as sentiment.
- C
Use the first token’s one-hot vector as the only representation for every task.
- D
Use the model’s final EOS token as the sentiment category.
Correct answer
BUse the hidden state at the end of the sentence to predict a label such as sentiment.
Explanation
For classification, the lecture describes projecting the final hidden state into the space of possible labels.
- A
- 37
What problem were LSTMs designed to address in RNN-based models?
- A
Difficulty comparing generated translations with references.
- B
Difficulty producing any probability distribution over a vocabulary.
- C
Difficulty dividing text into tokens before processing.
- D
Difficulty retaining important information from earlier in a sequence.
Correct answer
DDifficulty retaining important information from earlier in a sequence.
Explanation
LSTMs extend RNNs with a cell state intended to help retain information that is important to remember.
- A
- 38
What additional quantity does an LSTM track alongside its hidden state?
- A
A separate vocabulary for every position in the input.
- B
A cell state intended to help preserve information over time.
- C
A fixed label-smoothing value for each word.
- D
A reference sentence used to score each output token.
Correct answer
BA cell state intended to help preserve information over time.
Explanation
The lecture describes the LSTM as tracking both an activation or hidden state and an additional cell state.
- A
- 39
What causes the vanishing-gradient problem in long recurrent computations?
- A
The model uses too many reference translations, causing the loss to grow without bound.
- B
The hidden state is replaced by a one-hot vector at every time step.
- C
The output vocabulary is smaller than the hidden dimension.
- D
Backpropagation through many sequential steps can multiply quantities smaller than one, causing gradients to shrink toward zero.
Correct answer
DBackpropagation through many sequential steps can multiply quantities smaller than one, causing gradients to shrink toward zero.
Explanation
When many factors below one are multiplied during backpropagation through time, the resulting gradients can become very small, making updates difficult.
- A
- 40
What can happen when factors greater than one are repeatedly multiplied during recurrent backpropagation?
- A
The model loses its output vocabulary and cannot make predictions.
- B
Gradients can grow very large, producing the exploding-gradient problem.
- C
The model becomes invariant to the order of the input tokens.
- D
Gradients necessarily become zero, producing the vanishing-gradient problem.
Correct answer
BGradients can grow very large, producing the exploding-gradient problem.
Explanation
The lecture contrasts vanishing gradients from repeated multiplication by values below one with exploding gradients from values above one.
- A
- 41
Why can training an RNN be slow on a long sequence?
- A
The model must generate all output tokens before reading the input.
- B
Every token must be compared with a human-written translation.
- C
Computations for later tokens depend on hidden states computed at earlier steps.
- D
RNNs must compute every possible tokenization of the input.
Correct answer
CComputations for later tokens depend on hidden states computed at earlier steps.
Explanation
RNN computation is sequential: the model must compute earlier hidden states before it can process later steps.
- A
- 42
How does attention help with long-range dependencies?
- A
It makes every token depend only on the immediately previous token.
- B
It forces the model to forget all earlier tokens after each step.
- C
It creates more direct connections between what is being predicted and relevant earlier elements.
- D
It removes the need to represent input tokens as vectors.
Correct answer
CIt creates more direct connections between what is being predicted and relevant earlier elements.
Explanation
Attention provides direct links to relevant elements in the sequence, rather than requiring information to pass only through a long chain of recurrent states.
- A
- 43
What makes the mechanism in a transformer’s self-attention layer “self”-attention?
- A
The model represents a token without considering any other tokens.
- B
Tokens in a sequence use information from other tokens in that same sequence to form their representations.
- C
The decoder attends exclusively to the next token it has not generated.
- D
The model compares each input token only with a reference sentence.
Correct answer
BTokens in a sequence use information from other tokens in that same sequence to form their representations.
Explanation
In self-attention, each token’s representation is computed using relationships with tokens in the same sequence.
- A
- 44
In the query-key-value interpretation, what does comparing a query with keys determine?
- A
Which tokenization scheme must be used for the input.
- B
Whether the input sentence is positive or negative.
- C
How relevant each corresponding element is to the query.
- D
How many layers the encoder must contain.
Correct answer
CHow relevant each corresponding element is to the query.
Explanation
Query-key comparisons determine the weights used to identify which elements are relevant to the query.
- A
- 45
In attention, what role do values play after query-key comparisons?
- A
They specify which words were absent from the training vocabulary.
- B
They identify the position of each token in the sequence.
- C
They provide the reference labels used to calculate precision.
- D
They provide the vectors combined using the relevance weights.
Correct answer
DThey provide the vectors combined using the relevance weights.
Explanation
After computing relevance weights from queries and keys, the model uses those weights to form a weighted combination of values.
- A
- 46
How are queries, keys, and values obtained in the transformer example?
- A
They are manually assigned according to each token’s dictionary definition.
- B
Learned projection matrices transform the input representations into query, key, and value vectors.
- C
They are fixed one-hot vectors determined only by word order.
- D
They are taken directly from the reference translation without training.
Correct answer
BLearned projection matrices transform the input representations into query, key, and value vectors.
Explanation
The model learns projection matrices, commonly denoted Wq, Wk, and Wv, to obtain queries, keys, and values.
- A
- 47
What is the purpose of the softmax operation in scaled dot-product attention?
- A
It guarantees that all query-key scores are equal.
- B
It removes the need for learned value projections.
- C
It turns query-key scores into weights that determine the relative importance of values.
- D
It converts the input text into subword tokens.
Correct answer
CIt turns query-key scores into weights that determine the relative importance of values.
Explanation
Softmax converts the query-key scores into attention weights, which are then applied to the values.
- A
- 48
Why are query-key dot products divided by the square root of the key dimension in scaled dot-product attention?
- A
To keep dot-product magnitudes from growing too large as the dimension increases.
- B
To convert the values into one-hot vocabulary vectors.
- C
To ensure that every token attends equally to every other token.
- D
To make the input sequence shorter before attention is computed.
Correct answer
ATo keep dot-product magnitudes from growing too large as the dimension increases.
Explanation
The scaling factor normalizes dot products that tend to grow with the dimension of the keys and queries.
- A
- 49
What does a multi-head attention layer allow the model to do?
- A
Replace the encoder with a larger output vocabulary.
- B
Use several tokenizers while keeping all representations fixed.
- C
Generate several complete translations and select one by majority vote.
- D
Compute attention through several learned projections, allowing different relationships to be represented.
Correct answer
DCompute attention through several learned projections, allowing different relationships to be represented.
Explanation
Each head uses learned projections, giving the model opportunities to represent different relationships or associations.
- A
- 50
How are the outputs of multiple attention heads combined in the described transformer?
- A
They are concatenated and then passed through a learned output projection.
- B
They are converted into reference sentences and compared for BLEU.
- C
They are averaged with the input text before tokenization.
- D
They are discarded after the model selects one head.
Correct answer
AThey are concatenated and then passed through a learned output projection.
Explanation
The head outputs are concatenated and then projected back to the model’s embedding dimension using an output matrix such as Wo.
- A
- 51
What does cross-attention do during encoder-decoder translation?
- A
It compares the final translation with reference text during generation.
- B
It uses decoder queries to attend to keys and values from the encoded input sequence.
- C
It uses encoder queries to attend only to future decoder tokens.
- D
It lets input tokens attend only to other input tokens and never to decoder states.
Correct answer
BIt uses decoder queries to attend to keys and values from the encoded input sequence.
Explanation
In cross-attention, decoder queries use keys and values from the encoder to identify relevant information from the input.
- A
- 52
Why is decoder self-attention masked or causal during autoregressive generation?
- A
A position should use only itself and earlier generated tokens, not future tokens that are not yet available.
- B
The decoder should ignore all previously generated tokens.
- C
The model should prevent the encoder from computing token representations.
- D
The decoder should attend only to the encoder’s input tokens.
Correct answer
AA position should use only itself and earlier generated tokens, not future tokens that are not yet available.
Explanation
Causal masking prevents a decoder position from accessing future output tokens, preserving the step-by-step generation process.
- A
- 53
Why does a transformer add positional information to token representations?
- A
Self-attention alone does not encode the tokens’ positions or order in the sequence.
- B
Self-attention otherwise forces each token to receive a different sentiment label.
- C
Positional information changes an input sequence into a reference translation.
- D
Positional information is needed to calculate whether a token is in the vocabulary.
Correct answer
ASelf-attention alone does not encode the tokens’ positions or order in the sequence.
Explanation
Because self-attention connects tokens directly rather than processing them sequentially, positional encodings provide information about their positions.
- A
- 54
How did the original transformer paper encode position in the example described?
- A
It used a recurrent hidden state to encode each token’s position.
- B
It added sine-and-cosine positional information elementwise to token embeddings.
- C
It appended a reference translation after every input token.
- D
It replaced every token embedding with a one-hot vector for its position.
Correct answer
BIt added sine-and-cosine positional information elementwise to token embeddings.
Explanation
The lecture describes the original paper’s positional encoding as sine-and-cosine information added elementwise to token representations.
- A
- 55
What are the two major parts of the original encoder-decoder transformer architecture?
- A
A word-level embedding table followed by a recurrent language model.
- B
A reference-based evaluator that scores both source and target text.
- C
A classifier that labels the source text and a tokenizer that generates the target text.
- D
An encoder that processes the source text and a decoder that generates the target text.
Correct answer
DAn encoder that processes the source text and a decoder that generates the target text.
Explanation
For translation, the encoder processes the source-language input and the decoder produces the target-language output.
- A
- 56
What is the encoder’s main role in the transformer translation process?
- A
To compare the source sentence with reference translations.
- B
To assign one sentiment label to every source token.
- C
To create context-aware representations of the source tokens.
- D
To predict the final target sentence without using a decoder.
Correct answer
CTo create context-aware representations of the source tokens.
Explanation
The encoder uses self-attention and feedforward layers to produce rich representations of the input tokens.
- A
- 57
What is the main role of the feedforward component in a transformer block, as described in the lecture?
- A
It determines the input’s tokenization scheme.
- B
It supplies reference labels for the model’s output.
- C
It provides another learned transformation that can make token representations richer.
- D
It prevents the model from using attention.
Correct answer
CIt provides another learned transformation that can make token representations richer.
Explanation
The feedforward network provides an additional learned projection or transformation, giving the model more capacity to learn useful representations.
- A
- 58
How does the hidden dimension of the transformer’s feedforward network compare with its input and output dimensions in the example?
- A
It is identical to the vocabulary size, because it predicts one token per unit.
- B
It is always smaller, because it represents a compressed vocabulary.
- C
It is unrelated to the input and output dimensions.
- D
It is larger, providing additional capacity for learning representations.
Correct answer
DIt is larger, providing additional capacity for learning representations.
Explanation
The lecture notes that, unlike the smaller hidden dimension in the Word2vec example, the transformer feedforward hidden layer is larger than its input and output dimensions.
- A
- 59
What is the purpose of stacking multiple encoder and decoder layers?
- A
To make the model process every sequence one token at a time like an RNN.
- B
To apply successive layers of transformations and attention to the representations.
- C
To guarantee that all attention heads learn identical projections.
- D
To ensure each input token is assigned a separate reference translation.
Correct answer
BTo apply successive layers of transformations and attention to the representations.
Explanation
The transformer uses repeated encoder and decoder modules, allowing representations to be processed through successive layers.
- A
- 60
Which representations supply the keys and values in a decoder’s cross-attention layer?
- A
The encoded representations of the source input.
- B
The decoder’s future target tokens.
- C
The output probabilities from the final softmax.
- D
The reference labels for the target sentence.
Correct answer
AThe encoded representations of the source input.
Explanation
Cross-attention uses encoder outputs as keys and values, allowing the decoder to draw on the source input.
- A
- 61
Which description correctly identifies the query in decoder cross-attention?
- A
It comes from the decoder and expresses what information the current output position needs.
- B
It comes from the source text and represents every future output token.
- C
It is the final probability distribution over the target vocabulary.
- D
It is the position encoding added to the encoder input.
Correct answer
AIt comes from the decoder and expresses what information the current output position needs.
Explanation
The decoder provides the query, while the encoder supplies keys and values; the query is used to find relevant source information.
- A
- 62
How does autoregressive decoding typically begin?
- A
The decoder receives the end-of-sequence token as its first input.
- B
The decoder begins with a complete predicted translation.
- C
The decoder receives a beginning-of-sequence token as the first input.
- D
The encoder receives a one-hot vector for every possible target sentence.
Correct answer
CThe decoder receives a beginning-of-sequence token as the first input.
Explanation
The generation process starts with a beginning-of-sequence token, which signals that the model should begin predicting output.
- A
- 63
What happens after the transformer produces a vector of scores over the vocabulary at a decoding step?
- A
A reference metric changes the highest score into an EOS token.
- B
A tokenizer converts the scores into a source-language sentence.
- C
A position encoding replaces the scores with the hidden state.
- D
A softmax turns the scores into a probability distribution for selecting the next token.
Correct answer
DA softmax turns the scores into a probability distribution for selecting the next token.
Explanation
The final linear projection produces vocabulary scores, and softmax converts them into probabilities for the next token.
- A
- 64
When does autoregressive generation normally stop?
- A
When the model predicts a token with probability below one-half.
- B
When the model generates the beginning-of-sequence token again.
- C
When the model generates the end-of-sequence token.
- D
When the model has attended to every encoder token once.
Correct answer
CWhen the model generates the end-of-sequence token.
Explanation
The lecture explains that a special end-of-sequence token signals that generation should stop.
- A
- 65
What does label smoothing change during next-token training?
- A
It replaces the model’s output probabilities with a one-hot vector before training.
- B
It replaces a fully certain one-hot target with a softer target that assigns some probability to alternatives.
- C
It removes all alternative tokens from the output vocabulary.
- D
It changes the input tokens into labels for sentiment classification.
Correct answer
BIt replaces a fully certain one-hot target with a softer target that assigns some probability to alternatives.
Explanation
Label smoothing softens the target distribution, reflecting that multiple continuations can be plausible rather than treating one target as absolutely certain.
- A
- 66
Why can label smoothing be useful for language generation?
- A
It makes the model predict the same token regardless of context.
- B
A phrase always has exactly one valid continuation, so alternative predictions should be impossible.
- C
It eliminates the need to calculate probabilities over the vocabulary.
- D
A phrase can have several valid continuations, so training need not treat the observed next token as the only plausible option.
Correct answer
DA phrase can have several valid continuations, so training need not treat the observed next token as the only plausible option.
Explanation
Natural language often admits multiple reasonable next words; label smoothing makes the target less absolute, and the lecture notes that it can improve BLEU.
- A

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