1. Home
  2. Explore
  3. Computer Science
  4. Transformer Architecture and Attention

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Transformer Architecture and Attention

  • 61Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Locality and Context

Why can a shallow convolutional network struggle to judge a relationship between two distant image regions?

61 questions

  1. 1

    Why can a shallow convolutional network struggle to judge a relationship between two distant image regions?

    1. A

      Its local filters may not allow any output unit to depend jointly on both regions

    2. B

      Its outputs cannot combine information from different channels

    3. C

      Its pooling layers remove all information about object identity

    4. D

      Its shared filters prevent it from representing any visual features

    Correct answer
    A

    Its local filters may not allow any output unit to depend jointly on both regions

    Explanation

    A convolutional network builds dependencies through local receptive fields. In a shallow network, the receptive field may not span both distant regions, so no output unit can depend on their joint configuration.

  2. 2

    What inductive bias is central to convolutional networks?

    1. A

      A preference for processing nearby inputs together

    2. B

      A preference for connecting every input directly to every output

    3. C

      A preference for using input order only after all processing

    4. D

      A preference for treating all input positions independently

    Correct answer
    A

    A preference for processing nearby inputs together

    Explanation

    Convolutional networks use local filters, encoding a strong locality bias. This is useful when nearby parts of a signal are especially related, but can be inefficient for distant relationships.

  3. 3

    In a length-three convolutional filter, how does the receptive field typically change when another convolutional layer is added?

    1. A

      It stays fixed because convolution weights are shared

    2. B

      It immediately includes every input in the signal

    3. C

      It expands gradually to include additional nearby inputs

    4. D

      It becomes smaller because each layer reuses the same filter

    Correct answer
    C

    It expands gradually to include additional nearby inputs

    Explanation

    Each additional local convolutional layer expands the receptive field gradually. This can eventually connect distant inputs, but may require substantial depth.

  4. 4

    Why might attention be preferable to simply making a convolutional network much deeper for a task involving distant relationships?

    1. A

      Attention makes local patterns impossible to represent

    2. B

      Attention removes the need to represent inputs with numerical values

    3. C

      Attention can connect relevant distant inputs directly rather than relying on gradual receptive-field growth

    4. D

      Attention guarantees that every input is relevant to every task

    Correct answer
    C

    Attention can connect relevant distant inputs directly rather than relying on gradual receptive-field growth

    Explanation

    Attention allows information to be combined across distant locations in a single operation, rather than depending on local information spreading gradually through many convolutional layers.

  5. 5

    How does a fully connected layer differ from a convolutional layer in how it initially combines information?

    1. A

      A fully connected layer uses shared local filters, while a convolutional layer uses separate global weights

    2. B

      A fully connected layer uses attention scores, while a convolutional layer uses positional encodings

    3. C

      A fully connected layer operates only on vectors, while a convolutional layer operates only on images

    4. D

      A fully connected layer can combine information globally, while a convolutional layer uses local connections

    Correct answer
    D

    A fully connected layer can combine information globally, while a convolutional layer uses local connections

    Explanation

    Every output of a fully connected layer can receive information from every input. A convolutional layer instead connects each output to a local patch, using shared filters.

  6. 6

    What is the trade-off described between fully connected global processing and attention?

    1. A

      Fully connected processing uses dense connections, whereas attention aims for input-dependent, sparse global focus

    2. B

      Fully connected processing is local, whereas attention cannot connect distant inputs

    3. C

      Fully connected processing has no parameters, whereas attention learns a separate parameter for every input pair

    4. D

      Fully connected processing is input-dependent, whereas attention uses fixed connections

    Correct answer
    A

    Fully connected processing uses dense connections, whereas attention aims for input-dependent, sparse global focus

    Explanation

    A fully connected mapping can involve a number of parameters that grows quadratically with input size. Attention also enables global interactions, but determines which inputs matter from the data rather than using all connections as unrestricted free parameters.

  7. 7

    Which situation best illustrates when a strong locality bias is useful?

    1. A

      Estimating a property of a room from observations within that room

    2. B

      Comparing two objects located at opposite ends of a very large image

    3. C

      Matching a signal to another signal with no nearby structure

    4. D

      Finding a word in a sentence that depends on a distant earlier phrase

    Correct answer
    A

    Estimating a property of a room from observations within that room

    Explanation

    Locality is useful when relevant information is concentrated nearby, such as understanding what is happening in a room without needing information from a distant, unrelated location.

  8. 8

    In the lecture's terminology, what is a token?

    1. A

      A learned attention score between two input locations

    2. B

      A single scalar neuron that must be processed independently

    3. C

      A vector-valued unit that bundles information for processing

    4. D

      A fixed vocabulary item that can never contain multiple features

    Correct answer
    C

    A vector-valued unit that bundles information for processing

    Explanation

    For the lecture, a token is a vector of neurons: an encapsulated bundle of information that serves as a basic unit of processing.

  9. 9

    How does the lecture's use of “token” differ from the common natural-language-processing use described there?

    1. A

      The lecture means a word in a vocabulary, while NLP means an image patch vector

    2. B

      The lecture means a scalar neuron, while NLP means a sequence of vectors

    3. C

      The lecture means a vector-valued information unit, while NLP often means a discrete vocabulary unit

    4. D

      The lecture means an attention matrix, while NLP means a positional encoding

    Correct answer
    C

    The lecture means a vector-valued information unit, while NLP often means a discrete vocabulary unit

    Explanation

    The lecture uses token for a vector-valued computational unit. In common NLP usage, a token often means a discrete vocabulary unit, such as a character, word, or subword unit.

  10. 10

    How are image inputs commonly converted into tokens in the described vision approach?

    1. A

      Assign each patch a scalar value and discard its color measurements

    2. B

      Convert every pixel directly into a separate sentence-level vocabulary item

    3. C

      Apply a global attention operation before dividing the image into regions

    4. D

      Divide the image into patches, flatten each patch, and project it to a fixed-dimensional vector

    Correct answer
    D

    Divide the image into patches, flatten each patch, and project it to a fixed-dimensional vector

    Explanation

    A standard approach divides an image into patches, flattens each patch's pixel values into a vector, and applies a linear projection to obtain a token of the desired dimension.

  11. 11

    What is the typical relationship between token sizes in a standard transformer setup described in the lecture?

    1. A

      Tokens generally have the same vector dimensionality

    2. B

      Token dimensionality changes at every position in the input

    3. C

      Only the first token is represented as a vector

    4. D

      Each token must have a different vector dimensionality

    Correct answer
    A

    Tokens generally have the same vector dimensionality

    Explanation

    The standard setup uses tokens with the same dimensionality, so they can be represented as rows of one matrix. Variable-sized tokens are possible in principle but create additional practical challenges.

  12. 12

    Do standard image-token patches in the lecture's described approach usually overlap?

    1. A

      No; standard image tokenization uses one patch for the entire image

    2. B

      Yes; every patch must overlap every neighboring patch

    3. C

      Yes; patches overlap only when their tokens have different dimensions

    4. D

      No; the standard approach generally uses non-overlapping patches

    Correct answer
    D

    No; the standard approach generally uses non-overlapping patches

    Explanation

    The lecture describes non-overlapping image patches as the standard approach, while noting that overlapping patches could also be explored.

  13. 13

    Which statement best captures the general strategy for tokenizing different domains?

    1. A

      Use the same fixed pixel-based partition for every kind of input

    2. B

      Let the transformer discover all input units without any domain-specific preparation

    3. C

      Convert every input into one scalar before applying the transformer

    4. D

      Choose chunks that make sense as units for the domain, then represent each chunk as a token

    Correct answer
    D

    Choose chunks that make sense as units for the domain, then represent each chunk as a token

    Explanation

    Tokenization is the main step where domain knowledge is used: the input is divided into meaningful chunks, which are then represented as tokens for generic transformer processing.

  14. 14

    Which tokenization example is associated with language in the lecture?

    1. A

      Converting each sentence into one color measurement

    2. B

      Representing text as subword units such as byte pairs

    3. C

      Dividing every sentence into non-overlapping image patches

    4. D

      Encoding each word only as a graph Laplacian eigenvector

    Correct answer
    B

    Representing text as subword units such as byte pairs

    Explanation

    The lecture describes byte pairs as a common way to divide language into subword units, with examples such as units corresponding to “TH” or “ING.”

  15. 15

    How does the lecture suggest representing an array of tokens mathematically?

    1. A

      As a graph in which every node must have a different vector size

    2. B

      As a matrix with one feature per row and one input example per column only

    3. C

      As a single scalar with one entry for the whole input

    4. D

      As a matrix with one token per row and token features in the columns

    Correct answer
    D

    As a matrix with one token per row and token features in the columns

    Explanation

    The lecture stacks token vectors as rows of a matrix, with the number of tokens in the rows and the shared feature dimensionality in the columns.

  16. 16

    Why are transformers described as relatively agnostic to input domain?

    1. A

      They do not require any representation of the input data

    2. B

      They use exactly the same tokenizer for images, language, and every other signal

    3. C

      Once domain-specific data is converted into tokens, much of the subsequent processing can use a generic framework

    4. D

      Their attention mechanism works only on data with spatial locality

    Correct answer
    C

    Once domain-specific data is converted into tokens, much of the subsequent processing can use a generic framework

    Explanation

    The domain expert provides a suitable tokenization, after which the transformer can apply a broadly generic token-processing recipe across different domains.

  17. 17

    What is the principal practical challenge mentioned for variable-size tokens?

    1. A

      They make it impossible to represent language or images

    2. B

      They can complicate bookkeeping and mapping computations efficiently onto hardware

    3. C

      They force every attention score to be zero

    4. D

      They prevent the use of any learned parameters

    Correct answer
    B

    They can complicate bookkeeping and mapping computations efficiently onto hardware

    Explanation

    Variable-size tokens may be interesting, but they complicate bookkeeping and may be difficult to map efficiently onto hardware designed for uniform computations.

  18. 18

    What does a linear combination of tokens do in the described token-based network?

    1. A

      It applies a separate scalar nonlinearity to every feature and removes the vectors

    2. B

      It multiplies every feature by a different weight for every other feature

    3. C

      It forms a weighted sum of token vectors using a weight for each token

    4. D

      It changes token order without combining their information

    Correct answer
    C

    It forms a weighted sum of token vectors using a weight for each token

    Explanation

    A token-level linear combination weights each token vector and sums the resulting vectors. In matrix notation, it can be expressed as a weight vector multiplied by the token matrix.

  19. 19

    Why is a linear combination of token vectors less expressive than a general linear combination of all their scalar features?

    1. A

      It has no learnable weights at all

    2. B

      It uses one weight per token rather than an independent weight for every scalar feature

    3. C

      It forces all input tokens to have different dimensions

    4. D

      It replaces every feature with a fixed nonlinear function

    Correct answer
    B

    It uses one weight per token rather than an independent weight for every scalar feature

    Explanation

    When a whole vector is treated as one token, a single token weight applies across its features. A general neuron-level linear combination could assign independent weights to all scalar features.

  20. 20

    What is a token-wise nonlinearity?

    1. A

      A different attention matrix applied to every feature of one token

    2. B

      The same nonlinear function applied independently to each token

    3. C

      A transformation that changes token positions but not token values

    4. D

      A nonlinear function that combines all tokens into a single scalar

    Correct answer
    B

    The same nonlinear function applied independently to each token

    Explanation

    A token-wise nonlinearity applies the same function to each token independently. In transformers, that function is typically an MLP.

  21. 21

    How is the token-wise MLP related to convolution, as described in the lecture?

    1. A

      It is equivalent to a length-three filter that cannot access token features

    2. B

      It is a convolution that must shift tokens into a new order

    3. C

      It is equivalent to a large convolution connecting every token to every other token

    4. D

      It resembles a one-by-one convolution applied independently across the token sequence

    Correct answer
    D

    It resembles a one-by-one convolution applied independently across the token sequence

    Explanation

    Applying the same MLP independently to each token is analogous to a one-by-one convolution across a sequence: the same transformation is used at each position without mixing positions.

  22. 22

    Which pair of operations forms the basic repeated motif of the token network described in the lecture?

    1. A

      A causal mask followed by an image tokenizer

    2. B

      A token-level linear combination followed by a token-wise nonlinearity

    3. C

      A pooling operation followed by a graph search

    4. D

      A positional encoding followed by a vocabulary lookup

    Correct answer
    B

    A token-level linear combination followed by a token-wise nonlinearity

    Explanation

    Like an MLP, a token network alternates a linear-combination operation and a nonlinearity, but its basic units are vectors rather than scalar neurons.

  23. 23

    What makes a transformer resemble a graph network in the lecture's comparison?

    1. A

      Both process vector-valued units through aggregation and update-like operations

    2. B

      Both use only scalar-valued nodes and prohibit global interactions

    3. C

      Both are necessarily convolutional and share weights across depth

    4. D

      Both require a fixed natural-language vocabulary as their input

    Correct answer
    A

    Both process vector-valued units through aggregation and update-like operations

    Explanation

    Both can be viewed as processing vector-valued units through aggregation and update operations. The transformer differs in how its connections are determined.

  24. 24

    What determines the aggregation connections in a graph neural network, in contrast with a standard transformer?

    1. A

      A shared convolution filter determines the graph's adjacency

    2. B

      A learned vocabulary determines which nodes may exchange information

    3. C

      The graph's connectivity structure determines which nodes aggregate information

    4. D

      A fixed positional encoding connects every pair of nodes

    Correct answer
    C

    The graph's connectivity structure determines which nodes aggregate information

    Explanation

    In a graph network, the graph's adjacency structure specifies which nodes contribute to an aggregation. A standard transformer is described as using a fully connected graph of token interactions.

  25. 25

    Which statement about weight sharing across depth is supported by the lecture?

    1. A

      Neither architecture can choose whether to share weights across depth

    2. B

      Standard transformers must share all weights across depth, while graph networks cannot

    3. C

      Graph networks often share weights across depth, while standard transformers typically use different weights across layers

    4. D

      Both architectures always use a single shared parameter set across every layer

    Correct answer
    C

    Graph networks often share weights across depth, while standard transformers typically use different weights across layers

    Explanation

    The lecture describes depth-wise weight sharing as common in graph networks but not typical in standard transformers, while noting that either design is a choice.

  26. 26

    In query-key-value attention, what does the query represent conceptually?

    1. A

      A fixed position assigned to each input token

    2. B

      A representation of what information the current token is seeking

    3. C

      A normalized sum of all output token vectors

    4. D

      A representation of the information a token will return after a match

    Correct answer
    B

    A representation of what information the current token is seeking

    Explanation

    The query encodes what a token is looking for. It is compared with keys from tokens that may contain relevant information.

  27. 27

    What role does a key play in query-key-value attention?

    1. A

      It applies a nonlinear function independently to every feature

    2. B

      It specifies the token's fixed location in the input

    3. C

      It represents information against which a query can be matched

    4. D

      It stores the final weighted sum returned by attention

    Correct answer
    C

    It represents information against which a query can be matched

    Explanation

    A key represents a token's content in a form that can be compared with a query to assess relevance.

  28. 28

    What role does a value play in query-key-value attention?

    1. A

      It determines the position of the token in the sequence

    2. B

      It carries the token information that is combined to form the output

    3. C

      It normalizes the dot products before they are computed

    4. D

      It decides which query vector is used for every other token

    Correct answer
    B

    It carries the token information that is combined to form the output

    Explanation

    Values are the information retrieved from tokens. Attention scores determine the weights used to combine these value vectors.

  29. 29

    How are queries, keys, and values typically produced from token vectors in the described attention layer?

    1. A

      By sorting tokens according to their position and copying their indices

    2. B

      By using the attention scores as the only learned parameters

    3. C

      By applying one fixed nonlinear function that produces identical vectors

    4. D

      By applying separate learned linear projections to the token vectors

    Correct answer
    D

    By applying separate learned linear projections to the token vectors

    Explanation

    The standard mechanism uses separate learnable projection matrices to map token vectors into query, key, and value vectors.

  30. 30

    What does the dot product between a query and a key indicate?

    1. A

      How relevant or similar the key is to the query

    2. B

      How far apart the two tokens are in the input sequence

    3. C

      How many features the value vector contains

    4. D

      How much the token's positional encoding should be scaled

    Correct answer
    A

    How relevant or similar the key is to the query

    Explanation

    The query-key dot product is used as a similarity or relevance score, determining how strongly a token should attend to another token.

  31. 31

    What does the softmax operation do to attention scores before they weight the values?

    1. A

      It converts every score into an independent learned parameter

    2. B

      It changes the scores into token position indices

    3. C

      It removes all scores except the largest one in every case

    4. D

      It converts the scores into normalized weights that sum to one

    Correct answer
    D

    It converts the scores into normalized weights that sum to one

    Explanation

    Softmax normalizes the score vector into attention weights that sum to one, which are then used to form a weighted combination of values.

  32. 32

    What is the result of applying attention weights to the value vectors?

    1. A

      A new set of query vectors that is independent of the input

    2. B

      A convolutional filter shared across all image patches

    3. C

      A positional encoding that identifies the order of all tokens

    4. D

      A weighted combination of value vectors that forms the output representation

    Correct answer
    D

    A weighted combination of value vectors that forms the output representation

    Explanation

    The attention weights specify how much each value contributes, and their weighted sum produces the attention output.

  33. 33

    In the animal-counting example, why can attention help produce the count?

    1. A

      It converts every image patch into a separate vocabulary word

    2. B

      It uses a fixed convolution filter that counts all pixels equally

    3. C

      It assigns a different positional encoding to each animal species

    4. D

      It can select animal-related patches and combine their count-relevant values

    Correct answer
    D

    It can select animal-related patches and combine their count-relevant values

    Explanation

    Attention can assign weight to patches containing animals and little or no weight to irrelevant patches. Combining count-related values from selected patches can yield a count representation.

  34. 34

    In the impala-color example, what information would the selected value vectors need to carry?

    1. A

      Color information from the patches that attention selects as relevant

    2. B

      Only the similarity scores between the query and the keys

    3. C

      The position of every word in a sentence describing the impala

    4. D

      The number of image pixels in all unrelated patches

    Correct answer
    A

    Color information from the patches that attention selects as relevant

    Explanation

    To answer a color question, the selected value vectors need to carry relevant color information. Attention identifies which patches contribute to the answer.

  35. 35

    What distinguishes self-attention from attention using an external question token?

    1. A

      In self-attention, values come from an unrelated external dataset

    2. B

      In self-attention, queries are produced from the tokens in the signal being processed

    3. C

      In self-attention, keys are fixed and cannot depend on the input

    4. D

      In self-attention, tokens are processed without computing relevance scores

    Correct answer
    B

    In self-attention, queries are produced from the tokens in the signal being processed

    Explanation

    Self-attention lets the tokens in a sequence generate queries that interact with keys from that same sequence, rather than requiring an external question.

  36. 36

    For a sequence of nnn tokens, what shape does the matrix of pairwise self-attention scores have?

    1. A

      A ddd by ddd matrix with one score for each token position

    2. B

      A 111 by nnn matrix with one score for each feature channel

    3. C

      An nnn by 111 matrix with one score for the whole sequence

    4. D

      An nnn by nnn matrix with a score for each query-key pair

    Correct answer
    D

    An nnn by nnn matrix with a score for each query-key pair

    Explanation

    Every query can be compared with every key, so the pairwise score matrix has one row and one column per token, giving an nnn by nnn matrix.

  37. 37

    Why is the query-key score matrix scaled by the square root of the query and key dimensionality in the standard equation described?

    1. A

      To force the attention matrix to be a permutation matrix

    2. B

      To replace the learned query and key projections with fixed values

    3. C

      To scale the dot products before softmax as part of the standard attention calculation

    4. D

      To make the number of input tokens equal to the feature dimension

    Correct answer
    C

    To scale the dot products before softmax as part of the standard attention calculation

    Explanation

    The standard scaled dot-product attention equation divides query-key dot products by the square root of their dimensionality before applying softmax.

  38. 38

    Why does using learned query and key projections avoid learning a separate free attention weight for every token pair?

    1. A

      The projections determine scores from token content, so their parameter count need not grow with sequence length

    2. B

      The projections assign one learned parameter to each possible sequence position

    3. C

      The projections make every token attend equally to every other token

    4. D

      The projections eliminate the need to compute any pairwise scores

    Correct answer
    A

    The projections determine scores from token content, so their parameter count need not grow with sequence length

    Explanation

    The attention matrix is computed from projected token representations. The learned projection matrices depend on feature dimensions rather than requiring a separate free parameter for every pair of positions in each sequence.

  39. 39

    What is the main idea of multi-headed self-attention?

    1. A

      Use multiple tokenizers to turn one image into different patch sizes

    2. B

      Apply a separate positional encoding to every value feature

    3. C

      Repeat the same attention operation sequentially while sharing one set of scores

    4. D

      Run several attention operations in parallel so they can learn different patterns of interaction

    Correct answer
    D

    Run several attention operations in parallel so they can learn different patterns of interaction

    Explanation

    Multi-headed self-attention uses several attention operations in parallel, allowing different heads to learn to focus on different relationships or features.

  40. 40

    What is the purpose of a residual connection in the transformer architecture described?

    1. A

      It prevents attention from using information from other tokens

    2. B

      It provides an identity path around a processing block

    3. C

      It replaces normalization with a learned positional encoding

    4. D

      It converts each token into a discrete vocabulary item

    Correct answer
    B

    It provides an identity path around a processing block

    Explanation

    A residual connection carries the input around a processing block through an identity path, adding that input to the block's processed output.

  41. 41

    What does LayerNorm typically do in the described transformer?

    1. A

      It normalizes the number of tokens to equal the feature dimension

    2. B

      It normalizes the features of a token using their mean and variance

    3. C

      It changes all attention weights into learnable parameters

    4. D

      It sorts tokens into their original input order

    Correct answer
    B

    It normalizes the features of a token using their mean and variance

    Explanation

    LayerNorm is described as normalizing a vector by subtracting its mean and scaling by its variance or standard deviation, giving normalized activations.

  42. 42

    Which components of the described transformer blocks are learnable?

    1. A

      The query, key, and value projections and the token-wise MLP parameters

    2. B

      The softmax definition and the input patch boundaries only

    3. C

      The residual identity paths and the order of the input tokens

    4. D

      The normalization operation and every token's original position only

    Correct answer
    A

    The query, key, and value projections and the token-wise MLP parameters

    Explanation

    The attention projections and the parameters of the token-wise MLP are learned. Residual connections and the softmax operation are not themselves learned parameters.

  43. 43

    Why is the transformer processing recipe well suited to modern hardware, according to the lecture?

    1. A

      It removes the need to store token activations during processing

    2. B

      Much of the computation can be expressed as matrix multiplications

    3. C

      It avoids all matrix operations and uses only sequential scalar calculations

    4. D

      It requires every token to have a different computational procedure

    Correct answer
    B

    Much of the computation can be expressed as matrix multiplications

    Explanation

    Transformer computations are largely expressed as matrix multiplications and other simple operations, which map well onto modern computing hardware.

  44. 44

    What does the standard transformer token-wise MLP do within a layer?

    1. A

      It computes a different attention score for every pair of image pixels

    2. B

      It applies the same learned nonlinear transformation independently to each token

    3. C

      It imposes causal masking on all token pairs

    4. D

      It converts tokens into positional indices without changing features

    Correct answer
    B

    It applies the same learned nonlinear transformation independently to each token

    Explanation

    The token-wise MLP is applied independently and identically to each token, transforming its feature vector without directly mixing token positions.

  45. 45

    How does the lecture characterize the role of LayerNorm's optimization benefits?

    1. A

      It is used for desirable optimization properties, though the precise reasons are not fully settled

    2. B

      It guarantees the globally optimal transformer parameters

    3. C

      It is proven to eliminate the need for gradient descent

    4. D

      It forces the network to learn the correct attention pattern without data

    Correct answer
    A

    It is used for desirable optimization properties, though the precise reasons are not fully settled

    Explanation

    The lecture says LayerNorm has desirable optimization properties but that exactly why it is the right choice remains an open scientific question.

  46. 46

    What does it mean that a transformer without positional information is permutation equivariant?

    1. A

      Permuting input tokens causes the output tokens to be permuted in the corresponding way

    2. B

      Permuting input tokens forces all outputs to become identical

    3. C

      Permuting input tokens changes the learned weights but not the activations

    4. D

      Permuting input tokens leaves every output token in exactly the same row

    Correct answer
    A

    Permuting input tokens causes the output tokens to be permuted in the corresponding way

    Explanation

    Permutation equivariance means that reordering the input tokens reorders the outputs correspondingly, rather than making the model depend on the original row order.

  47. 47

    Why is a standard transformer without positional information described as a set-to-set mapping?

    1. A

      Its operations do not use the ordering of token rows to distinguish the tokens

    2. B

      It requires every token to be connected to a fixed spatial coordinate

    3. C

      It processes only one token and outputs one scalar

    4. D

      It can only process inputs that are already sorted

    Correct answer
    A

    Its operations do not use the ordering of token rows to distinguish the tokens

    Explanation

    Token-wise processing treats tokens identically, and attention scores depend on token content rather than row order. Without positional information, the input is effectively an unordered set.

  48. 48

    What is the purpose of adding positional encodings to tokens?

    1. A

      To provide information about where each token came from in the input

    2. B

      To ensure that all tokens have the same feature values

    3. C

      To make the attention matrix independent of token content

    4. D

      To replace tokenization with a convolutional operation

    Correct answer
    A

    To provide information about where each token came from in the input

    Explanation

    Positional encodings tell the model the location or order associated with each token, allowing it to use information that is absent from an unordered set representation.

  49. 49

    How can positional information be represented for image patches in the described approach?

    1. A

      By sorting patches according to their color and discarding their coordinates

    2. B

      By assigning every patch the same fixed scalar regardless of location

    3. C

      By encoding the patch's location using sinusoidal or Fourier-style functions

    4. D

      By replacing the patch's pixel values with its attention scores

    Correct answer
    C

    By encoding the patch's location using sinusoidal or Fourier-style functions

    Explanation

    The lecture describes encoding image coordinates with sine and cosine functions at different frequencies, providing a Fourier-style representation of position.

  50. 50

    What domain-specific information can positional encodings provide?

    1. A

      A method for removing the need to represent input features

    2. B

      A guarantee that every token contains the same semantic content

    3. C

      An inductive bias about what locality or location means for the domain

    4. D

      A replacement for all learned query, key, and value projections

    Correct answer
    C

    An inductive bias about what locality or location means for the domain

    Explanation

    Positional encodings are a place to introduce domain knowledge about location and locality, such as coordinates in an image or structure in a graph.

  51. 51

    Which positional encoding example is associated with graph data in the lecture?

    1. A

      Using image-patch color values as a fixed graph ordering

    2. B

      Using byte pairs to define each node's vocabulary position

    3. C

      Using a causal mask to encode graph adjacency

    4. D

      Using eigenvectors of the graph Laplacian to describe node locations

    Correct answer
    D

    Using eigenvectors of the graph Laplacian to describe node locations

    Explanation

    The lecture gives graph Laplacian eigenvectors as a common kind of graph positional encoding, with eigenvectors describing different patterns of location over the graph.

  52. 52

    Why does adding position information affect permutation equivariance?

    1. A

      Position information forces attention scores to be identical for all tokens

    2. B

      The model then becomes invariant to every possible input transformation

    3. C

      Position information removes all dependence on token content

    4. D

      The model can distinguish tokens by their encoded positions, so reordering tokens without their positions changes the represented input

    Correct answer
    D

    The model can distinguish tokens by their encoded positions, so reordering tokens without their positions changes the represented input

    Explanation

    Without positional information, tokens are treated as an unordered set. Position encodings associate each token with its location, allowing order or spatial arrangement to matter.

  53. 53

    What is the basic training objective of an autoregressive language model described in the lecture?

    1. A

      Predict the next text token from the preceding tokens

    2. B

      Classify an entire sentence without modeling token order

    3. C

      Reconstruct image patches from their positional encodings

    4. D

      Predict every earlier token from the final token

    Correct answer
    A

    Predict the next text token from the preceding tokens

    Explanation

    An autoregressive language model is trained to predict the next word or token from the preceding sequence, using observed text as supervised training data.

  54. 54

    What does autoregressive generation do after producing a next-token prediction?

    1. A

      Appends the prediction to the sequence and predicts again

    2. B

      Uses the predicted token only as a positional encoding

    3. C

      Reorders all tokens according to their attention scores

    4. D

      Deletes the preceding context and restarts from an empty sequence

    Correct answer
    A

    Appends the prediction to the sequence and predicts again

    Explanation

    Autoregressive generation repeatedly appends the predicted token to the input sequence and then predicts the next one.

  55. 55

    Why is causal masking needed when training a next-token transformer?

    1. A

      It forces each position to attend to every future token equally

    2. B

      It ensures that each input token is represented by a different dimension

    3. C

      It removes all attention between the current token and previous tokens

    4. D

      It prevents a position's prediction from using future tokens, including its own target

    Correct answer
    D

    It prevents a position's prediction from using future tokens, including its own target

    Explanation

    Without causal masking, the model could inspect the target token in its input and copy it. Masking ensures predictions depend only on allowed preceding information.

  56. 56

    In the causal attention matrix, which tokens can an output position normally attend to?

    1. A

      The permitted earlier tokens and, in the described later-layer mask, itself

    2. B

      Only tokens that occur later in the sequence

    3. C

      Only tokens with the same vocabulary identity

    4. D

      Every token in both the past and future without restriction

    Correct answer
    A

    The permitted earlier tokens and, in the described later-layer mask, itself

    Explanation

    Causal masking restricts attention to earlier positions. The lecture's later-layer illustration allows a token to attend to itself and previous tokens, while preventing access to future tokens.

  57. 57

    Why can causal masking make a transformer's outputs suitable for next-token prediction at multiple positions in one training pass?

    1. A

      Each position receives the correct future token as an additional query

    2. B

      The mask makes all positions predict the same next token

    3. C

      The mask removes the need for training examples of text

    4. D

      Each position's output can use preceding context while remaining unable to see its future target

    Correct answer
    D

    Each position's output can use preceding context while remaining unable to see its future target

    Explanation

    With causal masking, every position's representation depends only on permitted earlier context. The model can therefore be trained to predict the next token at many positions without leaking future targets.

  58. 58

    What does “shifted right” refer to in the language-model diagram discussed in the lecture?

    1. A

      Shifting every attention score by the same learned constant

    2. B

      Offsetting the input sequence relative to the target sequence for next-token prediction

    3. C

      Reversing the order of all words before applying attention

    4. D

      Moving positional encodings from tokens into the value matrix

    Correct answer
    B

    Offsetting the input sequence relative to the target sequence for next-token prediction

    Explanation

    The shifted sequence aligns each input context with the next token that the model should predict, as part of autoregressive training.

  59. 59

    How does cross-attention support image-to-text captioning in the described architecture?

    1. A

      Text-generation tokens can attend both to earlier generated words and to image-token representations

    2. B

      A single image token is copied as the complete caption

    3. C

      Text tokens attend only to future generated words and ignore the image

    4. D

      Image tokens are replaced by words before any transformer processing

    Correct answer
    A

    Text-generation tokens can attend both to earlier generated words and to image-token representations

    Explanation

    In captioning, image tokens are encoded first. During autoregressive text generation, text tokens can use causal attention to prior words and cross-attention to the image representations.

  60. 60

    What distinguishes cross-attention from self-attention in the captioning example?

    1. A

      Cross-attention compares each token only with itself

    2. B

      Cross-attention uses no query, key, or value representations

    3. C

      Cross-attention connects tokens from one set, such as text, to a different set, such as image tokens

    4. D

      Cross-attention is the same as a positional encoding applied to one sequence

    Correct answer
    C

    Cross-attention connects tokens from one set, such as text, to a different set, such as image tokens

    Explanation

    Self-attention relates tokens within the same set or sequence. Cross-attention lets one set of tokens attend to another, as when text-generation tokens attend to image tokens.

  61. 61

    Which statement best describes the relationship between GPT and the transformer in the lecture?

    1. A

      GPT is a positional encoding method based on graph eigenvectors

    2. B

      GPT is a convolutional network that predicts image patches only

    3. C

      GPT is an autoregressive transformer that predicts successive text tokens

    4. D

      GPT is a tokenizer that converts sentences into byte pairs

    Correct answer
    C

    GPT is an autoregressive transformer that predicts successive text tokens

    Explanation

    GPT stands for Generative Pre-trained Transformer. The lecture describes it as a transformer used autoregressively to predict the next text token.

Question 1 of 61
Question 1 of 61

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent