uiz Space

September 2024 term · Large Language Models · BSDA5004

Large Language Models Quiz 1: 27 October 2024 (September 2024 term)

The IIT Madras BS Large Language Models (LLM) Quiz 1 paper sat on 27 Oct 2024, in the September 2024 term: 19 questions for 40 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
19
Marks
40
Duration
120 min
MCQ
5
Numerical
14

Updated

Official paper: IIT M DEGREE AN EXAM QDB2 27 Oct 2024 · No negative marking.

Question 1

+2 marksOne correct option

Teacher forcing for training an transformer model is:

  1. A

    mandatory.

  2. B

    optional.

Show answer

Correct answer

  • B

    optional.

Question 2

+2 marksOne correct option

Choose the correct statements regarding transformer architecture:

  1. A

    Residual connections are practically optional in a transformer model with 10 encoder layers and 10 decoder layers.

  2. B

    Having multiple heads helps in capturing different relationships between input tokens.

  3. C

    One hot encoding is a good choice for position encoding.

  4. D

    Batch normalization can be used instead of layer normalization.

  5. E

    None of these.

Show answer

Correct answer

  • B

    Having multiple heads helps in capturing different relationships between input tokens.

Question 3

+2 marksNumerical answer

Based on the above data, answer the given subquestions.

Assume the model has two layers (N = 2). Calculate the total number of parameters in the model (excluding the embedding layer and output layer). Moreover, no bias was added to the neuron in the FFNN layers.

Show answer

Correct answer: 230656

Question 4

+2 marksNumerical answer

Based on the above data, answer the given subquestions.

How many parameters does the output layer have?

Show answer

Correct answer: 48000

Question 5

+2 marksNumerical answer

Based on the above data, answer the given subquestions.

How many parameters does the embedding layer have?

Show answer

Correct answer: 32000

Question 6

+2 marksNumerical answer

Based on the above data, answer the given subquestions.

At time step t = 1, the prediction probability for the words “Naan”, “transformer” and “padaththai” are 0.55,0.15 and 0.2, respectively. What is the probability for the word “rasithen”? If you think, the given information is insufficient enter -1

Show answer

Correct answer: -1

Question 7

+2 marksNumerical answer

Consider following input matrix to a single neural network layer:

X=[1234711−35−2]X = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 7 & 11 \\ -3 & 5 & -2 \end{bmatrix}

It has 3 samples with 3 features each i.e. batch size is 3. Each column represents a sample. Left most column represents the first sample and topmost row represents the first feature vector.

Note: assume γ=1\gamma = 1, β=0\beta = 0 and ϵ=10−6\epsilon = 10^{-6} for both batch and layer normalization, if not mentioned explicitly. Use standard scaling.

Based on the above data, answer the given subquestions.

Say matrix F is computed by applying batch normalization on X, what will be sum of every element in first/topmost row of F?

Show answer

Correct answer: 0.005 (accepted within ±0.005)

Question 8

+2 marksNumerical answer

Consider following input matrix to a single neural network layer:

X=[1234711−35−2]X = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 7 & 11 \\ -3 & 5 & -2 \end{bmatrix}

It has 3 samples with 3 features each i.e. batch size is 3. Each column represents a sample. Left most column represents the first sample and topmost row represents the first feature vector.

Note: assume γ=1\gamma = 1, β=0\beta = 0 and ϵ=10−6\epsilon = 10^{-6} for both batch and layer normalization, if not mentioned explicitly. Use standard scaling.

Based on the above data, answer the given subquestions.

Say matrix F is computed by applying layer normalization on X, what will be sum of every element in first/leftmost column of F?

Show answer

Correct answer: 0.005 (accepted within ±0.005)

Question 9

+2 marksNumerical answer

Consider following input matrix to a single neural network layer:

X=[1234711−35−2]X = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 7 & 11 \\ -3 & 5 & -2 \end{bmatrix}

It has 3 samples with 3 features each i.e. batch size is 3. Each column represents a sample. Left most column represents the first sample and topmost row represents the first feature vector.

Note: assume γ=1\gamma = 1, β=0\beta = 0 and ϵ=10−6\epsilon = 10^{-6} for both batch and layer normalization, if not mentioned explicitly. Use standard scaling.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 9 (accepted within ±0.05)

Question 10

+2 marksNumerical answer

Consider following input matrix to a single neural network layer:

X=[1234711−35−2]X = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 7 & 11 \\ -3 & 5 & -2 \end{bmatrix}

It has 3 samples with 3 features each i.e. batch size is 3. Each column represents a sample. Left most column represents the first sample and topmost row represents the first feature vector.

Note: assume γ=1\gamma = 1, β=0\beta = 0 and ϵ=10−6\epsilon = 10^{-6} for both batch and layer normalization, if not mentioned explicitly. Use standard scaling.

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 12.5 (accepted within ±0.05)

Question 11

+1 markNumerical answer

Consider a vocabulary V\mathcal{V},

V=\mathcal{V} =([start], breaking, ground, a, is, seismology, study, experience, earth quake,[end]).

Assume that we have a pre-trained GPT model for text generation and the first input token to the model is always the special token [start]. The prediction probabilities outputted by the model are given below.

Y^=[0.040.010.140.070.090.410.080.050.080.010.100.030.060.160.430.010.060.090.010.040.060.080.280.290.030.080.040.080.040.040.110.030.480.020.010.070.060.140.070.010.090.290.040.010.040.030.250.050.150.060.140.220.130.080.010.030.060.230.080.03]\hat{Y} = \begin{bmatrix} 0.04 & 0.01 & 0.14 & 0.07 & 0.09 & 0.41 & 0.08 & 0.05 & 0.08 & 0.01 \\ 0.10 & 0.03 & 0.06 & 0.16 & 0.43 & 0.01 & 0.06 & 0.09 & 0.01 & 0.04 \\ 0.06 & 0.08 & 0.28 & 0.29 & 0.03 & 0.08 & 0.04 & 0.08 & 0.04 & 0.04 \\ 0.11 & 0.03 & 0.48 & 0.02 & 0.01 & 0.07 & 0.06 & 0.14 & 0.07 & 0.01 \\ 0.09 & 0.29 & 0.04 & 0.01 & 0.04 & 0.03 & 0.25 & 0.05 & 0.15 & 0.06 \\ 0.14 & 0.22 & 0.13 & 0.08 & 0.01 & 0.03 & 0.06 & 0.23 & 0.08 & 0.03 \end{bmatrix}

The columns of the matrix are in the same order as the words listed in the vocabulary set above

The zeroth row of the matrix is the output probability distribution by the model given the special [Start] token as input. Following the Greedy Search decoding strategy, the subsequent rows give the conditional probability distribution conditioned over the previous tokens. If you think the given information is insufficient for any sub-questions, then enter -1 as your answer

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 0.41

Question 12

+2 marksNumerical answer

Consider a vocabulary V\mathcal{V},

V=\mathcal{V} =([start], breaking, ground, a, is, seismology, study, experience, earth quake,[end]).

Assume that we have a pre-trained GPT model for text generation and the first input token to the model is always the special token [start]. The prediction probabilities outputted by the model are given below.

Y^=[0.040.010.140.070.090.410.080.050.080.010.100.030.060.160.430.010.060.090.010.040.060.080.280.290.030.080.040.080.040.040.110.030.480.020.010.070.060.140.070.010.090.290.040.010.040.030.250.050.150.060.140.220.130.080.010.030.060.230.080.03]\hat{Y} = \begin{bmatrix} 0.04 & 0.01 & 0.14 & 0.07 & 0.09 & 0.41 & 0.08 & 0.05 & 0.08 & 0.01 \\ 0.10 & 0.03 & 0.06 & 0.16 & 0.43 & 0.01 & 0.06 & 0.09 & 0.01 & 0.04 \\ 0.06 & 0.08 & 0.28 & 0.29 & 0.03 & 0.08 & 0.04 & 0.08 & 0.04 & 0.04 \\ 0.11 & 0.03 & 0.48 & 0.02 & 0.01 & 0.07 & 0.06 & 0.14 & 0.07 & 0.01 \\ 0.09 & 0.29 & 0.04 & 0.01 & 0.04 & 0.03 & 0.25 & 0.05 & 0.15 & 0.06 \\ 0.14 & 0.22 & 0.13 & 0.08 & 0.01 & 0.03 & 0.06 & 0.23 & 0.08 & 0.03 \end{bmatrix}

The columns of the matrix are in the same order as the words listed in the vocabulary set above

The zeroth row of the matrix is the output probability distribution by the model given the special [Start] token as input. Following the Greedy Search decoding strategy, the subsequent rows give the conditional probability distribution conditioned over the previous tokens. If you think the given information is insufficient for any sub-questions, then enter -1 as your answer

Based on the above data, answer the given subquestions.

Show answer

Correct answer: 1.6

Question 13

+2 marksNumerical answer

Consider a vocabulary V\mathcal{V},

V=\mathcal{V} =([start], breaking, ground, a, is, seismology, study, experience, earth quake,[end]).

Assume that we have a pre-trained GPT model for text generation and the first input token to the model is always the special token [start]. The prediction probabilities outputted by the model are given below.

Y^=[0.040.010.140.070.090.410.080.050.080.010.100.030.060.160.430.010.060.090.010.040.060.080.280.290.030.080.040.080.040.040.110.030.480.020.010.070.060.140.070.010.090.290.040.010.040.030.250.050.150.060.140.220.130.080.010.030.060.230.080.03]\hat{Y} = \begin{bmatrix} 0.04 & 0.01 & 0.14 & 0.07 & 0.09 & 0.41 & 0.08 & 0.05 & 0.08 & 0.01 \\ 0.10 & 0.03 & 0.06 & 0.16 & 0.43 & 0.01 & 0.06 & 0.09 & 0.01 & 0.04 \\ 0.06 & 0.08 & 0.28 & 0.29 & 0.03 & 0.08 & 0.04 & 0.08 & 0.04 & 0.04 \\ 0.11 & 0.03 & 0.48 & 0.02 & 0.01 & 0.07 & 0.06 & 0.14 & 0.07 & 0.01 \\ 0.09 & 0.29 & 0.04 & 0.01 & 0.04 & 0.03 & 0.25 & 0.05 & 0.15 & 0.06 \\ 0.14 & 0.22 & 0.13 & 0.08 & 0.01 & 0.03 & 0.06 & 0.23 & 0.08 & 0.03 \end{bmatrix}

The columns of the matrix are in the same order as the words listed in the vocabulary set above

The zeroth row of the matrix is the output probability distribution by the model given the special [Start] token as input. Following the Greedy Search decoding strategy, the subsequent rows give the conditional probability distribution conditioned over the previous tokens. If you think the given information is insufficient for any sub-questions, then enter -1 as your answer

Based on the above data, answer the given subquestions.

Show answer

Correct answer: -1

Question 14

+2 marksNumerical answer

Consider a vocabulary V\mathcal{V},

V=\mathcal{V} =([start], breaking, ground, a, is, seismology, study, experience, earth quake,[end]).

Assume that we have a pre-trained GPT model for text generation and the first input token to the model is always the special token [start]. The prediction probabilities outputted by the model are given below.

Y^=[0.040.010.140.070.090.410.080.050.080.010.100.030.060.160.430.010.060.090.010.040.060.080.280.290.030.080.040.080.040.040.110.030.480.020.010.070.060.140.070.010.090.290.040.010.040.030.250.050.150.060.140.220.130.080.010.030.060.230.080.03]\hat{Y} = \begin{bmatrix} 0.04 & 0.01 & 0.14 & 0.07 & 0.09 & 0.41 & 0.08 & 0.05 & 0.08 & 0.01 \\ 0.10 & 0.03 & 0.06 & 0.16 & 0.43 & 0.01 & 0.06 & 0.09 & 0.01 & 0.04 \\ 0.06 & 0.08 & 0.28 & 0.29 & 0.03 & 0.08 & 0.04 & 0.08 & 0.04 & 0.04 \\ 0.11 & 0.03 & 0.48 & 0.02 & 0.01 & 0.07 & 0.06 & 0.14 & 0.07 & 0.01 \\ 0.09 & 0.29 & 0.04 & 0.01 & 0.04 & 0.03 & 0.25 & 0.05 & 0.15 & 0.06 \\ 0.14 & 0.22 & 0.13 & 0.08 & 0.01 & 0.03 & 0.06 & 0.23 & 0.08 & 0.03 \end{bmatrix}

The columns of the matrix are in the same order as the words listed in the vocabulary set above

The zeroth row of the matrix is the output probability distribution by the model given the special [Start] token as input. Following the Greedy Search decoding strategy, the subsequent rows give the conditional probability distribution conditioned over the previous tokens. If you think the given information is insufficient for any sub-questions, then enter -1 as your answer

Based on the above data, answer the given subquestions.

Suppose we use Top−k-k sampling, with k=3k = 3, what is the probability of the predicted word equal to “Seismology” given the “[Start]“ token as the initial input P(y1=Seismology∣y0=[Start])P(y_1 = Seismology|y_0 = [Start])?

Show answer

Correct answer: -1

Question 15

+2 marksOne correct option

Rajesh has created a GPT-like transformer model. However he doesn't have access to large compute infrastructure, so he has configured the original architecture in the following manner:

  1. He has taken a vocabulary of size 1000 words/tokens.
  2. Sequence length is 64.
  3. Embedding dimension and dmodeld_{model} is 128.
  4. There are only 4 transformer blocks (layers).
  5. Each transformer block (layer) has only 4 attention heads.
  6. FFN hidden layer size is 256.

Based on the above data, answer the given subquestions.

What will be the shape of positional embedding?

  1. A

    64 × 128

  2. B

    64 × 4

  3. C

    12 × 128

  4. D

    512 × 768

  5. E

    None of these.

Show answer

Correct answer

  • A

    64 × 128

Question 16

+2 marksOne correct option

Rajesh has created a GPT-like transformer model. However he doesn't have access to large compute infrastructure, so he has configured the original architecture in the following manner:

  1. He has taken a vocabulary of size 1000 words/tokens.
  2. Sequence length is 64.
  3. Embedding dimension and dmodeld_{model} is 128.
  4. There are only 4 transformer blocks (layers).
  5. Each transformer block (layer) has only 4 attention heads.
  6. FFN hidden layer size is 256.

Based on the above data, answer the given subquestions.

  1. A

    32 × 32

  2. B

    64 × 32

  3. C

    128 × 16

  4. D

    128 × 32

  5. E

    8 × 32

  6. F

    None of these.

Show answer

Correct answer

  • D

    128 × 32

Question 17

+2 marksOne correct option

Rajesh has created a GPT-like transformer model. However he doesn't have access to large compute infrastructure, so he has configured the original architecture in the following manner:

  1. He has taken a vocabulary of size 1000 words/tokens.
  2. Sequence length is 64.
  3. Embedding dimension and dmodeld_{model} is 128.
  4. There are only 4 transformer blocks (layers).
  5. Each transformer block (layer) has only 4 attention heads.
  6. FFN hidden layer size is 256.

Based on the above data, answer the given subquestions.

  1. A

    16 × 16

  2. B

    32 × 32

  3. C

    64 × 64

  4. D

    128 × 128

  5. E

    None of these.

Show answer

Correct answer

  • C

    64 × 64

Question 18

+4 marksNumerical answer

The input embeddings for the words “learning”, “brings” and “joy” are h1=[0.5,0.25,1]h_1 = [0.5, 0.25, 1], h2=[0.1,0.25,0]h_2 = [0.1, 0.25, 0], and h3=[0.1,0.1,0.9]h_3 = [0.1, 0.1, 0.9], respectively. Note that the embeddings are row vectors. The projection matrices are as follows

WQ=[11−1101]WK=[011001]WV=[00−1−111]W_Q = \begin{bmatrix} 1 & 1 \\ -1 & 1 \\ 0 & 1 \end{bmatrix} \quad W_K = \begin{bmatrix} 0 & 1 \\ 1 & 0 \\ 0 & 1 \end{bmatrix} \quad W_V = \begin{bmatrix} 0 & 0 \\ -1 & -1 \\ 1 & 1 \end{bmatrix}

The following quantities are computed as

Q=HWQK=HWKV=HWVQ = HW_Q \quad K = HW_K \quad V = HW_V

Let eje_j denote the unnormalized attention score, aja_j denote the normalized attention score (ignore the scaling by dk\sqrt{d_k}) and zjz_j denote the linear combination of the value vectors for the j−thj - th word.

Suppose the gradient vector ∂L∂z3=[1,2]\frac{\partial L}{\partial z_3} = [1, 2], then what is the gradient vector ∂L∂e3\frac{\partial L}{\partial e_3}? Enter the sum of gradients.

Show answer

Correct answer: 0

Question 19

+3 marksNumerical answer

Consider the embedding vector for a word, x=[0.1,0.2,−0.3,0.4]x = [0.1, 0.2, -0.3, 0.4]. Suppose the word is at position 2 in the given sentence. Add the corresponding position embedding pp to the word embedding to get hh, i.e. the sum of the elements in h=x+ph = x + p. Use the fixed-sinusoidal position embedding vector calculated using the formula given below

PE(pos,2i)=sin(pos100002i/dmodel)PE(pos, 2i) = sin\left(\frac{pos}{10000^{2i/dmodel}}\right)

PE(pos,2i+1)=cos(pos100002i/dmodel)PE(pos, 2i+1) = cos\left(\frac{pos}{10000^{2i/dmodel}}\right)

What is h[0]+h[1]h[0] + h[1] i.e. sum of first two elements of hh?

Show answer

Correct answer: 0.8 (accepted within ±0.05)