uiz Space

May 2025 term · Large Language Models · BSDA5004

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.

Questions
17
Marks
40
Duration
180 min
MCQ
5
MSQ
5
Numerical
7

Updated

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:

SubwordLog-Probability (base ee)
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.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 2

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 3

+3 marksOne or more correct options

Which of the following statements about subword tokenizers (e.g., Byte Pair Encoding, SentencePiece) is true?

Select all that apply.

  1. A

    They always split words into individual characters.

  2. B

    They help handle rare words by breaking them into smaller units.

  3. C

    They require the vocabulary to contain every possible word in the language.

  4. D

    They can reduce the overall vocabulary size compared to word-level tokenizers.

Show answer

Correct answers

  • B

    They help handle rare words by breaking them into smaller units.

  • D

    They can reduce the overall vocabulary size compared to word-level tokenizers.

Question 4

+3 marksOne or more correct options

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.

  1. A

    Method A: Greedy decoding

  2. B

    Method A: Top-K sampling with K = 50

  3. C

    Method B: Top-P sampling with p = 0.9

  4. D

    Method C: Top-P sampling with p = 0.5 and high temperature T = 1.5

  5. E

    Method C: Beam search with K = 5

Show answer

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

Question 5

+3 marksOne or more correct options

Which of the following are valid design choices when building a transformer-based language model?

Select all that apply.

  1. A

    Number of transformer layers

  2. B

    Learning rate schedule

  3. C

    Font style of the source code

  4. D

    Vocabulary size

  5. E

    Type of normalization (e.g., LayerNorm)

Show answer

Correct answers

  • A

    Number of transformer layers

  • B

    Learning rate schedule

  • D

    Vocabulary size

  • E

    Type of normalization (e.g., LayerNorm)

Question 6

+3 marksOne or more correct options

Which of the following statements about Top-k and Nucleus (Top-p) sampling are correct?

Select all that apply.

  1. A

    Top-k keeps only the k most probable tokens before sampling.

  2. B

    Top-p dynamically chooses the smallest set of tokens whose cumulative probability exceeds p.

  3. C

    Top-k is always a subset of Top-p.

  4. D

    Top-p always has a fixed number of candidate tokens.

Show answer

Correct answers

  • A

    Top-k keeps only the k most probable tokens before sampling.

  • B

    Top-p dynamically chooses the smallest set of tokens whose cumulative probability exceeds p.

Question 7

+3 marksOne or more correct options

Which of the following preprocessing steps are commonly required when preparing data for transformer models like BERT?

Select all that apply.

  1. A

    Lowercasing text (for uncased models)

  2. B

    Splitting into subword units using BPE or WordPiece

  3. C

    Removing all punctuation marks

  4. D

    Adding position indices for each token

Show answer

Correct answers

  • A

    Lowercasing text (for uncased models)

  • B

    Splitting into subword units using BPE or WordPiece

  • D

    Adding position indices for each token

Question 8

+3 marksNumerical answer

Suppose a language model outputs the following logits for a vocabulary of size 4:

TokenLogit
cat1.5
sat0.5
on0.0
mat−0.5-0.5

You apply Low Temperature Sampling with temperature T=2.0T = 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)

Show answer

Correct answer: 0.41 (accepted within ±0.03)

Question 9

+3 marksNumerical answer

A vocabulary V={tea,you,enjoy,often}\mathcal{V} = \{\text{tea}, \text{you}, \text{enjoy}, \text{often}\} is associated with the following embedding matrix:

E=[011110−11]E = \begin{bmatrix} 0 & 1 \\ 1 & 1 \\ 1 & 0 \\ -1 & 1 \end{bmatrix}

Words are indexed in the order shown above: “tea” (index 0), “you” (1), “enjoy” (2), and “often” (3). No positional encodings are used.

The parameters of the attention layer are:

WQ=[0.5110.5],WK=[10.5−0.51],WV=[10.20.51],WO=[0.50.51−1]W_Q = \begin{bmatrix} 0.5 & 1 \\ 1 & 0.5 \end{bmatrix}, \quad W_K = \begin{bmatrix} 1 & 0.5 \\ -0.5 & 1 \end{bmatrix}, \quad W_V = \begin{bmatrix} 1 & 0.2 \\ 0.5 & 1 \end{bmatrix}, \quad W_O = \begin{bmatrix} 0.5 & 0.5 \\ 1 & -1 \end{bmatrix}

For the input sequence “you enjoy tea often”. The computed attention matrix A=softmax(QK⊤dk)A = \text{softmax}\left(\frac{QK^\top}{\sqrt{d_k}}\right) is given as:

A=[0.550.320.110.020.430.250.210.10.390.390.160.070.240.40.20.17]A = \begin{bmatrix} 0.55 & 0.32 & 0.11 & 0.02 \\ 0.43 & 0.25 & 0.21 & 0.1 \\ 0.39 & 0.39 & 0.16 & 0.07 \\ 0.24 & 0.4 & 0.2 & 0.17 \end{bmatrix}

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.

Show answer

Correct answer: 1.02 (accepted within ±0.04)

Question 10

+2 marksNumerical answer

A vocabulary V={tea,you,enjoy,often}\mathcal{V} = \{\text{tea}, \text{you}, \text{enjoy}, \text{often}\} is associated with the following embedding matrix:

E=[011110−11]E = \begin{bmatrix} 0 & 1 \\ 1 & 1 \\ 1 & 0 \\ -1 & 1 \end{bmatrix}

Words are indexed in the order shown above: “tea” (index 0), “you” (1), “enjoy” (2), and “often” (3). No positional encodings are used.

The parameters of the attention layer are:

WQ=[0.5110.5],WK=[10.5−0.51],WV=[10.20.51],WO=[0.50.51−1]W_Q = \begin{bmatrix} 0.5 & 1 \\ 1 & 0.5 \end{bmatrix}, \quad W_K = \begin{bmatrix} 1 & 0.5 \\ -0.5 & 1 \end{bmatrix}, \quad W_V = \begin{bmatrix} 1 & 0.2 \\ 0.5 & 1 \end{bmatrix}, \quad W_O = \begin{bmatrix} 0.5 & 0.5 \\ 1 & -1 \end{bmatrix}

For the input sequence “you enjoy tea often”. The computed attention matrix A=softmax(QK⊤dk)A = \text{softmax}\left(\frac{QK^\top}{\sqrt{d_k}}\right) is given as:

A=[0.550.320.110.020.430.250.210.10.390.390.160.070.240.40.20.17]A = \begin{bmatrix} 0.55 & 0.32 & 0.11 & 0.02 \\ 0.43 & 0.25 & 0.21 & 0.1 \\ 0.39 & 0.39 & 0.16 & 0.07 \\ 0.24 & 0.4 & 0.2 & 0.17 \end{bmatrix}

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”?

Show answer

Correct answer: 0.07 (accepted within ±0.03)

Question 11

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 12

+1 markNumerical answer
Show answer

Correct answer: 120

Question 13

+2 marksNumerical answer

What percentage of entries in the attention matrix are zero (i.e., the sparsity)?

Show answer

Correct answer: 80

Question 14

+1 markOne correct option

Consider the short sentence:

“large language models are cool”

A transformer processes this sequence using the naive relative positional embedding method. The transformer's embedding dimension is dmodel=4d_{\text{model}} = 4, and the number of tokens is T=5T = 5. We use zero-based indexing for token positions:

0:large1:language2:models3:are4:cool0: \texttt{large} \quad 1: \texttt{language} \quad 2: \texttt{models} \quad 3: \texttt{are} \quad 4: \texttt{cool}

Note: In this context, the relative position (k) between two tokens is:

Relative position=j−i\text{Relative position} = j - i

rows == current token ii, cols == other token jj

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.

  1. Token embeddings (rows correspond to tokens in order):

    X=[11112222333344445555]\mathbf{X} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 2 & 2 & 2 & 2 \\ 3 & 3 & 3 & 3 \\ 4 & 4 & 4 & 4 \\ 5 & 5 & 5 & 5 \end{bmatrix}

    Denote the ii-th row by xi\boldsymbol{x}_i.

  2. Positional embedding definition: For a relative position k∈Zk \in \mathbb{Z},

    p(j−i)=[(j−i)10(j−i)10(j−i)10(j−i)10].\boldsymbol{p}_{(j-i)} = \left[\frac{(j-i)}{10} \quad \frac{(j-i)}{10} \quad \frac{(j-i)}{10} \quad \frac{(j-i)}{10}\right].

Based on the above data, answer the given subquestions.

  1. A

    (0, 1, 2, 3, 4)

  2. B

    (-1, 0, 1, 2, 3)

  3. C

    (-2, -1, 0, 1, 2)

  4. D

    (-3, -2, -1, 0, 1)

Show answer

Correct answer

  • C

    (-2, -1, 0, 1, 2)

Question 15

+1 markOne correct option

Consider the short sentence:

“large language models are cool”

A transformer processes this sequence using the naive relative positional embedding method. The transformer's embedding dimension is dmodel=4d_{\text{model}} = 4, and the number of tokens is T=5T = 5. We use zero-based indexing for token positions:

0:large1:language2:models3:are4:cool0: \texttt{large} \quad 1: \texttt{language} \quad 2: \texttt{models} \quad 3: \texttt{are} \quad 4: \texttt{cool}

Note: In this context, the relative position (k) between two tokens is:

Relative position=j−i\text{Relative position} = j - i

rows == current token ii, cols == other token jj

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.

  1. Token embeddings (rows correspond to tokens in order):

    X=[11112222333344445555]\mathbf{X} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 2 & 2 & 2 & 2 \\ 3 & 3 & 3 & 3 \\ 4 & 4 & 4 & 4 \\ 5 & 5 & 5 & 5 \end{bmatrix}

    Denote the ii-th row by xi\boldsymbol{x}_i.

  2. Positional embedding definition: For a relative position k∈Zk \in \mathbb{Z},

    p(j−i)=[(j−i)10(j−i)10(j−i)10(j−i)10].\boldsymbol{p}_{(j-i)} = \left[\frac{(j-i)}{10} \quad \frac{(j-i)}{10} \quad \frac{(j-i)}{10} \quad \frac{(j-i)}{10}\right].

Based on the above data, answer the given subquestions.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 16

+3 marksNumerical answer

Consider the short sentence:

“large language models are cool”

A transformer processes this sequence using the naive relative positional embedding method. The transformer's embedding dimension is dmodel=4d_{\text{model}} = 4, and the number of tokens is T=5T = 5. We use zero-based indexing for token positions:

0:large1:language2:models3:are4:cool0: \texttt{large} \quad 1: \texttt{language} \quad 2: \texttt{models} \quad 3: \texttt{are} \quad 4: \texttt{cool}

Note: In this context, the relative position (k) between two tokens is:

Relative position=j−i\text{Relative position} = j - i

rows == current token ii, cols == other token jj

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.

  1. Token embeddings (rows correspond to tokens in order):

    X=[11112222333344445555]\mathbf{X} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 2 & 2 & 2 & 2 \\ 3 & 3 & 3 & 3 \\ 4 & 4 & 4 & 4 \\ 5 & 5 & 5 & 5 \end{bmatrix}

    Denote the ii-th row by xi\boldsymbol{x}_i.

  2. Positional embedding definition: For a relative position k∈Zk \in \mathbb{Z},

    p(j−i)=[(j−i)10(j−i)10(j−i)10(j−i)10].\boldsymbol{p}_{(j-i)} = \left[\frac{(j-i)}{10} \quad \frac{(j-i)}{10} \quad \frac{(j-i)}{10} \quad \frac{(j-i)}{10}\right].

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}i \in \{0, \ldots, T-1\},

hi=xi+∑j=0T−1pj−i.\boldsymbol{h}_i = \boldsymbol{x}_i + \sum_{j=0}^{T-1} \boldsymbol{p}_{j-i}.

Using the naive formula above, compute the final combined embedding hi\boldsymbol{h}_i for the token "language" (i.e., i=1i = 1). Submit the sum of all the elements.

Show answer

Correct answer: 10

Question 17

+3 marksNumerical answer

Consider the short sentence:

“large language models are cool”

A transformer processes this sequence using the naive relative positional embedding method. The transformer's embedding dimension is dmodel=4d_{\text{model}} = 4, and the number of tokens is T=5T = 5. We use zero-based indexing for token positions:

0:large1:language2:models3:are4:cool0: \texttt{large} \quad 1: \texttt{language} \quad 2: \texttt{models} \quad 3: \texttt{are} \quad 4: \texttt{cool}

Note: In this context, the relative position (k) between two tokens is:

Relative position=j−i\text{Relative position} = j - i

rows == current token ii, cols == other token jj

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.

  1. Token embeddings (rows correspond to tokens in order):

    X=[11112222333344445555]\mathbf{X} = \begin{bmatrix} 1 & 1 & 1 & 1 \\ 2 & 2 & 2 & 2 \\ 3 & 3 & 3 & 3 \\ 4 & 4 & 4 & 4 \\ 5 & 5 & 5 & 5 \end{bmatrix}

    Denote the ii-th row by xi\boldsymbol{x}_i.

  2. Positional embedding definition: For a relative position k∈Zk \in \mathbb{Z},

    p(j−i)=[(j−i)10(j−i)10(j−i)10(j−i)10].\boldsymbol{p}_{(j-i)} = \left[\frac{(j-i)}{10} \quad \frac{(j-i)}{10} \quad \frac{(j-i)}{10} \quad \frac{(j-i)}{10}\right].

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 21.65 (accepted within ±0.35)