Transformer Architecture and Attention
- 60Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
60 questions
- 1CNNs 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.
- 2A 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.
- 3Increasing 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.
- 4A 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.
- 5For 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.
- 6Attention 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.
- 7The 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.
- 8Transformers 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.
- 9A 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.
- 10In 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.
- 11In 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.
- 12A 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.
- 13In 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.
- 14For 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.
- 15After 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.
- 16The 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.
- 17In 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.
- 18The 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.
- 19A 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.
- 20The 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.
- 21A 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.
- 22When 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.
- 23A 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.
- 24In 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.
- 25A 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.
- 26A 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.
- 27A 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.
- 28In 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.
- 29The 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.
- 30The 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.
- 31The 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.
- 32In 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.
- 33In 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.
- 34In 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.
- 35The 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.
- 36In 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.
- 37Multiple 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.
- 38If 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.
- 39A 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.
- 40Because 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.
- 41The 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.
- 42In 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.
- 43A 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.
- 44LayerNorm 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.
- 45The 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.
- 46The 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.
- 47Transformers 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.
- 48An 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.
- 49For 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.
- 50Causal 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.
- 51Without 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.
- 52An 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.
- 53At 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.
- 54In 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.
- 55A 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.
- 56For 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.
- 57For 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.
- 58Positional 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.
- 59The 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.
- 60In 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.

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