1. Home
  2. Explore
  3. Computer Science
  4. Attention and Transformers

Study methods

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

Attention and Transformers

  • 84Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Sequence Motivation
A problem that takes one input, such as an image, and produces one output, such as a classification, is called a
problem.

84 questions

  1. 1
    A problem that takes one input, such as an image, and produces one output, such as a classification, is called a
    _____
    problem.
    Hint

    Both the input and output consist of a single item.

    Answer

    one-to-one

  2. 2
    Image captioning is an example of a
    _____
    problem because one image produces a sequence of words.
    Hint

    The input is singular, but the output contains multiple sequential elements.

    Answer

    one-to-many

  3. 3
    Inputting a sequence of video frames and producing one classification is an example of a
    _____
    problem.
    Hint

    The input has multiple elements, while the output is a single label.

    Answer

    many-to-one

  4. 4
    Recurrent neural networks were introduced as neural network architectures designed for processing
    _____
    data.
    Hint

    The data elements have an ordered temporal or positional relationship.

    Answer

    sequences

  5. 5
    The ability to process sequences allows neural networks to address problems that traditional
    _____
    neural networks could not handle as naturally.
    Hint

    These networks do not maintain a recurrent state across sequence elements.

    Answer

    feed forward

  6. 6
    The transformer architecture has
    _____
    attention at its core.
    Hint

    The mechanism allows elements within one set to interact with one another.

    Answer

    self

  7. 7
    Transformers are widely used for large state-of-the-art applications involving images, text, and
    _____
    .
    Hint

    This modality includes speech and other sound signals.

    Answer

    audio

  8. 8
    The ideas behind transformers developed historically from work on recurrent neural networks and
    _____
    .
    Hint

    This mechanism lets a model focus on relevant parts of an input.

    Answer

    attention

  9. 9
    Neural machine translation maps an input sequence of English words to an output sequence of words in
    _____
    .
    Hint

    The lecture uses Italian and French as examples.

    Answer

    another language

  10. 10
    In translation, the input and output sequences may differ in both their number of words and their word
    _____
    .
    Hint

    Languages do not necessarily arrange corresponding words identically.

    Answer

    order

  11. 11
    In a recurrent sequence-to-sequence model, the input sequence is first processed by an RNN called the
    _____
    .
    Hint

    This network reads and represents the source sequence.

    Answer

    encoder

  12. 12
    At each time step, a recurrent neural network receives the current input xxx and the previous
    _____
    state.
    Hint

    This state carries information from earlier sequence positions.

    Answer

    hidden

  13. 13
    Applying the same recurrent unit repeatedly across time allows an RNN to process sequences of potentially
    _____
    length.
    Hint

    The number of sequence elements does not need to be fixed in advance.

    Answer

    variable

  14. 14
    The encoder summarizes the entire input sequence into a single vector called the
    _____
    vector.
    Hint

    This vector provides information about the source sequence to the decoder.

    Answer

    context

  15. 15
    A common way to form the context vector in an encoder RNN is to use the encoder's
    _____
    hidden state.
    Hint

    This state is produced after all input tokens have been processed.

    Answer

    last

  16. 16
    The network that generates the translated output sequence one token at a time is called the
    _____
    .
    Hint

    It converts the source representation into the target sequence.

    Answer

    decoder

  17. 17
    At each time step, the decoder RNN receives the previous output token, its previous hidden state, and the
    _____
    vector.
    Hint

    This third input summarizes the encoded source sequence.

    Answer

    context

  18. 18
    The encoder and decoder may share the same architecture while using different learned
    _____
    .
    Hint

    These include weights and biases learned during optimization.

    Answer

    parameters

  19. 19
    The decoder produces output words one at a time by repeatedly
    _____
    the recurrent network across the output sequence.
    Hint

    This means applying the same recurrent computation at successive time steps.

    Answer

    unrolling

  20. 20
    The fixed-size context vector creates a communication
    _____
    between the input and output sequences.
    Hint

    All source information must pass through one limited representation.

    Answer

    bottleneck

  21. 21
    The fixed length of the context vector does not change when the input or output sequence becomes longer or
    _____
    .
    Hint

    The vector dimension is set by the architecture rather than by sequence length.

    Answer

    shorter

  22. 22
    The bottleneck becomes especially problematic when translating very long sequences such as a paragraph, book, or entire
    _____
    .
    Hint

    This term refers to a large collection of texts or data.

    Answer

    corpus

  23. 23
    Attention addresses the bottleneck by allowing the decoder to look back at the
    _____
    input sequence at every output time step.
    Hint

    The decoder is not restricted to one summary vector.

    Answer

    entire

  24. 24
    To determine what to focus on, attention first computes scalar
    _____
    scores between a decoder state and each encoder state.
    Hint

    These scores measure how well two representations match.

    Answer

    alignment

  25. 25
    A simple alignment function concatenates the decoder hidden state with an encoder hidden state and applies a learned
    _____
    layer.
    Hint

    This layer maps the combined vector to one scalar.

    Answer

    linear

  26. 26
    Because raw alignment scores are unbounded real values, they are converted into attention weights using
    _____
    .
    Hint

    This function transforms scores into nonnegative values that sum to one.

    Answer

    softmax

  27. 27
    The outputs of a softmax lie between 0 and 1 and
    _____
    to one.
    Hint

    These are the defining properties of a discrete probability distribution.

    Answer

    sum

  28. 28
    Attention weights can be interpreted as a probability distribution over the input
    _____
    .
    Hint

    Each position corresponds to an element such as a word in the source sentence.

    Answer

    tokens

  29. 29
    The attention context vector is computed as a weighted
    _____
    combination of the encoder hidden states.
    Hint

    Each encoder state is multiplied by an attention weight and then summed.

    Answer

    linear

  30. 30
    At each decoder step, the attention mechanism computes a new context vector rather than reusing a single
    _____
    vector.
    Hint

    The new representation is selected dynamically for the current output step.

    Answer

    fixed length

  31. 31
    When generating a word corresponding to 'we see,' the model can assign higher attention weights to the input words
    _____
    .
    Hint

    These are the source words most relevant to that output.

    Answer

    we see

  32. 32
    The attention computation is differentiable, so its parameters can be learned end to end through
    _____
    descent.
    Hint

    This optimization method adjusts parameters using derivatives of the loss.

    Answer

    gradient

  33. 33
    The output sequence is commonly trained with a cross-entropy loss applied to predicted output
    _____
    .
    Hint

    The model is trained to predict the correct words or symbols.

    Answer

    tokens

  34. 34
    The initial hidden state of a decoder may be set to zeros, derived from the encoder's final state, or produced by a learned
    _____
    transform.
    Hint

    This transformation maps one representation into the required decoder-state dimension.

    Answer

    linear

  35. 35
    The attention operator takes a query vector and summarizes a collection of data vectors into an output
    _____
    .
    Hint

    The result is the context representation produced for that query.

    Answer

    vector

  36. 36
    In the generalized attention formulation, the decoder hidden states serve as
    _____
    vectors.
    Hint

    They specify what information the model is trying to produce or retrieve.

    Answer

    query

  37. 37
    The encoder hidden states serve as the
    _____
    vectors that attention summarizes.
    Hint

    These vectors contain the information available for retrieval.

    Answer

    data

  38. 38
    The similarity function in attention takes two vectors and returns a scalar
    _____
    score.
    Hint

    The score measures how well the two representations match.

    Answer

    similarity

  39. 39
    The simplest commonly used similarity function for attention is the
    _____
    product.
    Hint

    It multiplies corresponding vector components and sums the results.

    Answer

    dot

  40. 40
    Scaled dot-product attention divides the dot product by the square root of the vector
    _____
    .
    Hint

    The scaling compensates for changes in representation size.

    Answer

    dimension

  41. 41
    The scaling factor in scaled dot-product attention improves gradient flow through the
    _____
    function.
    Hint

    This function can become too concentrated when its inputs grow large.

    Answer

    softmax

  42. 42
    Attention can process many query vectors in parallel by representing them as a
    _____
    .
    Hint

    A collection of vectors can be arranged as rows or columns of one two-dimensional object.

    Answer

    matrix

  43. 43
    All pairwise similarities between query vectors and data vectors can be computed efficiently with a
    _____
    multiplication.
    Hint

    This operation produces inner products between rows or columns.

    Answer

    matrix

  44. 44
    The output of attention is formed by taking linear combinations of the data vectors weighted by the
    _____
    matrix.
    Hint

    This matrix contains the normalized scores produced by softmax.

    Answer

    attention

  45. 45
    Attention separates the roles of matching and retrieval by projecting each data vector into a key and a
    _____
    .
    Hint

    This representation is combined to form the output.

    Answer

    value

  46. 46
    Key vectors are compared with the query vectors to compute
    _____
    scores.
    Hint

    These scores indicate how well a query matches each key.

    Answer

    alignment

  47. 47
    Value vectors are combined using attention weights to produce the attention
    _____
    .
    Hint

    This is the context-like representation returned by the layer.

    Answer

    output

  48. 48
    The key and value projections are implemented with separate learnable
    _____
    matrices.
    Hint

    These parameters are optimized along with the rest of the neural network.

    Answer

    weight

  49. 49
    The separation of keys and values is analogous to a search engine separating what is being looked for from the information returned as the
    _____
    .
    Hint

    The query matches indexed representations, while a different representation is retrieved.

    Answer

    answer

  50. 50
    A cross attention layer receives query vectors and data vectors as two potentially
    _____
    sets of inputs.
    Hint

    The two sets may come from separate sources or represent different modalities.

    Answer

    different

  51. 51
    In machine translation, cross attention can connect representations of an input sentence with representations of the
    _____
    sentence.
    Hint

    This sentence is generated in the target language.

    Answer

    output

  52. 52
    Image captioning can use cross attention to relate image features to generated word
    _____
    .
    Hint

    The generated sequence consists of pieces of text.

    Answer

    tokens

  53. 53
    A self attention layer begins with only one set of input
    _____
    .
    Hint

    The same representations provide the source for all three projections.

    Answer

    vectors

  54. 54
    In self attention, every input vector is separately projected into a query, a key, and a
    _____
    .
    Hint

    This is the third representation used for aggregation.

    Answer

    value

  55. 55
    Self attention produces the same number of output vectors as input
    _____
    .
    Hint

    There is one output associated with each query position.

    Answer

    vectors

  56. 56
    The input and output dimensions of a self attention layer are architectural
    _____
    .
    Hint

    They are chosen when designing the layer rather than learned directly.

    Answer

    hyperparameters

  57. 57
    In practice, the input and output dimensions of self attention are usually the
    _____
    .
    Hint

    Although they can differ in principle, implementations commonly preserve the model width.

    Answer

    same

  58. 58
    The three projections in self attention can be fused into one large matrix multiplication for greater hardware
    _____
    .
    Hint

    Fewer larger operations are often preferable to many smaller ones.

    Answer

    efficiency

  59. 59
    Self attention is particularly suitable for image classification when the model needs to process parts of an image relative to
    _____
    .
    Hint

    There is only one natural input modality in this situation.

    Answer

    themselves

  60. 60
    If the inputs to self attention are permuted, the outputs are permuted in the same way; this property is called permutation
    _____
    .
    Hint

    The operation respects reordering rather than producing order-independent output positions.

    Answer

    equivariance

  61. 61
    Because ordinary self attention does not depend on input order, it fundamentally operates on
    _____
    of vectors rather than ordered sequences.
    Hint

    A set has no inherent ordering.

    Answer

    sets

  62. 62
    To provide sequence order information, a positional
    _____
    can be concatenated to each input vector.
    Hint

    This added representation indicates an element's position.

    Answer

    embedding

  63. 63
    Masked self attention blocks selected interactions by replacing prohibited alignment scores with negative
    _____
    .
    Hint

    After softmax, these values receive zero probability.

    Answer

    infinities

  64. 64
    In causal language modeling, masking prevents a token from looking
    _____
    in the sequence.
    Hint

    The model must not use future words when predicting the current word.

    Answer

    ahead

  65. 65
    Multi-headed self attention runs several independent copies, called
    _____
    heads, in parallel.
    Hint

    Each copy has the same architecture but different learned weights.

    Answer

    attention

  66. 66
    The outputs of the independent attention heads are combined using a final linear
    _____
    .
    Hint

    This learned transformation mixes information across heads.

    Answer

    projection

  67. 67
    Recurrent neural networks operate on one-dimensional ordered sequences but are fundamentally difficult to
    _____
    across sequence positions.
    Hint

    Each hidden state depends on the previous hidden state.

    Answer

    parallelize

  68. 68
    Convolution operates on multidimensional
    _____
    and mixes information locally.
    Hint

    Images are a common two-dimensional example.

    Answer

    grids

  69. 69
    Convolution is highly parallelizable because different kernel positions can, in principle, be computed in
    _____
    .
    Hint

    The computations at separate spatial positions do not inherently depend on one another.

    Answer

    parallel

  70. 70
    Convolution has difficulty building large
    _____
    fields without using large kernels or many layers.
    Hint

    This refers to the region of the input that can influence an output.

    Answer

    receptive

  71. 71
    Unlike convolution, one self attention layer allows every vector to look at
    _____
    other vector.
    Hint

    The interaction is global rather than local.

    Answer

    every

  72. 72
    For a sequence of length nnn, full self attention has computational complexity proportional to
    _____
    .
    Hint

    Every one of the nnn positions can compare with all nnn positions.

    Answer

    n2n^2n2

  73. 73
    A transformer places
    _____
    attention at the center of its neural network architecture.
    Hint

    This is the attention variant in which queries, keys, and values originate from the same input.

    Answer

    self

  74. 74
    After self attention, a transformer commonly uses a
    _____
    connection to help stabilize optimization.
    Hint

    This connection adds a layer's input back to its output.

    Answer

    residual

  75. 75
    Transformer blocks commonly apply
    _____
    normalization after the residual attention operation.
    Hint

    The normalization is applied across features within each representation.

    Answer

    layer

  76. 76
    The transformer component that processes each vector independently is a two-layer
    _____
    perceptron.
    Hint

    It is commonly abbreviated MLP.

    Answer

    multi-layer

  77. 77
    The per-vector MLP is also called an
    _____
    network, abbreviated FFN.
    Hint

    This name emphasizes that it operates independently on each vector.

    Answer

    feed-forward

  78. 78
    A transformer block consists of attention and an independent-vector MLP, each wrapped with residual connections and layer
    _____
    .
    Hint

    This process helps stabilize the activations and training.

    Answer

    normalization

  79. 79
    A transformer is formed by stacking a sequence of transformer
    _____
    .
    Hint

    Each repeated unit contains self attention and an MLP.

    Answer

    blocks

  80. 80
    To apply a transformer to an image, the image is divided into
    _____
    and each patch is projected into a vector.
    Hint

    These are smaller regions of the original image.

    Answer

    patches

  81. 81
    For image classification, the transformer outputs are aggregated with a
    _____
    operation before class scores are predicted.
    Hint

    This operation combines representations from multiple image patches.

    Answer

    pooling

  82. 82
    The main computational operations in a multi-headed self attention layer can be implemented as approximately four large batched
    _____
    multiplies.
    Hint

    These operations are highly optimized on GPUs.

    Answer

    matrix

  83. 83
    Matrix multiplication makes attention highly scalable because it can be distributed and efficiently run on
    _____
    .
    Hint

    These processors are designed for massively parallel numerical operations.

    Answer

    GPUs

  84. 84
    The transformer architecture has scaled from early models with relatively few blocks to models containing hundreds of blocks and
    _____
    of parameters.
    Hint

    This is a quantity larger than billions.

    Answer

    trillions

1 of 84
Question 1 of 84

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent