Question 1
Transformers process input tokens:
One at a time (sequentially)
In reverse order
All at once (in parallel)
Only after seeing the full input
The IIT Madras BS Large Language Models (LLM) Quiz 1 paper sat on 13 Jul 2025, in the May 2025 term: 21 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
Transformers process input tokens:
One at a time (sequentially)
In reverse order
All at once (in parallel)
Only after seeing the full input
Correct answer
All at once (in parallel)
What is the purpose of the softmax function in the attention mechanism?
Normalize attention scores to a probability distribution
Add non-linearity to the model
To predict the correct class for the loss function
Remove redundant features from the input
Correct answer
Normalize attention scores to a probability distribution
What is the main difference between GPT and BERT pre-training objectives?
GPT uses Masked Language Modeling, BERT uses Causal Language Modeling
GPT uses Causal Language Modeling, BERT uses Masked Language Modeling
Both use Masked Language Modeling
Both use Causal Language Modeling
Correct answer
GPT uses Causal Language Modeling, BERT uses Masked Language Modeling
In Top-K sampling for language generation, increasing the value of K typically has which of the following effects?
It makes the output more deterministic and repetitive.
It reduces the probability of selecting high-frequency words.
It increases the diversity of the generated text but may reduce coherence if K is too large.
It guarantees grammatical correctness by focusing on top-ranked tokens only.
Correct answer
It increases the diversity of the generated text but may reduce coherence if K is too large.
Why are residual connections important in transformer architectures?
They reduce memory consumption.
They add extra cost of compute by adding batch normalization.
They help in training deep networks by enabling gradient flow.
They remove the need for layer normalization.
Correct answer
They help in training deep networks by enabling gradient flow.
Which of the following statements are true regarding causal language modeling (CLM)?
The model only attends to past and current tokens during training.
The model is trained by predicting the next token in a sequence.
The model uses bidirectional context.
The CLM objective is commonly used for encoder-only models.
Correct answers
The model only attends to past and current tokens during training.
The model is trained by predicting the next token in a sequence.
Which of the following are valid reasons why transformer-based large language models are widely used in natural language processing?
Transformers process input sequences in parallel, enabling faster training.
They use recurrence to remember long-term dependencies more effectively than LSTMs.
Transformers are limited to short text inputs due to their architecture.
Large transformer models can be fine-tuned for various NLP tasks using a single pre-trained model.
Correct answers
Transformers process input sequences in parallel, enabling faster training.
Large transformer models can be fine-tuned for various NLP tasks using a single pre-trained model.
Which elements are included in BERT’s input representation for Next Sentence Prediction?
Correct answers
How does Top-p (nucleus) sampling differ from Top-K sampling in language generation?
It samples only from a fixed number of tokens at each step.
It samples from the smallest set of tokens whose cumulative probability exceeds p.
It always selects the top-p tokens with equal probability.
It guarantees diversity by selecting all low-probability tokens.
Correct answer
It samples from the smallest set of tokens whose cumulative probability exceeds p.
Consider the embedding vector for a word, . Suppose the word is at position 3 in the given sentence. Add the corresponding position embedding to the word embedding to get , i.e. the sum of the elements in . Use the fixed sinusoidal position embedding vector calculated using the formula given below
What is the value of i.e. substract second element from the first element of vector ? (Answer correct up to 2 values after the decimal)
Correct answer: 2.03 (accepted within ±0.05)
Suppose a language model outputs the following logits for a vocabulary of size 4:
| Token | Logit |
|---|---|
| the | 2.0 |
| sky | 1.0 |
| is | 0.5 |
| blue |
You apply temperature scaling with temperature . After applying the softmax on the temperature-scaled logits, what is the probability assigned to the token “the”? (Give your answer up to 2 decimal places)
Correct answer: 0.84 (accepted within ±0.03)
Correct answer: 1 (accepted within ±0.1)
Question Description
Based on the above data, answer the given subquestions.
Select the scaled dot-product attention for the first head:
Correct answer
Question Description
Based on the above data, answer the given subquestions.
Select the scaled dot-product attention for the second head:
Correct answer
Question Description
Based on the above data, answer the given subquestions.
Concatenate the outputs from both the attention heads, then apply the output projection matrix Wo to produce the final output of the multi-head attention mechanism. Select the correct result of this operation.
Correct answer
Based on the above data, answer the given subquestions.
For the given input matrix X and multihead attention output MHA(X), apply a residual connection and store the result in matrix R, and finally compute the sum of all elements in matrix R.
Correct answer: 36
Based on the above data, answer the given subquestions.
Correct answer: 8
Based on the above data, answer the given subquestions.
Correct answer: 8
The table presents the conditional probability distribution over vocabulary tokens at each timestep during sequence generation. Each column corresponds to a timestep (from 1 to 5), and the values represent the probability of selecting each token given the tokens chosen in all previous timesteps. For timestep t, the values in the column represent:
timesteps
| 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|
| the | 0.07 | 0.19 | 0.20 | 0.42 | 0.08 |
| is | 0.04 | 0.13 | 0.12 | 0.26 | 0.08 |
| sky | 0.23 | 0.12 | 0.35 | 0.05 | 0.15 |
| today | 0.03 | 0.18 | 0.16 | 0.16 | 0.46 |
| very | 0.22 | 0.01 | 0.07 | 0.11 | 0.15 |
| blue | 0.33 | 0.25 | 0.08 | 0.05 | 0.08 |
Table 1: Probability distribution over vocabulary tokens at each timestep
Based on the above data, answer the given subquestions.
In exhaustive search, at timestep t=1, we run the decoder once to obtain probability distributions over all tokens in the vocabulary. Given the 6 tokens available in the table in the main question, how many times must we run the decoder at timestep t=4?
Correct answer: 216
The table presents the conditional probability distribution over vocabulary tokens at each timestep during sequence generation. Each column corresponds to a timestep (from 1 to 5), and the values represent the probability of selecting each token given the tokens chosen in all previous timesteps. For timestep t, the values in the column represent:
timesteps
| 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|
| the | 0.07 | 0.19 | 0.20 | 0.42 | 0.08 |
| is | 0.04 | 0.13 | 0.12 | 0.26 | 0.08 |
| sky | 0.23 | 0.12 | 0.35 | 0.05 | 0.15 |
| today | 0.03 | 0.18 | 0.16 | 0.16 | 0.46 |
| very | 0.22 | 0.01 | 0.07 | 0.11 | 0.15 |
| blue | 0.33 | 0.25 | 0.08 | 0.05 | 0.08 |
Table 1: Probability distribution over vocabulary tokens at each timestep
Based on the above data, answer the given subquestions.
How many total sequences of exactly length 5 are possible according to exhaustive search?
Correct answer: 7776
The table presents the conditional probability distribution over vocabulary tokens at each timestep during sequence generation. Each column corresponds to a timestep (from 1 to 5), and the values represent the probability of selecting each token given the tokens chosen in all previous timesteps. For timestep t, the values in the column represent:
timesteps
| 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|
| the | 0.07 | 0.19 | 0.20 | 0.42 | 0.08 |
| is | 0.04 | 0.13 | 0.12 | 0.26 | 0.08 |
| sky | 0.23 | 0.12 | 0.35 | 0.05 | 0.15 |
| today | 0.03 | 0.18 | 0.16 | 0.16 | 0.46 |
| very | 0.22 | 0.01 | 0.07 | 0.11 | 0.15 |
| blue | 0.33 | 0.25 | 0.08 | 0.05 | 0.08 |
Table 1: Probability distribution over vocabulary tokens at each timestep
Based on the above data, answer the given subquestions.
If we use top-k sampling with k=2 at timestep 1, what is the normalized probability of selecting token “sky” at the timestep=1?
Correct answer: 0.41