Transformers and Large Language Models
- 85Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
How did NLP systems in the 2010s typically differ from modern general-purpose LLMs?
They commonly used a separate model for each task rather than one model serving many purposes.
Or swipe the card
85 cards
How did NLP systems in the 2010s typically differ from modern general-purpose LLMs?
They commonly used a separate model for each task rather than one model serving many purposes.
What were examples of task-specific NLP systems used in the 2010s?
Separate systems handled sentiment classification, machine translation, and named-entity recognition such as identifying people or locations.
What architecture commonly dominated NLP in the 2010s before transformers?
Recurrent neural networks (RNNs).
What did the 2017 paper “Attention Is All You Need” introduce?
The transformer architecture, which relies on attention rather than recurrence to connect tokens.
What does it mean that transformers are scalable?
Increasing model parameters, training data, and compute can produce substantial performance gains.
What broader change did ChatGPT’s 2022 release represent?
It brought conversational interaction with LLMs to a much wider public and marked a major product shift.
How have some newer LLM approaches differed from predicting one token at a time?
Some approaches use alternative paradigms, including diffusion-based methods.
What is tokenization in language modeling?
The process of dividing text into discrete units called tokens that can be represented numerically.
What is a token vocabulary?
The set of token types that a tokenizer is allowed to use.
How does the choice of vocabulary affect a tokenized sequence?
Different vocabularies can split the same text into different numbers of tokens; vocabulary choices are closely related to sequence length.
How does word-level tokenization usually divide English text?
It treats each word, often separated by spaces, as a token.
What are advantages of word-level tokenization?
It is simple and interpretable because each token corresponds directly to a word.
Why can word-level tokenization create a large vocabulary?
Words occur in many forms, such as singular and plural or masculine and feminine forms, which may each become separate tokens.
Why can word-level tokenization struggle to represent related word forms?
Related forms such as “bear” and “bears” are separate tokens, and the tokenizer itself does not ensure that their learned representations are similar.
What is an out-of-vocabulary problem in word-level tokenization?
A word encountered at inference time was not in the training vocabulary, so the model may lack a learned representation for it.
How does character-level tokenization divide text?
It represents text as individual characters, using a small, fixed set of character tokens.
What are advantages of character-level tokenization?
It keeps the vocabulary small and can handle unfamiliar or misspelled words and variations in casing using known characters.
What are disadvantages of character-level tokenization?
It creates much longer sequences, increasing computation, and individual character representations can be less interpretable than word representations.
What is subword tokenization?
A method that divides text into units smaller than words but often larger than characters, such as common word roots and letter sequences.
What is a key advantage of subword tokenization over whole-word tokenization?
Related words can share subword units, allowing the tokenizer to reuse information about common roots and reduce the need for a separate token for every word form.
What trade-off does subword tokenization involve?
It requires learning the tokenization scheme from data, so the resulting vocabulary depends on the corpus used to train the tokenizer.
What does BPE stand for, and what kind of tokenizer is it?
BPE stands for byte pair encoding; it is a subword-tokenization method.
How does BPE construct its vocabulary?
Starting from basic units such as characters, it repeatedly finds frequent adjacent pairs, adds merged pairs as tokens, and continues until the desired vocabulary size is reached.
How can BPE affect sequence length and computation?
Frequent combinations become single tokens, often shortening sequences and reducing the amount of computation needed to process them.
What should be considered when training a tokenizer for multilingual use?
Its training corpus should represent the languages of interest; otherwise, those languages may be split into longer sequences or represented less effectively.
What is the approximate vocabulary size of many modern LLM tokenizers?
On the order of hundreds of thousands of tokens.
What does an unknown token represent?
A piece of text that cannot be represented using the tokenizer’s available vocabulary.
What are beginning-of-sequence (BOS) and end-of-sequence (EOS) tokens used for?
BOS marks the start of generation, while EOS marks that generation is finished.
What is a padding token used for?
It makes sequences conform to a chosen length, which can help batch processing on hardware that handles uniform dimensions efficiently.
Are special-token spellings and conventions universal across models?
No. Special-token conventions vary, and tokens may also mark roles such as user or assistant.
What is a one-hot representation of a token?
A vector with a 1 at the token’s vocabulary index and 0s at all other indices.
Why are one-hot vectors poor representations of word meaning?
Different one-hot vectors are orthogonal, so their dot products do not express semantic similarity or relationships.
What property should useful token representations have?
They should encode meaningful relationships, so tokens with related meanings can have similar representations.
What is a proxy task in representation learning?
A training task used to learn representations that support a broader goal, even though the proxy task is not itself the final goal.
What proxy tasks are used by the two Word2Vec variants described?
Continuous bag of words (CBOW) predicts a target word from context words; skip-gram predicts surrounding words from a given word.
How can a simple neural network learn word representations from a next-word prediction task?
It maps an input token representation to a hidden, or latent, vector and then to probabilities over the vocabulary; a loss such as cross-entropy updates the weights to favor the correct target.
What are the dimensions of the input, hidden representation, and output in the simple word-prediction network described?
The one-hot input and vocabulary-probability output each have size V, the vocabulary size; the hidden representation has size D, typically smaller than V.
What can Word2Vec-style learned representations capture?
They can encode similarities and associations, such as related concepts and relationships like Paris-to-France and Berlin-to-Germany.
What is a limitation of Word2Vec-style static word representations?
A word receives the same representation in every context, even when its meaning changes, as with “bank” in “river bank” versus “go to the bank.”
Why do static word representations fail to encode word order?
They represent the same set of words alike even when the order changes, although word order can change sentence meaning.
How does an RNN incorporate information about earlier tokens?
It maintains a hidden state that summarizes the sequence seen so far and uses that state along with the current input when processing the next token.
What kinds of NLP tasks were RNNs used for?
They were used for tasks including text classification, token-level classification such as noun-versus-verb labeling, and text generation.
What is the long-range dependency problem in RNNs?
An RNN can have difficulty retaining information from far earlier in a sequence because its evolving hidden state compresses the past into a single vector.
What is an LSTM, and how does it address long-range dependencies?
A long short-term memory network is an RNN variant that maintains both a hidden state and a cell state intended to carry information for longer.
What deeper training issue is associated with long-range dependencies in RNNs?
The vanishing-gradient problem can make it difficult to propagate learning signals across long sequences.
Why can RNNs be slow to train or use for next-token prediction?
They process tokens sequentially, with each step depending on a hidden state computed from earlier steps.
What problem does attention address compared with relying only on an RNN hidden state?
It gives a token direct connections to relevant earlier tokens instead of requiring all past information to be retrieved only through a compressed hidden state.
What is self-attention?
A mechanism that computes each token’s representation as a function of tokens in the same sequence.
In attention, what is a query?
A representation used to determine which tokens are useful for constructing the representation of the token being processed.
In attention, what is a key?
A representation compared with a query to measure how relevant a token is to the token being processed.
In attention, what is a value?
The information from a token that is combined with other values according to attention weights.
How does attention combine information from tokens?
It compares a query with keys to produce relevance weights, then uses those weights to form a weighted sum of the corresponding values.
How are queries, keys, and values typically obtained from input embeddings?
Each input embedding is projected using learned matrices into query, key, and value representations.
What limitation would self-attention have if used without any positional information?
It would not know the tokens’ order or positions in the sequence.
What is the scaled dot-product attention formula?
Attention(Q,K,V)=softmax(dkQKT)V
What does the matrix product QKT represent in attention?
It produces query–key dot products, giving a similarity score for each query and key pair.
Why is softmax applied to attention scores?
It converts the scores into normalized weights that sum to 1 across the keys for each query.
Why are attention scores divided by dk?
The scaling helps control the variance of dot-product scores as the key dimension changes.
What is the role of the transformer encoder?
It computes contextual, meaningful representations of the input sequence, with each token representation informed by the sequence.
What is the role of the transformer decoder in machine translation?
It uses the encoder’s representations and the target tokens generated so far to produce the translation one token at a time.
What is the purpose of token embeddings in a transformer?
A learned lookup table maps each token to a numerical vector, initially representing the token itself rather than its full context.
Why are position embeddings added to token embeddings?
They provide information about each token’s position in the sequence, which attention alone does not supply.
What are two ways to represent positions in a transformer?
Position vectors can be learned, or they can be predefined using functions such as sine and cosine at different frequencies.
What is a limitation of learned position embeddings?
They may not represent positions beyond the range encountered during training.
What is a useful property of sinusoidal position representations?
Positions near one another tend to have similar representations, while positions far apart tend to be less similar.
What are the main components of a transformer encoder block described in the lecture?
A self-attention layer and a feed-forward neural network.
What does the encoder’s self-attention layer do?
It lets each input token representation incorporate information from other tokens in the input sequence.
What does the transformer feed-forward network contribute?
It projects representations through a higher-dimensional space and a nonlinear activation, enabling more complex transformations.
What does masked self-attention do in a decoder?
It lets each target token attend only to itself and earlier generated tokens, not to future tokens.
What does cross-attention do in the transformer decoder?
It lets decoder representations query the encoder’s representations; decoder states provide queries, while encoder outputs provide keys and values.
How does a transformer decoder generate a sequence?
It produces a probability distribution over the vocabulary for the next token, selects a token, feeds it back into the decoder, and repeats.
What does the final softmax in a transformer decoder represent?
A probability distribution over the vocabulary used to predict the next token.
When does autoregressive decoding stop?
It stops when the decoder produces an end-of-sequence (EOS) token.
In the attention projections, why must the query and key dimensions match?
The query–key dot products require matching dimensions; in the notation shown, dq=dk.
What are residual connections in a transformer?
Connections that add a layer’s input to its transformed output, allowing input features to pass through without being entirely rewritten.
How can residual connections help deep networks?
They support backpropagation and make it easier for layers to modify existing features rather than replace them completely.
What is layer normalization used for in a transformer?
It normalizes activations and can help the model converge during training.
What is dropout?
A training technique that randomly drops units with some probability so the model does not rely too heavily on particular features.
How can dropout improve a model?
By discouraging overreliance on specific features, it can help the model generalize better.
What is multi-head attention?
Attention computed through multiple learned query, key, and value projections, with the resulting heads combined into a shared representation.
What is the purpose of using multiple attention heads?
Different heads can learn different ways of relating tokens, analogous to using multiple filters in a convolutional network.
What is label smoothing?
A technique that softens the target distribution, assigning most probability to the correct token but leaving some probability for other vocabulary tokens.
Why can label smoothing help in language prediction?
It reflects that a sequence can have multiple valid continuations and can help models generalize and improve translation metrics.
How does a causal attention mask prevent a decoder from using future tokens?
It masks future-token connections, often with a triangular mask; masked scores can be set to negative infinity so their softmax weights become zero.
What are the two components identified as central to transformer capacity and learning?
Attention layers and feed-forward networks; the feed-forward networks contain a large share of the model’s parameters.

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