uiz Space

January 2024 term · Large Language Models · BSDA5004

Large Language Models Quiz 1: 25 February 2024 (January 2024 term)

The IIT Madras BS Large Language Models (LLM) Quiz 1 paper sat on 25 Feb 2024, in the January 2024 term: 15 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.

Questions
15
Marks
50
Duration
120 min
Numerical
6
MCQ
5
MSQ
4

Updated

Official paper: IIT M DEGREE AN2 EXAM QDB2 25 Feb 2024 · No negative marking.

Question 1

+3 marksNumerical answer

Consider a vocabulary V=(A,T,C,G)\mathcal{V} = (A, T, C, G) and the corresponding embedding matrix E=[10011−111]E = \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ 1 & -1 \\ 1 & 1 \end{bmatrix}. For example, the 0−th0 - th row of EE is the embedding for 0−th0 - th token of V\mathcal{V} and so on. The following sequence X=(G,C,C,T,A,G)X = (G, C, C, T, A, G) is to be processed by the encoder layer of the transformer architecture by appropriately adding the positional information using the following encoding scheme

P(pos,2i)=sin(pos10(2i/dmodel))P(pos, 2i) = sin\left(\frac{pos}{10^{(2i/dmodel)}}\right)

P(pos,2i+1)=cos(pos10(2i/dmodel))P(pos, 2i+1) = cos\left(\frac{pos}{10^{(2i/dmodel)}}\right)

Assume the index for the position starts from zero. Add positional information to all the tokens in the sequence. Let the resultant sequence be denoted by H=E(X)+PH = E(X) + P, (HH will be used in the subsequent questions,please write it down).Here, E(X)E(X) denotes the embedding for each token in XX

Based on the above data, answer the given subquestions.

Show answer

Correct answer: -0.68 (accepted within ±0.05)

Question 2

+2 marksNumerical answer

Consider a vocabulary V=(A,T,C,G)\mathcal{V} = (A, T, C, G) and the corresponding embedding matrix E=[10011−111]E = \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ 1 & -1 \\ 1 & 1 \end{bmatrix}. For example, the 0−th0 - th row of EE is the embedding for 0−th0 - th token of V\mathcal{V} and so on. The following sequence X=(G,C,C,T,A,G)X = (G, C, C, T, A, G) is to be processed by the encoder layer of the transformer architecture by appropriately adding the positional information using the following encoding scheme

P(pos,2i)=sin(pos10(2i/dmodel))P(pos, 2i) = sin\left(\frac{pos}{10^{(2i/dmodel)}}\right)

P(pos,2i+1)=cos(pos10(2i/dmodel))P(pos, 2i+1) = cos\left(\frac{pos}{10^{(2i/dmodel)}}\right)

Assume the index for the position starts from zero. Add positional information to all the tokens in the sequence. Let the resultant sequence be denoted by H=E(X)+PH = E(X) + P, (HH will be used in the subsequent questions,please write it down).Here, E(X)E(X) denotes the embedding for each token in XX

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 0.165 (accepted within ±0.035)

Question 3

+3 marksNumerical answer

Consider a vocabulary V=(A,T,C,G)\mathcal{V} = (A, T, C, G) and the corresponding embedding matrix E=[10011−111]E = \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ 1 & -1 \\ 1 & 1 \end{bmatrix}. For example, the 0−th0 - th row of EE is the embedding for 0−th0 - th token of V\mathcal{V} and so on. The following sequence X=(G,C,C,T,A,G)X = (G, C, C, T, A, G) is to be processed by the encoder layer of the transformer architecture by appropriately adding the positional information using the following encoding scheme

P(pos,2i)=sin(pos10(2i/dmodel))P(pos, 2i) = sin\left(\frac{pos}{10^{(2i/dmodel)}}\right)

P(pos,2i+1)=cos(pos10(2i/dmodel))P(pos, 2i+1) = cos\left(\frac{pos}{10^{(2i/dmodel)}}\right)

Assume the index for the position starts from zero. Add positional information to all the tokens in the sequence. Let the resultant sequence be denoted by H=E(X)+PH = E(X) + P, (HH will be used in the subsequent questions,please write it down).Here, E(X)E(X) denotes the embedding for each token in XX

Based on the above data, answer the given subquestions.

The bottommost encoder layer of the transformer contains the following parameter matrices

WQ=[100−1],WK=[1010]WV=[0110]WO=[1111]W_Q = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}, \quad W_K = \begin{bmatrix} 1 & 0 \\ 1 & 0 \end{bmatrix} \quad W_V = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \quad W_O = \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}

given that the embeddings are row vectors, compute the attention score to produce the new representation for the token (TT) at the 3-rd position in the sequence XX.

Show answer

Correct answer: -0.0475 (accepted within ±0.0125)

Question 4

+2 marksOne correct option

Consider a vocabulary V=(A,T,C,G)\mathcal{V} = (A, T, C, G) and the corresponding embedding matrix E=[10011−111]E = \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ 1 & -1 \\ 1 & 1 \end{bmatrix}. For example, the 0−th0 - th row of EE is the embedding for 0−th0 - th token of V\mathcal{V} and so on. The following sequence X=(G,C,C,T,A,G)X = (G, C, C, T, A, G) is to be processed by the encoder layer of the transformer architecture by appropriately adding the positional information using the following encoding scheme

P(pos,2i)=sin(pos10(2i/dmodel))P(pos, 2i) = sin\left(\frac{pos}{10^{(2i/dmodel)}}\right)

P(pos,2i+1)=cos(pos10(2i/dmodel))P(pos, 2i+1) = cos\left(\frac{pos}{10^{(2i/dmodel)}}\right)

Assume the index for the position starts from zero. Add positional information to all the tokens in the sequence. Let the resultant sequence be denoted by H=E(X)+PH = E(X) + P, (HH will be used in the subsequent questions,please write it down).Here, E(X)E(X) denotes the embedding for each token in XX

Based on the above data, answer the given subquestions.

The bottommost encoder layer of the transformer contains the following parameter matrices

WQ=[100−1],WK=[1010]WV=[0110]WO=[1111]W_Q = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}, \quad W_K = \begin{bmatrix} 1 & 0 \\ 1 & 0 \end{bmatrix} \quad W_V = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \quad W_O = \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}

given that the embeddings are row vectors, compute the attention score to produce the new representation for the token (TT) at the 3-rd position in the sequence XX.

Which token in the sequence was given the highest score?

  1. A

    G

  2. B

    C

  3. C

    T

  4. D

    A

Show answer

Correct answer

  • A

    G

Question 5

+3 marksNumerical answer

Consider the following configuration for the Vannila transformer architecture with one encoder layer and one decoder layer.

  • Source and target vocabulary size =100= 100
  • maximum sequence length =32= 32
  • length of context window (TT) for both encoder and decoder =32= 32
  • number of heads nh=2n_h = 2
  • dff=4∗dmodeldff = 4 * dmodel
  • dq=dk=dv=dmodelnhdq = dk = dv = \frac{dmodel}{n_h}

Based on the above data, answer the given subquestions.

Suppose the number of learnable parameters in the source input embedding layer is 1600, how many parameters are there in the positional embedding layer of the source language? Assume the positional embeddings are learnable.

Show answer

Correct answer: 512

Question 6

+3 marksNumerical answer

Consider the following configuration for the Vannila transformer architecture with one encoder layer and one decoder layer.

  • Source and target vocabulary size =100= 100
  • maximum sequence length =32= 32
  • length of context window (TT) for both encoder and decoder =32= 32
  • number of heads nh=2n_h = 2
  • dff=4∗dmodeldff = 4 * dmodel
  • dq=dk=dv=dmodelnhdq = dk = dv = \frac{dmodel}{n_h}

Based on the above data, answer the given subquestions.

How many parameters are there in the multi-head attention layer of the encoder (exclude the parameters in the WO matrix used for linear transformation)?

Show answer

Correct answer: 768

Question 7

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

Correct answer

  • D

Question 8

+4 marksOne correct option

Suppose we run the pre-trained GPT model in an autoregressive fashion for generating a text sequence. Then, the statement that “ We do not need to add the positional embedding to the predicted tokens at every time step” is

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 9

+3 marksOne or more correct options

Suppose we have a dataset for machine translation tasks with thousands of samples. Suppose a team considers training the transformer model. The model could be trained in two approaches A  Autoregressive training
B  Teacher forcing
Choose the correct statements

Select all that apply.

  1. A

    Approach A helps the model to converge faster than approach B

  2. B

    Approach B helps the model converge faster than approach A

  3. C

    One can start the training with approach B first and then switch to approach A after some training steps

  4. D

    Once the training starts with approach B and then switching to approach A after some training steps can not be done

Show answer

Correct answers

  • B

    Approach B helps the model converge faster than approach A

  • C

    One can start the training with approach B first and then switch to approach A after some training steps

Question 10

+4 marksOne or more correct options

A team trained a Language model using the GPT architecture using a large corpus of text. The model configurations are given below

  • Vocabulary size =30000= 30000
  • dmodel=512dmodel = 512
  • length of context window T=1024T = 1024
  • dff=4∗dmodeldff = 4 * dmodel
  • dq=dk=dv=64dq = dk = dv = 64

They trained the model for millions of steps and stopped the training after the loss had decreased significantly. Then, they used the model to generate the text by giving the special starting token [BOS] as an input to the model. Select the length of the text sequence that the model could generate.

Select all that apply.

  1. A

    512

  2. B

    1024

  3. C

    1536

  4. D

    2048

Show answer

Correct answers

  • A

    512

  • B

    1024

  • C

    1536

  • D

    2048

Question 11

+4 marksOne or more correct options

Choose the correct statements

Select all that apply.

  1. A

    All the parameters of the GPT model are randomly initialized during pre- training

  2. B

    The model minimizes the CLM objective during fine-tuning to improve the performance

  3. C

    All parameters of the GPT model are randomly initialized during fine-tuning

  4. D

    In general, fine-tuning requires a dataset with labels

Show answer

Correct answers

  • A

    All the parameters of the GPT model are randomly initialized during pre- training

  • D

    In general, fine-tuning requires a dataset with labels

Question 12

+4 marksOne or more correct options

Select all that apply.

  1. A

    Top-k sampling

  2. B

    Beam search with the beam size K = 2

  3. C

    Top-p sampling

  4. D

    Exhaustive search

  5. E

    None of these

Show answer

Correct answers

  • B

    Beam search with the beam size K = 2

  • D

    Exhaustive search

Question 13

+4 marksOne correct option

Consider a GPT model used for Causal language modelling. We feed the input sentence “This is a cool idea” to the model by appending special staring [BOS] and ending [EOS] tokens ( that is, “[BOS] This is a cool idea [EOS]”). Assume the context length of the model is 7. The attention matrix computed in one of the attention layers is given below

1000000
0.50.500000
0.30.20.50000
0.10.10.80000
00.1500.60.2500
0.250.3500.20.10.10
0.10.10.10.10.10.40.1

Table 1: Attention score

Based on the above data, answer the given subquestions.

The attention score matrix given in Table 1 is appropriate for the causal language modelling task

  1. A

    True

  2. B

    False

  3. C

    Insufficient information

Show answer

Correct answer

  • A

    True

Question 14

+4 marksNumerical answer

Consider a GPT model used for Causal language modelling. We feed the input sentence “This is a cool idea” to the model by appending special staring [BOS] and ending [EOS] tokens ( that is, “[BOS] This is a cool idea [EOS]”). Assume the context length of the model is 7. The attention matrix computed in one of the attention layers is given below

1000000
0.50.500000
0.30.20.50000
0.10.10.80000
00.1500.60.2500
0.250.3500.20.10.10
0.10.10.10.10.10.40.1

Table 1: Attention score

Based on the above data, answer the given subquestions.

Assume the time step starts from t = 0 and ends at t = 6. Suppose the model is at time step t = 4, what is the attention value assigned for the word “is”?

Show answer

Correct answer: 0

Question 15

+3 marksOne correct option

The statement that “the Next Sentence Prediction (NSP) task requires the BERT model to run autoregressively given the first sentence( or segment)” is

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE