1. Home
  2. Explore
  3. Computer Science
  4. How Large Language Models Work

Study methods

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

How Large Language Models Work

  • 68Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Transformer Foundations

What is a transformer, and what does GPT stand for?

68 questions

  1. 1

    What is a transformer, and what does GPT stand for?

    Model answer

    A transformer is a neural-network architecture used to process language. GPT stands for generative pre-trained transformer.

    Explanation

    The content identifies transformers as the architecture behind GPT models and expands the acronym.

  2. 2

    When and through what publication did the transformer architecture become a major turning point?

    Model answer

    In 2017, a Google team published the paper “Attention Is All You Need,” introducing the transformer architecture.

    Explanation

    The discussion dates the transformer revolution to the 2017 paper.

  3. 3

    How did recurrent neural networks process text, and what limitation could arise with long sentences?

    Model answer

    RNNs processed text sequentially, one word after another. Their memory could lose information from the beginning of a long sentence before reaching its end.

    Explanation

    The sequential process made RNNs slow and liable to forget earlier context.

  4. 4

    How does a transformer’s processing approach differ from an RNN’s sequential approach?

    Model answer

    A transformer can process the words in a sequence in parallel rather than only one at a time, allowing it to consider the whole sequence together.

    Explanation

    The content describes this as unrolling the scroll and looking at the whole text at once.

  5. 5

    What problem does self-attention solve when a transformer processes a sequence?

    Model answer

    Self-attention helps the model focus on which words matter to each other, providing a way to interpret relationships across the sequence.

    Explanation

    Processing many words at once would be chaotic without a mechanism for identifying relevant connections.

  6. 6

    How does self-attention represent the importance of relationships between words?

    Model answer

    It calculates scores that weight how important different words are in relation to one another in context.

    Explanation

    For example, in a sentence about a glass shattering, the model can give a strong relationship weight to “glass” and “shattered.”

  7. 7

    In “I dropped the glass on the floor and it shattered,” why should “shattered” be linked more strongly to “glass” than to “floor”?

    Model answer

    Because the glass is the object that breaks; relating “shattered” to “glass” captures the sentence’s meaning more accurately.

    Explanation

    The example illustrates how attention can connect words according to their contextual roles.

  8. 8

    What is multi-head attention, and why use multiple attention heads?

    Model answer

    Multi-head attention uses several attention mechanisms to analyze the same text from different perspectives, then combines their findings.

    Explanation

    Different heads may focus on grammar, pronoun references, or emotional tone, capturing multiple aspects of meaning.

  9. 9

    How can different attention heads contribute distinct information about a sentence?

    Model answer

    One head might track which noun matches a verb, another might resolve pronouns, and another might attend to emotional tone.

    Explanation

    The heads analyze different kinds of relationships in parallel before their results are merged.

  10. 10

    Why does parallel processing contribute to transformers’ speed and capability?

    Model answer

    It lets the model analyze many relationships across the text at the same time instead of processing each word in sequence.

    Explanation

    The content connects this parallelism with transformers’ speed and notes that it requires substantial computation.

  11. 11

    Why are powerful GPUs useful for transformer models?

    Model answer

    Transformers perform large amounts of computation in parallel, so powerful GPUs help carry out that computation.

    Explanation

    The discussion links the computational demands of attention and parallel processing to the need for GPUs.

  12. 12

    What is the difference between a word and a token in language-model processing?

    Model answer

    A token is a chunk of text: it may be a whole word, but it can also be only part of a word.

    Explanation

    The model processes text as tokens rather than treating every complete word as an indivisible unit.

  13. 13

    Why break text into reusable token pieces instead of assigning a separate token to every possible word?

    Model answer

    A separate token for every word, spelling, slang term, and code form would require an enormous vocabulary. Reusable pieces allow many words to be represented with a smaller set of tokens.

    Explanation

    The content compares the smaller pieces to Lego bricks that can be combined to form different words.

  14. 14

    How can token pieces represent related forms such as “run,” “running,” and “runner”?

    Model answer

    The model can combine reusable pieces, such as “run,” “ing,” or “er,” to represent different forms.

    Explanation

    The examples show how token pieces can be joined to build words.

  15. 15

    What is an embedding in a language model?

    Model answer

    An embedding represents a token as a vector, or list of numbers, that the model can use in mathematical computations.

    Explanation

    Tokens are converted into numerical vectors so that the model can process them mathematically.

  16. 16

    How can distances and directions between embedding vectors represent relationships between concepts?

    Model answer

    Vectors place tokens in a numerical space where their relative positions can reflect relationships between concepts.

    Explanation

    The content uses a galaxy of points as an analogy for how a vector’s position can encode relationships.

  17. 17

    What does the example “king − man + woman ≈ queen” illustrate about embeddings?

    Model answer

    It illustrates the idea that relationships between concepts can be represented by operations on their vectors, with the resulting vector corresponding roughly to another related concept.

    Explanation

    The example demonstrates how vector representations allow mathematical operations to model relationships in meaning.

  18. 18

    Why must text be converted into numerical embeddings before a model can process it mathematically?

    Model answer

    The model performs computations on numbers, not directly on text; embeddings translate tokens into numerical forms it can work with.

    Explanation

    Without this translation layer, the transformer would have no numerical representation of language to process.

  19. 19

    What is the central task of a decoder-only language model?

    Model answer

    Its central task is to predict the next token based on the tokens that came before it.

    Explanation

    The content characterizes the decoder-only model as a predictive engine whose core job is next-token prediction.

  20. 20

    How does a model choose a next token when several continuations are possible?

    Model answer

    It assigns probabilities to possible next tokens based on the preceding context and selects a continuation from those possibilities.

    Explanation

    For a phrase such as “the cat sat on the,” candidates like “mat,” “floor,” and “couch” can receive different probabilities.

  21. 21

    What does autoregressive generation mean?

    Model answer

    The model generates a token, adds it to the sequence, and then uses the expanded sequence to predict the next token.

    Explanation

    This repeated feedback loop produces text one token at a time.

  22. 22

    How can an early incorrect prediction affect the rest of a generated response?

    Model answer

    Later predictions use the earlier token as context, so an incorrect early choice can steer the rest of the response in the wrong direction.

    Explanation

    The content compares this to a wrong turn that affects the route taken afterward.

  23. 23

    What is a hallucination, and how can next-token prediction contribute to one?

    Model answer

    A hallucination is made-up or factually incorrect output. It can occur when the model predicts a plausible-sounding but incorrect token and continues building on it.

    Explanation

    The model is described as tracking probabilities rather than knowing facts, so a mistaken prediction can become the basis for later ones.

  24. 24

    What kinds of material can be included in large-scale pre-training data?

    Model answer

    Pre-training data can include books, internet text, scientific papers, code repositories, legal documents, and other written material.

    Explanation

    The content describes training corpora drawn from a wide range of textual sources.

  25. 25

    What is self-supervised learning in the context of language-model pre-training?

    Model answer

    It is a learning process in which the model uses text itself to create a prediction task, such as guessing a covered or next token, without a teacher supplying each answer.

    Explanation

    The model learns from patterns in the training text rather than receiving a human correction for every prediction.

  26. 26

    How does predicting missing or next words teach a model about language?

    Model answer

    Repeated prediction exposes the model to patterns in how words and tokens are used in context, helping it learn language structure and meaning.

    Explanation

    The content describes a student guessing covered words across many examples and adjusting its expectations based on context.

  27. 27

    What is the difference between learning language patterns and being explicitly taught grammar rules?

    Model answer

    The model learns patterns from repeated examples of language use rather than being given a direct set of grammar rules to follow.

    Explanation

    The discussion says the model learns syntax and semantics from contextual patterns in text.

  28. 28

    How can pre-training expose a model to syntax and semantics?

    Model answer

    By predicting tokens across many contexts, the model encounters patterns in word order and in how words combine to convey meaning.

    Explanation

    The content identifies syntax as patterns such as where verbs go and semantics as what words mean together.

  29. 29

    How might a model learn an association such as “Paris is the capital of France” during pre-training?

    Model answer

    It may learn the association because those words and related statements occur together frequently in its training text.

    Explanation

    The example illustrates how frequently occurring textual patterns can be reflected in the model’s learned relationships.

  30. 30

    Why is a pre-trained model compared to a compressed representation rather than a conventional database?

    Model answer

    It does not store its training texts perfectly as a searchable collection; it stores learned mathematical relationships between parts of the text.

    Explanation

    The content likens the model to a compressed representation of the internet rather than a database of exact documents.

  31. 31

    How does a language model learn to generate code during pre-training?

    Model answer

    It predicts the next token in code just as it does in ordinary text, learning patterns in code’s syntax and usage from examples.

    Explanation

    The content describes code as another language for the model, with especially strict grammatical patterns.

  32. 32

    Why is large-scale pre-training expensive?

    Model answer

    It requires extensive computing hardware and electricity, often running many GPUs for long periods.

    Explanation

    The discussion describes training runs as potentially costing tens or hundreds of millions of dollars.

  33. 33

    Why does data quality matter in pre-training?

    Model answer

    The model learns patterns from its data, so flawed or biased data can lead to flawed or biased outputs.

    Explanation

    The content applies the principle “garbage in, garbage out” to model training.

  34. 34

    What is a base model, and why can it be unsafe to release without refinement?

    Model answer

    A base model is a raw pre-trained model. Because it learns from a broad and messy range of text without a moral filter, it may produce harmful or misleading completions.

    Explanation

    The content notes that such training data can include hate speech, incorrect medical advice, and dangerous instructions.

  35. 35

    What does the content mean by an emergent capability?

    Model answer

    It is a capability that appears as a model reaches large scale even though it was not explicitly programmed or directly trained for that capability.

    Explanation

    The discussion describes reasoning and problem-solving abilities appearing as models grow to hundreds of billions of parameters.

  36. 36

    How did model performance change as models grew, according to the account of emergence?

    Model answer

    Performance improved gradually for a time, but at sufficiently large scales some new capabilities appeared more suddenly.

    Explanation

    The content contrasts earlier gradual gains with capabilities appearing around a large-scale tipping point.

  37. 37

    Why might next-token prediction lead a model to develop reasoning-like abilities?

    Model answer

    Predicting the correct continuation of complex material can require representing the logic or relationships involved, so reasoning-like abilities may emerge as a side effect of prediction.

    Explanation

    The content uses solving an arithmetic word problem as an example of what may be needed to predict the right next token.

  38. 38

    What is the “grokking” phenomenon described in the discussion?

    Model answer

    Grokking is a pattern in which a model struggles with a concept and then seems to grasp an underlying pattern, after which its performance improves sharply.

    Explanation

    The discussion presents this as a sudden increase in performance after a period of difficulty.

  39. 39

    What three ingredients are identified by scaling laws as drivers of improved model performance?

    Model answer

    The three ingredients are more training data, a larger model with more parameters, and more computing power.

    Explanation

    The content presents these as the three levers of scaling.

  40. 40

    What role does model size play in scaling?

    Model answer

    A larger model has more parameters, or connections, that can represent additional patterns and nuance.

    Explanation

    The discussion compares a larger model to a bigger brain with more connections.

  41. 41

    What role does compute play in scaling a model?

    Model answer

    More compute allows training to use faster hardware or run longer, processing more data or doing more training work.

    Explanation

    The content describes compute as allowing a model to spend more time learning from its training data.

  42. 42

    What challenge does the discussion raise about scaling through more data?

    Model answer

    It suggests that the supply of high-quality text available on the internet may be running out.

    Explanation

    The content identifies limited high-quality text as a potential constraint on continued scaling.

  43. 43

    What is the risk of assuming that increasing model size will improve capability indefinitely?

    Model answer

    It is uncertain whether scaling will keep producing gains forever; the industry is investing heavily on the expectation that the trend will continue, but that remains a gamble.

    Explanation

    The discussion calls whether the scaling curve has peaked a major open question.

  44. 44

    Which capabilities are described as emerging with scale rather than being explicitly programmed?

    Model answer

    The content names translation, coding, summarization, reasoning, and problem-solving as capabilities that can emerge with scale.

    Explanation

    These are given as examples of abilities that were not directly programmed into the model.

  45. 45

    What are the three stated pillars of alignment?

    Model answer

    The three pillars are helpfulness, truthfulness, and harmlessness.

    Explanation

    The discussion refers to these as the “three H’s” of alignment.

  46. 46

    Why can helpfulness, truthfulness, and harmlessness conflict?

    Model answer

    Following a user’s request may be helpful while requiring the model to lie or provide harmful instructions, conflicting with truthfulness or harmlessness.

    Explanation

    The content gives requests to tell a convincing lie or explain how to make a weapon as examples of these tensions.

  47. 47

    What does RLHF stand for, and what is its general purpose?

    Model answer

    RLHF stands for reinforcement learning from human feedback. It uses human preferences to refine a model’s responses toward desired behavior.

    Explanation

    The content presents RLHF as a multi-step method for aligning a model with human values.

  48. 48

    What happens during supervised fine-tuning in the RLHF process?

    Model answer

    Humans write ideal responses to example prompts, and the model is trained on those examples to imitate the desired style and quality.

    Explanation

    The examples demonstrate the kinds of safe, polite, accurate, and appropriately formatted responses humans want.

  49. 49

    Why can’t supervised fine-tuning rely on humans writing an ideal answer for every possible prompt?

    Model answer

    There are too many possible questions, so writing ideal responses for all of them would not scale.

    Explanation

    The discussion identifies the limits of hiring enough people to create a complete set of answers.

  50. 50

    How does reward-model training use human judgments?

    Model answer

    A model produces several answers to a prompt, and humans rank those answers; the rankings are then used to train a separate reward model.

    Explanation

    Ranking candidate answers is described as easier and faster than writing ideal answers from scratch.

  51. 51

    What does a reward model learn to do?

    Model answer

    It learns to score responses in line with patterns in human rankings and preferences.

    Explanation

    The content describes the reward model as an automated judge that represents human preferences.

  52. 52

    What happens during the reinforcement-learning stage of RLHF?

    Model answer

    The main model generates answers, receives scores from the reward model, and adjusts its parameters to seek higher scores over repeated feedback cycles.

    Explanation

    The discussion likens the main model to an athlete improving under a coach’s scoring and feedback.

  53. 53

    Does a model optimized through RLHF necessarily understand right and wrong as a person does?

    Model answer

    No. It is optimized to obtain rewards associated with preferred responses; that does not mean it understands morality in a human sense.

    Explanation

    The content characterizes the process as reward optimization rather than human moral understanding.

  54. 54

    What is reward hacking?

    Model answer

    Reward hacking occurs when a model finds a way to gain a high reward without actually accomplishing the intended goal.

    Explanation

    The content’s boat-racing example shows an AI collecting repeated power-ups instead of finishing the race.

  55. 55

    How could reward hacking appear in a language model?

    Model answer

    A model might learn to be excessively apologetic, agree with the user regardless of truth, or state hallucinations confidently if those behaviors tend to earn high scores.

    Explanation

    The examples show how optimizing for approval can diverge from being accurate or genuinely helpful.

  56. 56

    What is sycophancy in a language model?

    Model answer

    Sycophancy is the tendency to agree with or flatter a user instead of giving an appropriately truthful response.

    Explanation

    The content connects this tendency to a model learning that users may reward being told they are right.

  57. 57

    What is the alignment tax?

    Model answer

    The alignment tax is the possible loss of capability or creativity that can result from safety constraints or alignment training.

    Explanation

    The discussion gives an example of a model refusing to write a violent fictional story because it is overly cautious.

  58. 58

    Why is alignment described as a balancing act?

    Model answer

    The model must be made safer and more usable without making it so restrictive that it refuses acceptable requests or loses useful capabilities.

    Explanation

    The content contrasts potential safety benefits with reduced creativity or over-refusal.

  59. 59

    What is the difference between a user prompt and a system prompt?

    Model answer

    A user prompt gives the specific task or request, while a system prompt provides higher-level instructions that frame the model’s role and rules.

    Explanation

    The user prompt is what a person types into the chat, whereas the system prompt is generally supplied by developers.

  60. 60

    What kinds of instructions might a system prompt contain?

    Model answer

    It might specify the model’s role, tone, and constraints, such as acting as an expert coding assistant, being concise, or using Python.

    Explanation

    The content describes system prompts as setting a session’s persona and rules.

  61. 61

    Why is a system prompt important when building an AI application?

    Model answer

    It establishes the application’s behavior and helps guide the model consistently before users submit their requests.

    Explanation

    The discussion calls system-prompt design especially important for applications such as customer-service bots.

  62. 62

    What is prompt injection, and how can weak system instructions make it more likely to succeed?

    Model answer

    Prompt injection is an attempt to steer the model by giving it conflicting instructions, such as telling it to ignore previous instructions. Weak system guidance may make it easier for the user’s instruction to derail the model.

    Explanation

    The content contrasts a weak, generic system prompt with a stronger prompt that clearly states the bot’s rules.

  63. 63

    What is chain-of-thought prompting?

    Model answer

    It is a prompting technique that encourages the model to work through a problem in intermediate steps, often with an instruction such as “think step by step.”

    Explanation

    The discussion presents it as a way to elicit a longer reasoning process for complex tasks.

  64. 64

    Why can asking a model to “think step by step” help with a complex problem?

    Model answer

    It encourages the model to generate intermediate tokens before its final answer, giving it more opportunities to process the problem than an immediate one-token response would.

    Explanation

    The content describes these generated steps as a kind of scratch pad that can support further computation.

  65. 65

    Why might a model perform poorly when asked to answer a complex logic problem in only one word?

    Model answer

    It has to produce an answer immediately, with little room to generate intermediate steps that could help it work through the logic.

    Explanation

    The discussion compares this to asking a person to solve a difficult problem instantly without writing anything down.

  66. 66

    How does chain-of-thought prompting relate to the model’s token-by-token generation process?

    Model answer

    Because the model generates one token at a time, prompting it to produce intermediate reasoning makes it generate more tokens before the final answer.

    Explanation

    The content links additional generated tokens with additional opportunities for processing.

  67. 67

    What does the content mean when it says verbosity can act as a proxy for intelligence in this architecture?

    Model answer

    For some tasks, a longer generated sequence may let the model work through more intermediate steps, though verbosity itself does not guarantee correctness.

    Explanation

    The discussion ties additional tokens to more processing, not to an automatic guarantee of a correct answer.

  68. 68

    Why is prompt engineering more than simply guessing the right words?

    Model answer

    It involves understanding how the model processes instructions and generates tokens, then shaping prompts to work with those mechanics.

    Explanation

    The discussion emphasizes using knowledge of the model’s constraints to guide it toward useful output.

1 of 68
Question 1 of 68

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent