Building Large Language Models
- 41Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is a large language model (LLM) at a high level?
41 questions
- 1
What is a large language model (LLM) at a high level?
Model answer
An LLM is a model of a probability distribution over sequences of tokens or words.
Explanation
The transcript defines language models as models of the probability P(x1,x2,...,xL) for a sequence of tokens. This is the fundamental definition.
- 2
How do autoregressive language models decompose the joint probability of a token sequence?
Model answer
They use the chain rule of probability: P(x1,x2,...,xL)=∏t=1LP(xt∣x1,...,xt−1).
Explanation
The transcript explains that autoregressive models factor the distribution as a product of conditional probabilities of the next token given all previous tokens, which is the chain rule.
- 3
What is the training objective for autoregressive language models?
Model answer
Minimizing cross-entropy loss by predicting the next token, which is equivalent to maximizing the log-likelihood of the training text.
Explanation
The transcript states that the loss is cross-entropy between the predicted distribution and the one-hot target of the actual next token, and minimizing this loss is equivalent to maximizing the log-likelihood of the text.
- 4
Explain why language models are considered generative models.
Model answer
Because once you have a model of a distribution, you can sample from it to generate new data, such as sentences.
Explanation
The transcript says language models are generative because modeling a distribution allows sampling, enabling generation.
- 5
What is the purpose of tokenization in large language models?
Model answer
To convert text into tokens that are more general than words, handle typos and languages without spaces, and keep sequences short enough for efficient computation.
Explanation
The transcript explains that tokenizers handle typos, languages like Thai, and keep sequence lengths manageable (each token ~3-4 characters) to avoid quadratic complexity in transformers.
- 6
Describe the byte-pair encoding (BPE) tokenization algorithm.
Model answer
Start with every character as a token. Repeatedly merge the most frequent adjacent pair of tokens into a new token until a desired vocabulary size is reached.
Explanation
The transcript outlines BPE: start with characters, find the most common pair, merge it, and repeat. It also notes that training is on a large text corpus, and during application, the longest possible token is chosen.
- 7
Why is pre-tokenization used in many tokenizers, and what does it do?
Model answer
Pre-tokenization handles spaces and punctuation separately for computational efficiency, preventing merges across spaces. It is a computational optimization, not a theoretical requirement.
Explanation
The transcript mentions that pre-tokenizers avoid merging across spaces to reduce the number of token pairs, making training faster; it is English-specific but optional.
- 8
What is perplexity and how is it computed?
Model answer
Perplexity is 2average per-token loss (or eaverage negative log-likelihood). It ranges from 1 to the vocabulary size.
Explanation
The transcript defines perplexity as exponentiated average loss, between 1 (perfect) and vocab size (random).
- 9
What does perplexity intuitively represent?
Model answer
The number of tokens the model is 'hesitating' between when predicting the next token.
Explanation
The transcript gives intuition: low perplexity (e.g., 10) means the model considers ~10 candidates; high perplexity (vocab size) means it has no preference.
- 10
Why is perplexity not used as the primary evaluation metric for academic benchmarking in modern LLMs?
Model answer
Because perplexity depends on the tokenizer (vocabulary size) and the evaluation data, making comparisons across different tokenizers and datasets inconsistent.
Explanation
The transcript states that perplexity depends on tokenizer choice (e.g., GPT-3 tokenizer vs Gemini tokenizer) and data, so it's used mainly for development, not academic benchmarks.
- 11
How are multiple-choice benchmarks like MMLU typically evaluated with language models?
Model answer
By computing the likelihood of each answer given the question and selecting the most likely one, or by constraining the model to output only the answer tokens and comparing likelihoods.
Explanation
The transcript explains two common methods: directly computing P(answer∣question) for each option, or prompting the model to choose A/B/C/D and comparing the likelihood of those tokens.
- 12
What challenge arises from using different evaluation methodologies for the same benchmark (e.g., MMLU)?
Model answer
Different methodologies can yield inconsistent results; for example, LLaMA 65B scored 63.7% on one evaluation but 48.8% on another.
Explanation
The transcript highlights that even for a fixed benchmark, different ways of measuring (e.g., scoring vs. prompting) give different numbers, causing confusion.
- 13
What is a clever trick to detect train-test contamination in language model evaluation?
Model answer
Compare the likelihood of the test set in the original order versus a randomized order; if the original order is more likely, contamination is suspected.
Explanation
The transcript describes this trick: since language models predict next tokens, if the test set appeared in training, the model will prefer the original sequential order over a shuffled one.
- 14
What is the first step in building a pre-training dataset from the internet?
Model answer
Download all of the internet (or a large crawl) using web crawlers like Common Crawl, which contains around 250 billion pages (~1 petabyte).
Explanation
The transcript mentions Common Crawl as a common source, with 250 billion pages and 1 petabyte of data.
- 15
What major challenges arise when extracting text from HTML pages for LLM training?
Model answer
Extracting math is very complicated, and boilerplate headers/footers repeat unwanted content.
Explanation
The transcript lists math extraction difficulty and boilerplate as challenges during text extraction from HTML.
- 16
How do companies filter undesirable content from pre-training data?
Model answer
They use blacklists of websites (NSFW, PII, harmful content) and may train a small classifier to identify PII.
Explanation
The transcript mentions blacklists and classifier-based filtering for undesirable content.
- 17
What is the purpose of deduplication in data processing, and what sources of duplication exist?
Model answer
To remove repeated content from headers/footers, different URLs pointing to the same website, and frequently duplicated paragraphs (e.g., from common books).
Explanation
The transcript describes deduplication to eliminate repetitions from various sources.
- 18
What is model-based filtering, and how does it work?
Model answer
Train a classifier to distinguish between high-quality documents (e.g., those linked from Wikipedia) and random web pages, then upweight the probability of high-quality data.
Explanation
The transcript explains that a classifier is trained on Wikipedia references vs. random web to select higher-quality content.
- 19
How do practitioners decide the mixture of different domains (e.g., code, books, entertainment) in pre-training data?
Model answer
They classify data into domains and then upweight or downweight certain domains (e.g., upweight code and books, downweight entertainment) based on observed improvements.
Explanation
The transcript gives examples: more code improves reasoning, books are beneficial, entertainment is downweighted. The exact weights can be tuned.
- 20
What is commonly done at the very end of pre-training to improve model quality?
Model answer
Train on a small, very high-quality dataset (e.g., Wikipedia, human-written data) with a reduced learning rate, essentially overfitting on that data.
Explanation
The transcript describes decreasing the learning rate and training on high-quality data like Wikipedia at the end.
- 21
What does a scaling law for large language models demonstrate?
Model answer
That increasing model size, data size, or compute consistently reduces test loss, and this relationship is log-linear.
Explanation
The transcript shows plots where test loss scales log-linearly with compute, data, and parameters, implying predictable improvements.
- 22
How are scaling laws used to decide hyperparameters before training a large model?
Model answer
Train smaller models of different sizes, fit a scaling law to extrapolate performance for a given compute budget, then train the final large model with the optimal configuration.
Explanation
The transcript explains the new pipeline: use smaller models to find scaling recipes (e.g., learning rate scaling) and then train the large model.
- 23
According to the Chinchilla paper, what is the optimal number of tokens per parameter for training efficiency?
Model answer
Approximately 20 tokens per parameter (i.e., the ratio of total training tokens to model parameters should be about 20:1).
Explanation
The transcript states the Chinchilla finding: for optimal training compute, use about 20 tokens for every parameter.
- 24
Why might companies train models with a higher tokens-to-parameters ratio (e.g., 150:1) than the Chinchilla optimal?
Model answer
Because inference cost matters: a smaller model with more data is cheaper to run over time, so they optimize for inference cost rather than pure training compute.
Explanation
The transcript mentions that inference-optimal ratio is around 150 tokens per parameter because smaller models cost less to serve.
- 25
Provide a back-of-the-envelope calculation for the total FLOPs required to train a model with P parameters on D tokens:
Model answer
FLOPs≈6×P×D.
Explanation
The transcript gives the formula: 6 times the product of the number of parameters and the number of tokens as an approximation.
- 26
What is the approximate cost to train LLaMA 3 400B (45B parameters) on 15.6 trillion tokens, based on $2/hour H100 rental?
Model answer
Approximately 52millionforcomputealone(26millionGPUhours),plusemployeesalaries,totalingaround75 million.
Explanation
The transcript walks through the calculation: 26M GPU hours at 2/hour=52M compute, plus ~25Mfor50employeesat500K/year, total ~$75M.
- 27
How do GPUs differ from CPUs in terms of architecture and optimization?
Model answer
GPUs prioritize throughput over latency, have many streaming multiprocessors for parallel execution, and are optimized for fast matrix multiplication.
Explanation
The transcript describes GPU characteristics: high throughput, many cores, and optimized for matrix operations.
- 28
What is Model FLOP Utilization (MFU) and why is it important?
Model answer
MFU is the observed throughput divided by the theoretical maximum FLOPs; it indicates how efficiently a GPU is used. Achieving 50% is considered good.
Explanation
The transcript gives MFU as a key metric, noting that even big companies like Meta achieve only ~45% MFU for LLaMA.
- 29
Explain the main idea behind mixed precision training for LLMs.
Model answer
Store weights in 32-bit but cast to 16-bit (FP16/BF16) for matrix multiplication, then update weights in 32-bit. This reduces memory and speeds up computation.
Explanation
The transcript describes automatic mixed precision: computation in 16-bit, accumulation/updates in 32-bit to maintain accuracy.
- 30
What is operator fusion and how does it improve performance?
Model answer
Combining multiple operations (e.g., two cosines) into a single kernel to reduce memory transfers between GPU global memory and compute units.
Explanation
The transcript explains that naively, each operation transfers data back and forth; fusion does all computation in one pass, significantly reducing communication.
- 31
Why is post-training alignment (such as RLHF) necessary for LLMs?
Model answer
Pre-trained language models model the distribution of internet text, which includes question lists and non-answer content; alignment makes them follow instructions and act as AI assistants.
Explanation
The transcript gives the example of GPT-3 completing a question with another question, not an answer, because it learned from data that one question often follows another.
- 32
What is supervised fine-tuning (SFT) and how does it work?
Model answer
Fine-tuning the pre-trained LLM on human-written instruction-response pairs using the same cross-entropy language modeling loss.
Explanation
The transcript states that SFT is language modeling on desired answers, with the same loss as pre-training but on human-provided data.
- 33
How is synthetic data generated for supervised fine-tuning, as in the Alpaca paper?
Model answer
Use a small set of human-written examples (175) to prompt a strong LLM (GPT-3) to generate many more instruction-response pairs (52,000), then fine-tune a smaller model on this synthetic data.
Explanation
The transcript describes Alpaca: using GPT-3 to expand a seed set of examples, creating a larger dataset for fine-tuning LLaMA 7B.
- 34
What surprising finding did the LIMA paper report about the amount of SFT data needed?
Model answer
Scaling from 2,000 to 32,000 examples did not significantly improve performance, suggesting SFT primarily teaches format, not new knowledge.
Explanation
The transcript cites LIMA: the model learns how to format answers but the knowledge comes from pre-training.
- 35
How can supervised fine-tuning contribute to hallucination in LLMs?
Model answer
If the human-written answer includes information not seen in pre-training, the model learns to generate plausible-sounding but factually incorrect content.
Explanation
The transcript explains that SFT may force the model to produce made-up references or facts because it wasn't present in the pre-training data.
- 36
What is the role of the reward model in RLHF?
Model answer
A classifier trained on human preferences that outputs a continuous score (logit) indicating which of two model responses is better.
Explanation
The transcript describes the Bradley-Terry model: train a reward model to predict the preference, and its logits provide a continuous reward signal.
- 37
How does Direct Preference Optimization (DPO) simplify RLHF?
Model answer
DPO directly maximizes the likelihood of preferred responses and minimizes the likelihood of dispreferred responses, without training a separate reward model or using reinforcement learning.
Explanation
The transcript presents DPO as a simpler alternative that replaces the PP pipeline with a single maximum-likelihood update on preference data.
- 38
Why can't perplexity or validation loss be used to evaluate aligned (post-trained) language models?
Model answer
Because alignment training (especially with RLHF) turns the model into a policy rather than a distribution estimator, so likelihoods are not meaningful or calibrated.
Explanation
The transcript explains that after PPO, the model no longer maximizes log-likelihood, so perplexity is not comparable.
- 39
How is the Chatbot Arena method used to evaluate aligned models?
Model answer
Random users chat with two anonymous models and pick the better response; aggregated over hundreds of thousands of comparisons, a ranking is derived.
Explanation
The transcript describes Chatbot Arena as a human evaluation benchmark using blind pairwise comparisons.
- 40
What is AlpacaEval and how does it work?
Model answer
An automated evaluation that uses GPT-4 to judge which of two model outputs is better, achieving 98% correlation with Chatbot Arena.
Explanation
The transcript presents AlpacaEval as an LLM-as-judge evaluator that is fast and cheap, with high correlation to human judgments.
- 41
What bias is commonly observed in LLM-based evaluators like GPT-4, and how can it be mitigated?
Model answer
They prefer longer outputs; this bias can be controlled by using regression analysis or other calibration tools.
Explanation
The transcript shows that making GPT-4 verbose increases its win rate artificially, but controlling for length removes much of the bias.

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