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

  • 60Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Locality and Motivation
CNNs are built around the inductive bias of
: each filter processes a local part of the input.

60 questions

  1. 1
    CNNs are built around the inductive bias of
    _____
    : each filter processes a local part of the input.
    Hint

    Think about how convolutional filters limit which input regions interact directly.

    Answer

    locality

    Explanation

    CNNs factorize signal processing into local pieces, which are assembled step by step. This gives them a strong locality bias.

  2. 2
    A shallow CNN may be unable to make a decision based on the joint configuration of two distant inputs if their receptive fields do not overlap at the output; the lecture illustrates this with
    _____
    and x7.
    Hint

    Recall the first input variable in the example comparing the two distant inputs.

    Answer

    x1

    Explanation

    In the depth-two convolutional example, no output neuron had information from both x1 and x7, so the network could not assess their joint configuration.

  3. 3
    Increasing the depth of a CNN expands its receptive field, but information spreads across the network
    _____
    than in a globally connected operation.
    Hint

    The lecture describes information as dye that gradually bleeds through the network.

    Answer

    slowly

    Explanation

    In convolutional networks, receptive fields expand layer by layer, so information from distant locations may take depth to come together.

  4. 4
    A fully connected network aggregates information
    _____
    because each output neuron connects to every input neuron.
    Hint

    Contrast this with a CNN’s local filters.

    Answer

    globally

    Explanation

    In a fully connected network, every output neuron receives information from every input neuron, so aggregation is global immediately.

  5. 5
    For a mapping from an input of size n to an output of size n, fully connecting every input to every output requires
    _____
    edges.
    Hint

    Count the connections between every input-output pair.

    Answer

    n squared

    Explanation

    A fully connected mapping from Rn to Rn has n choices of input for each of n outputs, for n squared edges and parameters.

  6. 6
    Attention aims to combine global access with
    _____
    global connectivity, rather than connecting every neuron to every other neuron.
    Hint

    The mechanism selects only the input parts relevant to the current task.

    Answer

    sparse

    Explanation

    Attention allows a model to look globally while selectively focusing on relevant parts, avoiding the full cost of dense all-to-all connections.

  7. 7
    The parts of an input that receive attention can change when the
    _____
    changes.
    Hint

    Counting birds and identifying the sky color call for different regions.

    Answer

    problem

    Explanation

    Attention is task-dependent: a model may attend to animals to count them, or to the sky to determine its color.

  8. 8
    Transformers can be applied across different domains after domain-specific data is converted into a set of
    _____
    for generic processing.
    Hint

    These are the basic units a transformer operates over.

    Answer

    tokens

    Explanation

    The transformer recipe separates domain-specific tokenization from generic processing of the resulting tokens.

  9. 9
    A major reason transformers transfer across domains is that they are relatively
    _____
    to the input domain once data has been tokenized.
    Hint

    The architecture can process tokens from images, language, audio, and other signals.

    Answer

    agnostic

    Explanation

    Transformers use a general token-processing framework, while domain knowledge is chiefly introduced in tokenization and related choices such as positional encoding.

  10. 10
    In the lecture’s terminology, a token is a
    _____
    of neurons that encapsulates a unit of information.
    Hint

    It is a vector-valued unit, in contrast to a scalar-valued neuron.

    Answer

    vector

    Explanation

    The lecture defines a token as a vector of neurons, treated as a bundled or encapsulated piece of information.

  11. 11
    In the graph-network example, the units corresponding to transformer tokens were graph
    _____
    or their associated feature vectors.
    Hint

    These are the entities in a graph that carry node attributes.

    Answer

    nodes

    Explanation

    Graph-net node attribute or feature vectors play the role of tokens in the lecture’s comparison.

  12. 12
    A transformer’s basic data structure is an array of
    _____
    rather than an array of scalar-valued neurons.
    Hint

    Each unit in this array is a vector-valued information bundle.

    Answer

    tokens

    Explanation

    Transformers operate over arrays or sets of vector-valued tokens, whereas ordinary neural networks are often described in terms of scalar-valued neurons.

  13. 13
    In the lecture’s token-matrix notation, the matrix has n rows for tokens and d columns for token
    _____
    .
    Hint

    This is the dimensionality of each token vector.

    Answer

    channels

    Explanation

    The token matrix stacks n token vectors as rows, with d channels or dimensions in each vector.

  14. 14
    For image tokenization, a common approach is to divide an image into non-overlapping
    _____
    and flatten each one into a vector.
    Hint

    Each chunk contains a local region of pixels.

    Answer

    patches

    Explanation

    The standard image procedure described is to break the image into patches, flatten each patch, and project it into a token vector.

  15. 15
    After flattening an image patch, a linear projection maps its pixel values to a chosen token
    _____
    .
    Hint

    The result is a vector in a chosen number of dimensions.

    Answer

    dimensionality

    Explanation

    A matrix projection, which may be learned or hard-coded, maps the flattened patch to a vector of the desired dimensionality.

  16. 16
    The standard image-tokenization approach described in the lecture generally uses patches that do not
    _____
    .
    Hint

    Adjacent patches are typically separate chunks in this standard approach.

    Answer

    overlap

    Explanation

    Standard architectures generally use non-overlapping image patches, though overlapping patches are possible as a design choice.

  17. 17
    In language processing, the lecture identifies byte pairs as a commonly used way to form small text
    _____
    .
    Hint

    These are pieces such as character combinations that serve as units of language.

    Answer

    snippets

    Explanation

    Language can be divided into characters, words, or other units; the lecture describes byte pairs as a common choice.

  18. 18
    The lecture’s use of “token” differs from the common NLP usage, where a token often means a discrete unit of the
    _____
    .
    Hint

    Examples include a character or a word treated as a discrete symbol.

    Answer

    vocabulary

    Explanation

    In much NLP usage, tokens are discrete vocabulary units. The lecture instead uses token to mean a vector-valued chunk of information.

  19. 19
    A linear combination of tokens applies weights to whole token vectors, so it is less expressive than independently combining all the individual
    _____
    .
    Hint

    These are the scalar components bundled inside the token vectors.

    Answer

    neurons

    Explanation

    A token-level weighted sum uses one weight per token, rather than separate weights for every scalar neuron in every token.

  20. 20
    The lecture characterizes a linear combination of tokens as a
    _____
    operation over the underlying neurons.
    Hint

    It uses fewer independent weights than a fully general transformation over all scalar components.

    Answer

    low rank

    Explanation

    Because token combination assigns weights to whole vectors, the resulting transformation over their individual neurons is low rank relative to a fully general linear layer.

  21. 21
    A token-wise nonlinearity applies the same nonlinear function to each token
    _____
    and identically.
    Hint

    Each token is processed separately, using shared behavior.

    Answer

    independently

    Explanation

    A token-wise nonlinearity applies one function to every token independently and identically; the function is often an MLP.

  22. 22
    When the token-wise function is viewed as a convolution over a sequence, it is equivalent to a
    _____
    convolutional filter.
    Hint

    The filter operates on each token without mixing it with neighboring tokens.

    Answer

    1 by 1

    Explanation

    The lecture relates token-wise processing to a 1 by 1 convolution, which applies a function to each token independently.

  23. 23
    A transformer can be understood as a graph net on a
    _____
    connected graph, with attention determining the aggregation weights.
    Hint

    Unlike a graph net restricted by an adjacency structure, every token can potentially interact with every other token.

    Answer

    fully

    Explanation

    The lecture describes a transformer as similar to a graph net over a fully connected graph, typically without weight sharing across depth.

  24. 24
    In a graph net, which tokens are combined during aggregation is determined by the graph’s
    _____
    matrix.
    Hint

    This matrix encodes which graph nodes are connected.

    Answer

    adjacency

    Explanation

    Graph connectivity, represented by the adjacency matrix, determines the aggregation structure in a graph net.

  25. 25
    A query vector represents what a token is asking the attention mechanism to
    _____
    .
    Hint

    It is compared against keys to identify relevant tokens.

    Answer

    attend to

    Explanation

    The query expresses what information is sought; its match with keys determines how much attention is assigned to tokens.

  26. 26
    A key vector represents information that a query can
    _____
    against to determine relevance.
    Hint

    The mechanism compares queries and keys using a similarity score.

    Answer

    match

    Explanation

    Each token emits a key that represents its content in a form that queries can compare against.

  27. 27
    A value vector contains the information from a token that is passed along to the next stage when the token receives
    _____
    .
    Hint

    After a query-key match, the model uses this representation in the weighted sum.

    Answer

    attention

    Explanation

    Values are the transformed token representations that are combined according to the attention weights.

  28. 28
    In query-key-value attention, the similarity between a query and a key is computed using their
    _____
    product.
    Hint

    It is the scalar product of the two vectors.

    Answer

    dot

    Explanation

    The dot product between query and key vectors provides a score indicating how relevant the key is to the query.

  29. 29
    The attention scores are normalized with a
    _____
    so the weights sum to one.
    Hint

    This operation turns a score vector into normalized weights.

    Answer

    softmax

    Explanation

    Applying softmax to the similarity scores produces attention weights that sum to one.

  30. 30
    The attention weights are used to take a weighted sum of the tokens’
    _____
    vectors.
    Hint

    These transformed vectors carry the information reported to the next layer.

    Answer

    value

    Explanation

    Attention forms a linear combination of value vectors, weighted according to the query-key similarity scores.

  31. 31
    The query, key, and value vectors are produced from token vectors by learned
    _____
    transformations.
    Hint

    Each uses a learned matrix projection in the standard mechanism.

    Answer

    linear

    Explanation

    The standard attention layer uses learnable matrices to project token vectors into query, key, and value vectors.

  32. 32
    In self-attention, the queries are emitted by tokens from the same
    _____
    that is being processed.
    Hint

    Unlike cross-attention, the queries are not supplied by an external question or text.

    Answer

    signal

    Explanation

    Self-attention lets each token in the input set emit queries to other tokens in that same input signal.

  33. 33
    In self-attention, the query-key dot products for all token pairs form an
    _____
    matrix.
    Hint

    There is a score for every input-token and output-token pair.

    Answer

    n by n

    Explanation

    With n input tokens, comparing each query with every key produces an n by n matrix of scores.

  34. 34
    In the standard scaled attention equation, the query-key scores are divided by the square root of the vector
    _____
    .
    Hint

    This is the size of the query and key vectors used in the scaling.

    Answer

    dimensionality

    Explanation

    The attention scores are scaled by the square root of the query-key vector dimensionality before softmax.

  35. 35
    The output of an attention operation is computed by multiplying the attention matrix by the matrix of
    _____
    vectors.
    Hint

    These vectors are weighted and combined by attention.

    Answer

    value

    Explanation

    The attention matrix supplies weights for combining the value vectors into output representations.

  36. 36
    In self-attention, each input token emits a query, a key, and a
    _____
    vector.
    Hint

    This is the third member of the query-key-value set.

    Answer

    value

    Explanation

    The self-attention layer projects every input token into a query, key, and value representation.

  37. 37
    Multiple attention operations run in parallel and then combined are called
    _____
    self-attention.
    Hint

    Each parallel operation can learn to focus on different kinds of information.

    Answer

    multi-headed

    Explanation

    Multi-headed self-attention uses multiple attention heads that can attend to different features, such as shapes or textures, before their results are combined.

  38. 38
    If one attention head focuses on shapes while another focuses on textures, the heads have learned different kinds of
    _____
    .
    Hint

    These are distinct aspects of the input that the heads may represent.

    Answer

    features

    Explanation

    Parallel attention heads can learn to focus on different kinds of information in the input, such as shapes and textures.

  39. 39
    A transformer with self-attention is permutation
    _____
    : reordering input tokens reorders the corresponding output representations.
    Hint

    The output changes in a corresponding way when the input order changes.

    Answer

    equivariant

    Explanation

    Without positional information or causal masking, permuting the input tokens results in the same permutation of the output tokens.

  40. 40
    Because of permutation equivariance, a basic transformer maps an unordered set of tokens to an unordered set of
    _____
    .
    Hint

    The output has the same kind of elements as the input.

    Answer

    tokens

    Explanation

    The ordering of tokens does not matter to the basic transformer operations, so the architecture acts as a set-to-set mapping.

  41. 41
    The standard vision transformer architecture applies token-wise processing, self-attention, residual connections, and
    _____
    .
    Hint

    This operation normalizes each token representation and is also called token norm in the lecture.

    Answer

    LayerNorm

    Explanation

    The described vision transformer includes LayerNorm, multi-headed self-attention, token-wise MLP processing, and residual connections.

  42. 42
    In a transformer, the token-wise MLP is applied to each token vector
    _____
    and identically.
    Hint

    It does not combine information across tokens by itself.

    Answer

    independently

    Explanation

    The token-wise MLP applies the same nonlinear transformation to every token separately.

  43. 43
    A residual connection adds an
    _____
    path around a processing block.
    Hint

    The input can pass directly around the block before being combined with its processed output.

    Answer

    identity

    Explanation

    Residual connections provide an identity pass around processing, adding the input representation back to the block’s output.

  44. 44
    LayerNorm normalizes the elements of a token vector by subtracting its mean and dividing by its
    _____
    .
    Hint

    The lecture describes normalization to zero mean and unit variance.

    Answer

    variance

    Explanation

    LayerNorm is described as subtracting the vector’s mean and dividing by its variance to normalize activations.

  45. 45
    The learnable parameters in a transformer include the query, key, and value projections and the parameters of the token-wise
    _____
    .
    Hint

    This is the nonlinear function applied separately to each token.

    Answer

    MLP

    Explanation

    The attention projections and token-wise MLP parameters are learned; residual additions and normalization operations are not learned in the described diagram.

  46. 46
    The main operations in the transformer pseudocode are matrix multiplications and a few other simple
    _____
    .
    Hint

    The lecture emphasizes that the implementation uses straightforward mathematical operations.

    Answer

    operators

    Explanation

    Transformer computations are largely expressed as matrix multiplications, together with operations such as softmax, normalization, and residual addition.

  47. 47
    Transformers typically use separate sets of weights at different layers rather than sharing weights across
    _____
    .
    Hint

    This describes the distinction between parameters used at different network layers.

    Answer

    depth

    Explanation

    The lecture notes that standard transformers typically do not share weights across depth, although sharing is possible.

  48. 48
    An unrolled graph neural network can share its weights across depth, whereas a standard transformer typically uses separate weights at each
    _____
    .
    Hint

    This is another way to refer to stages along the network’s depth.

    Answer

    layer

    Explanation

    Weight sharing across depth is a possible property of unrolled GNNs, while standard transformers generally use distinct layer parameters.

  49. 49
    For language modeling, transformers use causal masking so a token cannot attend to tokens that come
    _____
    in the sequence.
    Hint

    A next-word prediction must not use information from the future.

    Answer

    later

    Explanation

    Causal masking prevents a prediction from accessing future tokens, ensuring that each output depends only on earlier sequence elements.

  50. 50
    Causal masking sets disallowed attention connections to
    _____
    .
    Hint

    The mask removes those arrows from the attention matrix.

    Answer

    zero

    Explanation

    Causal masking blocks future-token connections by setting the corresponding attention entries to zero.

  51. 51
    Without causal masking during next-word training, a model could simply copy the target word from its input through an
    _____
    connection.
    Hint

    This would let the model see the answer directly rather than predict it.

    Answer

    identity

    Explanation

    If the target word is visible to the model, it could learn an identity connection instead of predicting the next word from preceding context.

  52. 52
    An autoregressive language model predicts the
    _____
    item in a sequence from the items already provided.
    Hint

    It repeatedly extends the sequence one unit at a time.

    Answer

    next

    Explanation

    Autoregressive modeling predicts the next word or token, then appends that prediction and repeats the process.

  53. 53
    At inference time, an autoregressive model appends each prediction to its input and repeats the prediction
    _____
    .
    Hint

    The model continues generating one item at a time.

    Answer

    process

    Explanation

    Autoregressive generation uses the predicted item as part of the extended input for the next prediction.

  54. 54
    In language modeling, the next-word prediction is trained against examples from a dataset of observed
    _____
    .
    Hint

    The training examples are real language sequences and their continuations.

    Answer

    text

    Explanation

    The model learns through supervised training to predict continuations found in a text dataset.

  55. 55
    A positional encoding provides information about where a token came from in the input
    _____
    , such as its sentence position or image location.
    Hint

    It tells the transformer the token’s location in the data being processed.

    Answer

    signal

    Explanation

    Positional encodings add information about the token’s original position, supplying order or location information that basic self-attention lacks.

  56. 56
    For image tokens, a positional encoding can represent the patch’s horizontal and vertical location using sine and cosine functions, creating a
    _____
    representation.
    Hint

    This basis uses sinusoidal functions at different frequencies.

    Answer

    Fourier

    Explanation

    The lecture describes encoding image positions with sine and cosine functions in a Fourier basis rather than only Cartesian coordinates.

  57. 57
    For graph data, one positional encoding approach uses eigenvectors of the graph
    _____
    .
    Hint

    This graph matrix has eigenvectors that can describe locations or patterns across the graph.

    Answer

    Laplacian

    Explanation

    The eigenvectors of the graph Laplacian can serve as positional encodings, providing graph-based location information.

  58. 58
    Positional encodings communicate domain-specific information about what it means for elements to be
    _____
    .
    Hint

    They provide an inductive bias about relationships between positions in a domain.

    Answer

    local

    Explanation

    Positional encodings introduce domain knowledge by representing locations and the notion of locality for the signal being processed.

  59. 59
    The transformation of image tokens into a sequence of text tokens can use
    _____
    attention between the image-token representations and the generated text tokens.
    Hint

    The two sets of tokens are different from one another.

    Answer

    cross

    Explanation

    Cross-attention allows text-generation tokens to attend to representations from a separate set of image tokens, enabling image captioning.

  60. 60
    In image captioning, generated text tokens can attend both to previous words in the caption and to the image’s
    _____
    .
    Hint

    These represent the image patches that were processed by the vision component.

    Answer

    tokens

    Explanation

    The captioning setup combines autoregressive access to previous words with cross-attention to the encoded image tokens.

1 of 60
Question 1 of 60

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent