Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 5 MCQsTransformers and Pretrained Language Models
Question 1 of 60 · Transformer architecture · Easy
What mechanism allows a Transformer to model relationships between tokens without using recurrence?
Not quite. Try another option.
Answer: Self-attention
Transformers use self-attention to directly model relationships between tokens in a sequence.
Question 2 of 60 · Self-attention · Easy
In self-attention, what does each token attend to?
Not quite. Try another option.
Answer: Tokens in the same sequence
Self-attention lets each token use information from other tokens in the same input sequence.
Question 3 of 60 · Multi-head attention · Easy
What is the main purpose of using multiple attention heads?
Not quite. Try another option.
Answer: To learn different relationships
Multiple heads can focus on different types of relationships, such as syntax or long-range dependencies.
Question 4 of 60 · Positional encoding · Easy
Why is positional encoding added to token embeddings in a Transformer?
Not quite. Try another option.
Answer: To indicate token order
Because self-attention does not inherently represent sequence order, positional encoding provides position information.
Question 5 of 60 · Transformer encoder and decoder blocks · Easy
Which Transformer component typically processes the input sequence into contextual representations?
Not quite. Try another option.
Answer: Encoder stack
The encoder stack converts input tokens into contextual representations used by later layers.
Question 6 of 60 · Tokenization methods · Easy
What is the purpose of tokenization in NLP?
Not quite. Try another option.
Answer: To divide text into units
Tokenization divides text into units, such as words, subwords, or characters, that a model can process.
Question 7 of 60 · Byte-Pair Encoding · Easy
How does Byte-Pair Encoding commonly build subword tokens?
Not quite. Try another option.
Answer: By merging frequent symbol pairs
Byte-Pair Encoding repeatedly merges frequent adjacent symbol pairs to form useful subword units.
Question 8 of 60 · WordPiece · Easy
What kind of units does WordPiece primarily use to represent text?
Not quite. Try another option.
Answer: Subword pieces
WordPiece represents text using subword units, helping the model handle rare and unfamiliar words.
Question 9 of 60 · Pretrained transformer models · Easy
What does it mean when a Transformer model is pretrained?
Not quite. Try another option.
Answer: It has learned from a large corpus
A pretrained model first learns broad language patterns from a large text corpus before task-specific training.
Question 10 of 60 · BERT · Easy
Which Transformer structure is primarily used by the original BERT model?
Not quite. Try another option.
Answer: Encoder-only structure
BERT uses Transformer encoder blocks to learn bidirectional contextual representations.
Question 11 of 60 · GPT · Easy
Which task is GPT especially well suited for?
Not quite. Try another option.
Answer: Autoregressive text generation
GPT predicts tokens from left to right, making it well suited for generating text.
Question 12 of 60 · T5 · Easy
How does T5 represent many NLP tasks?
Not quite. Try another option.
Answer: As text-to-text problems
T5 treats both task inputs and outputs as text, providing one format for many NLP tasks.
Question 13 of 60 · Masked language modeling · Easy
What does a model learn to do during masked language modeling?
Not quite. Try another option.
Answer: Predict hidden input tokens
Masked language modeling hides selected tokens and trains the model to predict their original values.
Question 14 of 60 · Next sentence prediction · Easy
What does next sentence prediction ask a model to determine?
Not quite. Try another option.
Answer: Whether one sentence follows another
Next sentence prediction trains a model to identify whether a second sentence naturally follows a first sentence.
Question 15 of 60 · Causal language modeling · Easy
In causal language modeling, which information is used to predict the next token?
Not quite. Try another option.
Answer: Previous tokens
A causal language model predicts the next token using tokens that appear earlier in the sequence.
Question 16 of 60 · Transfer learning for NLP tasks · Easy
What is transfer learning in NLP?
Not quite. Try another option.
Answer: Applying learned knowledge to a new task
Transfer learning reuses knowledge from pretraining to improve performance on a different NLP task.
Question 17 of 60 · Fine-tuning for text classification · Easy
What is typically added to a pretrained Transformer for text classification?
Not quite. Try another option.
Answer: A classification head
A classification head maps the model's representation to labels such as positive, negative, or neutral.
Question 18 of 60 · Named entity recognition · Easy
What does named entity recognition identify in text?
Not quite. Try another option.
Answer: People, places, and organizations
Named entity recognition finds and labels entities such as people, locations, and organizations.
Question 19 of 60 · Question answering · Easy
In extractive question answering, where does the answer usually come from?
Not quite. Try another option.
Answer: A span in the given passage
Extractive question answering selects a continuous span of text from the provided context.
Question 20 of 60 · HuggingFace Transformers · Easy
What does the HuggingFace Transformers library primarily provide?
Not quite. Try another option.
Answer: Pretrained models and NLP tools
HuggingFace Transformers provides pretrained models, tokenizers, and utilities for common NLP workflows.
Question 21 of 60 · Transformer architecture · Medium
A Transformer processes a sequence without using recurrence. Which mechanism allows each token representation to incorporate information from other tokens in the same layer?
Not quite. Try another option.
Answer: Self-attention over token representations
Self-attention allows every token to assign weights to other tokens and combine their representations, enabling global interaction without recurrence.
Question 22 of 60 · Self-attention · Medium
In scaled dot-product attention, why is the query-key dot product divided by ?
Not quite. Try another option.
Answer: To reduce the variance of large dot products
When the key dimension is large, dot products can have large magnitudes and produce saturated softmax values. Scaling by helps maintain stable gradients.
Question 23 of 60 · Multi-head attention · Medium
Why can multi-head attention represent relationships that a single attention head might miss?
Not quite. Try another option.
Answer: Each head can learn a different projection and relationship pattern
Different heads project the inputs into different subspaces, allowing them to focus on patterns such as syntax, long-distance dependencies, or semantic similarity.
Question 24 of 60 · Positional encoding · Medium
A Transformer receives the same set of token embeddings in two different orders. What is the main purpose of positional encoding in this situation?
Not quite. Try another option.
Answer: To make the representations sensitive to token order
Self-attention alone does not inherently distinguish token order. Positional encodings add position-dependent information so different sequences can produce different representations.
Question 25 of 60 · Transformer encoder and decoder blocks · Medium
During text generation, which attention pattern is required in a Transformer decoder to prevent a token from using future target tokens?
Not quite. Try another option.
Answer: A causal mask on decoder self-attention
A causal mask blocks attention to future positions, ensuring that each generated token depends only on earlier tokens and the current decoding context.
Question 26 of 60 · Tokenization methods · Medium
A tokenizer represents an unfamiliar word using several meaningful or partially meaningful pieces instead of mapping it to one unknown token. What advantage does this provide?
Not quite. Try another option.
Answer: It reduces out-of-vocabulary problems
Subword tokenization can represent rare or unseen words by combining known pieces, reducing reliance on a single unknown-token symbol.
Question 27 of 60 · Byte-Pair Encoding · Medium
In Byte-Pair Encoding for subword tokenization, a frequent adjacent symbol pair is repeatedly merged. If t and h frequently occur together, what may happen after training?
Not quite. Try another option.
Answer: The pair t h may become the token th
BPE builds subword units by merging frequent adjacent symbols. A frequent pair such as t and h can therefore become a reusable subword token.
Question 28 of 60 · WordPiece · Medium
A WordPiece tokenizer splits the word "unhappiness" into un, ##happi, and ##ness. What does the ## marker usually indicate?
Not quite. Try another option.
Answer: The piece continues a word rather than starting one
In common WordPiece notation, ## marks a subword that attaches to the preceding piece without beginning a new word.
Question 29 of 60 · Pretrained transformer models · Medium
A team has limited labeled data for sentiment analysis but access to a large pretrained Transformer. Which strategy is generally most appropriate?
Not quite. Try another option.
Answer: Fine-tune the pretrained model on labeled sentiment examples
Fine-tuning adapts general language representations learned during pretraining to the target task, which is useful when labeled data is limited.
Question 30 of 60 · BERT · Medium
Why is BERT particularly suitable for classifying a sentence based on both earlier and later context?
Not quite. Try another option.
Answer: Its encoder uses bidirectional self-attention
BERT's encoder can attend to tokens on both sides of a position, producing context-sensitive representations that use the full input sequence.
Question 31 of 60 · GPT · Medium
Which task aligns most directly with the original design of a GPT-style Transformer?
Not quite. Try another option.
Answer: Generating the next token from preceding tokens
GPT models use decoder-style causal language modeling, where each token is predicted from the tokens that precede it.
Question 32 of 60 · T5 · Medium
A T5 model is fine-tuned to answer questions. How is the task typically represented for the model?
Not quite. Try another option.
Answer: As text input mapped to text output
T5 uses a text-to-text framework. A question and its context are provided as text, and the answer is generated as text.
Question 33 of 60 · Masked language modeling · Medium
During masked language model pretraining, a model sees the sentence "The cat sat on the [MASK]." Which prediction best describes the training target?
Not quite. Try another option.
Answer: The original token at the masked position
Masked language modeling trains the model to reconstruct selected original tokens using their surrounding context.
Question 34 of 60 · Next sentence prediction · Medium
In the next sentence prediction objective, what does the model typically learn to determine?
Not quite. Try another option.
Answer: Whether one sentence logically follows another
Next sentence prediction uses sentence pairs and asks the model to classify whether the second sentence follows the first in the original text.
Question 35 of 60 · Causal language modeling · Medium
For the token sequence , what conditional factorization is used by a causal language model?
Not quite. Try another option.
Answer:
Causal language modeling factorizes the sequence from left to right. Each token is predicted using only the tokens before it.
Question 36 of 60 · Transfer learning for NLP tasks · Medium
What is the main benefit of transferring a pretrained language model to a new NLP task?
Not quite. Try another option.
Answer: It reuses general linguistic representations learned from broad data
Pretraining captures reusable patterns in language. Transfer learning adapts these patterns to a downstream task with less task-specific data and computation.
Question 37 of 60 · Fine-tuning for text classification · Medium
A binary text classifier is built with BERT. Which change is normally made to produce the final prediction?
Not quite. Try another option.
Answer: Add a classification head over a sequence representation
A task-specific classification layer maps a pooled or special-token representation to class scores. The pretrained parameters may then be updated during fine-tuning.
Question 38 of 60 · Named entity recognition · Medium
For named entity recognition, why are predictions usually made for individual tokens rather than only for the entire sentence?
Not quite. Try another option.
Answer: Each token may have a different entity label
NER is a sequence-labeling task. Tokens can receive labels such as B-PER, I-PER, B-ORG, or O, so predictions are made across the sequence.
Question 39 of 60 · Question answering · Medium
In extractive question answering, the answer is contained in a context passage. What does the model typically predict?
Not quite. Try another option.
Answer: The start and end positions of the answer span
Extractive QA models usually assign scores to possible start and end token positions, identifying a span from the supplied context.
Question 40 of 60 · HuggingFace Transformers · Medium
When using HuggingFace Transformers for a pretrained model, why should the tokenizer match the model checkpoint?
Not quite. Try another option.
Answer: It preserves the checkpoint's vocabulary and token-ID mapping
The model's embedding matrix is indexed by token IDs learned with its associated tokenizer. Using a different tokenizer can produce incompatible or incorrect inputs.
Question 41 of 60 · Transformer architecture · Hard
A Transformer processes a sequence of length with hidden size . Ignoring constants and feed-forward layers, which change most directly reduces the asymptotic self-attention cost while preserving ?
Not quite. Try another option.
Answer: Reducing the sequence length from to
Dense self-attention costs . Halving reduces its leading computation by about a factor of four; changing the head count while preserving does not change this asymptotic cost.
Question 42 of 60 · Self-attention · Hard
For and , what is the first output row of scaled dot-product self-attention with key dimension and no mask?
Not quite. Try another option.
Answer: , where
The first query has scaled scores , so its attention weights are . Multiplying these weights by gives .
Question 43 of 60 · Multi-head attention · Hard
A model has and 12 attention heads. It is changed to 24 heads while all query, key, value, and output projections remain dense matrices. Which statement is correct?
Not quite. Try another option.
Answer: Each head dimension becomes 32, while projection parameter counts remain unchanged
With equal-sized heads, . Dense projections still map 768 dimensions to 768 dimensions, so their parameter counts do not depend on the head partition.
Question 44 of 60 · Positional encoding · Hard
Why can sinusoidal positional encodings support reasoning about relative offsets without learning a separate vector for every offset?
Not quite. Try another option.
Answer: A fixed linear transformation relates the encoding at to that at for fixed
Angle-addition identities express sine and cosine at as linear combinations of those at . For a fixed offset , this relation is position-independent.
Question 45 of 60 · Transformer encoder and decoder blocks · Hard
During teacher-forced training of a standard encoder-decoder Transformer, which masking configuration is required?
The encoder must ignore source padding, the decoder must not see future target tokens, and cross-attention must ignore padded encoder positions.
Question 46 of 60 · Tokenization methods · Hard
A production NLP system must accept arbitrary Unicode input without emitting an unknown-token symbol. Which tokenizer design most directly guarantees this property, assuming valid byte input?
Not quite. Try another option.
Answer: A byte-level tokenizer whose base vocabulary contains every byte value
Any encoded string is a sequence of bytes, so a vocabulary covering all byte values can represent arbitrary input. Corpus-derived word or character vocabularies can still encounter unseen units.
Question 47 of 60 · Byte-Pair Encoding · Hard
A BPE trainer starts with the segmented corpus low low lower represented as characters plus end-of-word markers. If (l,o) and (o,w) have equal maximum frequency, what is required for independently trained tokenizers to produce identical vocabularies?
Not quite. Try another option.
Answer: A deterministic tie-breaking rule and the same ordered training corpus
Tied pair frequencies can lead to different first merges, which changes later statistics. Deterministic tie resolution and identical preprocessing/order are needed for reproducible merge sequences.
Question 48 of 60 · WordPiece · Hard
Compared with frequency-only BPE merging, a WordPiece-style merge score favors a pair with high joint frequency relative to its component frequencies. Which pair is therefore most likely to be preferred?
Not quite. Try another option.
Answer: , , and
Using the common score , the values are , , , and . The first pair has the strongest association despite its lower raw count.
Question 49 of 60 · Pretrained transformer models · Hard
A task requires assigning a label using both left and right context around every token, while inference is non-generative. Which pretrained architecture-objective pairing offers the closest inductive match?
Not quite. Try another option.
Answer: An encoder-only Transformer trained with masked token prediction
Masked-token pretraining develops bidirectional contextual representations at each position, matching token labeling that depends on both left and right context.
Question 50 of 60 · BERT · Hard
In original BERT input construction for sentence-pair classification, what distinguishes tokens from sentence A and sentence B before the encoder layers?
Not quite. Try another option.
Answer: Their token embeddings are summed with different learned segment embeddings
BERT sums token, position, and token-type embeddings. Token-type IDs distinguish sentence A from sentence B while both pass through the same encoder.
Question 51 of 60 · GPT · Hard
A decoder-only GPT model is trained on packed documents. Which attention mask prevents both future-token leakage and information flow across document boundaries?
Not quite. Try another option.
Answer: A block-diagonal lower-triangular mask aligned with document boundaries
Lower-triangular blocks enforce causality within each document, while the block boundaries prevent tokens from attending to unrelated packed documents.
Question 52 of 60 · T5 · Hard
T5 pretraining replaces multiple contiguous spans with sentinel tokens. Which target format is consistent with its span-corruption objective?
Not quite. Try another option.
Answer: Sentinel token, first missing span, next sentinel token, second missing span
The encoder input marks each removed span with a distinct sentinel. The decoder target concatenates each sentinel with its corresponding missing span in order.
Question 53 of 60 · Masked language modeling · Hard
In BERT-style masking, selected tokens are not always replaced by [MASK]; some remain unchanged or become random tokens. What mismatch is this strategy primarily intended to reduce?
Not quite. Try another option.
Answer: The absence of the artificial [MASK] token during downstream inference
Downstream inputs normally contain no [MASK]. Occasionally retaining or randomly replacing selected tokens reduces overdependence on a symbol seen mainly during pretraining.
Question 54 of 60 · Next sentence prediction · Hard
Why can randomly sampled negative pairs make next sentence prediction solvable through shortcuts rather than discourse understanding?
Not quite. Try another option.
Answer: Negative sentences may differ in topic or document style from positive continuations
A model can exploit topic, source, or style mismatch to identify random negatives without learning whether one sentence coherently follows another.
Question 55 of 60 · Causal language modeling · Hard
A causal language model assigns token probabilities , , and to the three observed next tokens. Using natural logarithms, what is the mean token negative log-likelihood?
Not quite. Try another option.
Answer:
The mean is .
Question 56 of 60 · Transfer learning for NLP tasks · Hard
A pretrained encoder performs well on general text but overfits a 500-example legal dataset during full fine-tuning. Which intervention most directly reduces trainable capacity while retaining task adaptation?
Not quite. Try another option.
Answer: Freeze the encoder and train a task-specific classification head
Freezing the pretrained encoder sharply reduces the number of trainable parameters. The new head can adapt representations to labels with less overfitting risk.
Question 57 of 60 · Fine-tuning for text classification · Hard
A classifier truncates every document to the first 512 tokens, but decisive evidence often appears near the end. Which change addresses the information-loss mechanism most directly?
Not quite. Try another option.
Answer: Classify overlapping chunks and aggregate their document-level evidence
Chunking exposes later content to the encoder, and aggregation combines evidence across the document. The other changes regularize optimization but do not recover discarded text.
Question 58 of 60 · Named entity recognition · Hard
The word Washington is split into Wash, ##ing, and ##ton. Under a first-subtoken labeling scheme, how should loss and prediction alignment usually be handled?
Not quite. Try another option.
Answer: Assign the entity label to Wash and ignore the other subtokens in the loss
First-subtoken alignment preserves one supervised decision per original word. Continuation subtokens commonly receive an ignore index so they do not distort word-level evaluation or loss.
Question 59 of 60 · Question answering · Hard
In extractive QA, a model independently scores start and end positions. Which decoding rule avoids invalid spans while respecting a maximum answer length ?
Not quite. Try another option.
Answer: Maximize subject to and
Joint constrained decoding combines start and end logits while enforcing valid order and length. Independent argmax decisions can produce reversed or implausibly long spans.
Question 60 of 60 · HuggingFace Transformers · Hard
A HuggingFace token-classification pipeline pads batches to different lengths. Which setup ensures padded positions neither affect encoder attention nor contribute to cross-entropy loss?
Not quite. Try another option.
Answer: Set attention_mask to 0 and labels to -100 at padded positions
The attention mask excludes padding from attention, while HuggingFace token-classification losses conventionally use -100 as the ignored label index.
That's unit 5
Answer a few questions and your score shows up here.
Nearly through. Did unit 5 of CSE472 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 5 of CSE472 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.