Large Language Models End Term: 31 August 2025, Set QDB1 (May 2025 term)
The IIT Madras BS Large Language Models (LLM) End Term paper sat on 31 Aug 2025, in the May 2025 term, set QDB1: 17 questions for 40 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
Official paper: IIT M DEGREE AN EXAM QDB3 31 Aug 2025 · No negative marking.
Question 1
+2 marksOne correct option
Given the input string:
moonlight
And the following vocabulary of subword tokens with their corresponding log-probabilities:
Subword
Log-Probability (base e)
moon
-0.4
light
-1.0
moonlight
-1.8
moo
-0.3
nlight
-0.6
n
-2.0
li
-0.5
ght
-0.5
Using the Viterbi algorithm (as used in the SentencePiece tokenizer), determine the most probable tokenization of the input string. The probability of a tokenized sequence is the sum of the log-probabilities of the selected subwords. Only subwords from the vocabulary may be used.
A GPT-based model is fine-tuned for story generation. During evaluation, you test different decoding strategies on the same prompt:
1. Method A: Every run produces the exact same story, even when executed multiple times. 2. Method B: The story changes slightly in each run, but overall structure and key events remain similar.
3. Method C: The story is wildly different each time, sometimes even changing the genre. Based on the observations, select the most likely decoding strategies for each method:
Select all that apply.
A
Method A: Greedy decoding
B
Method A: Top-K sampling with K = 50
C
Method B: Top-P sampling with p = 0.9
D
Method C: Top-P sampling with p = 0.5 and high temperature T = 1.5
E
Method C: Beam search with K = 5
Show answerTap to reveal
Correct answers
A
Method A: Greedy decoding
C
Method B: Top-P sampling with p = 0.9
D
Method C: Top-P sampling with p = 0.5 and high temperature T = 1.5
Suppose a language model outputs the following logits for a vocabulary of size 4:
Token
Logit
cat
1.5
sat
0.5
on
0.0
mat
−0.5
You apply Low Temperature Sampling with temperature T=2.0. After applying the softmax on the temperature-scaled logits, what is the probability assigned to the token “cat”? (Give your answer up to 2 decimal places)
Answer the given subquestions. If you believe the information is insufficient, enter -1 as your answer.
For the input “you enjoy tea often”, compute the final representation of the word “tea” after the attention layer (i.e., after applying WQ, WK, WV , attention weights, and WO). Enter the sum of the elements in the resulting vector.
Answer the given subquestions. If you believe the information is insufficient, enter -1 as your answer.
Suppose the input sentence is “tea you enjoy often”. Using the same matrices and processing method, what is the attention score (i.e., softmax entry from A) for the query word “tea” attending to key word “often”?
A transformer processes this sequence using the naive relative positional embedding method. The transformer's embedding dimension is dmodel=4, and the number of tokens is T=5. We use zero-based indexing for token positions:
0:large1:language2:models3:are4:cool
Note: In this context, the relative position (k) between two tokens is:
Relative position=j−i
rows = current token i, cols = other token j
Positive values mean the other token is after the current token, negative values mean it is before, and 0 means it is the same token.
Token embeddings (rows correspond to tokens in order):
X=12345123451234512345
Denote the i-th row by xi.
Positional embedding definition: For a relative position k∈Z,
p(j−i)=[10(j−i)10(j−i)10(j−i)10(j−i)].
Based on the above data, answer the given subquestions.
A transformer processes this sequence using the naive relative positional embedding method. The transformer's embedding dimension is dmodel=4, and the number of tokens is T=5. We use zero-based indexing for token positions:
0:large1:language2:models3:are4:cool
Note: In this context, the relative position (k) between two tokens is:
Relative position=j−i
rows = current token i, cols = other token j
Positive values mean the other token is after the current token, negative values mean it is before, and 0 means it is the same token.
Token embeddings (rows correspond to tokens in order):
X=12345123451234512345
Denote the i-th row by xi.
Positional embedding definition: For a relative position k∈Z,
p(j−i)=[10(j−i)10(j−i)10(j−i)10(j−i)].
Based on the above data, answer the given subquestions.
A transformer processes this sequence using the naive relative positional embedding method. The transformer's embedding dimension is dmodel=4, and the number of tokens is T=5. We use zero-based indexing for token positions:
0:large1:language2:models3:are4:cool
Note: In this context, the relative position (k) between two tokens is:
Relative position=j−i
rows = current token i, cols = other token j
Positive values mean the other token is after the current token, negative values mean it is before, and 0 means it is the same token.
Token embeddings (rows correspond to tokens in order):
X=12345123451234512345
Denote the i-th row by xi.
Positional embedding definition: For a relative position k∈Z,
p(j−i)=[10(j−i)10(j−i)10(j−i)10(j−i)].
Based on the above data, answer the given subquestions.
With a naive implementation, for each token embedding, we need a way to combine (say, addition) relative position embeddings. For token index i∈{0,…,T−1},
hi=xi+∑j=0T−1pj−i.
Using the naive formula above, compute the final combined embedding hi for the token "language" (i.e., i=1). Submit the sum of all the elements.
A transformer processes this sequence using the naive relative positional embedding method. The transformer's embedding dimension is dmodel=4, and the number of tokens is T=5. We use zero-based indexing for token positions:
0:large1:language2:models3:are4:cool
Note: In this context, the relative position (k) between two tokens is:
Relative position=j−i
rows = current token i, cols = other token j
Positive values mean the other token is after the current token, negative values mean it is before, and 0 means it is the same token.
Token embeddings (rows correspond to tokens in order):
X=12345123451234512345
Denote the i-th row by xi.
Positional embedding definition: For a relative position k∈Z,
p(j−i)=[10(j−i)10(j−i)10(j−i)10(j−i)].
Based on the above data, answer the given subquestions.