Qlaudia

← All courses

Large Language Models

  • Artificial Intelligence
  • Technology & Computing
  • Mathematics

Explore how language models learn to predict text at scale, developing broad knowledge of grammar, facts, and reasoning patterns. Discover the building blocks—tokenization, pretraining, alignment, and prompting—that shape how these systems work and behave.

Sign in to enroll$1034 lessons

What you'll learn

  • Next-Token PredictionThe training task where a model estimates a probability distribution over possible next tokens given a sequence of prior text, driving it to learn grammar, facts, reasoning, and style.
  • Few-Shot PromptingA technique where input-output example pairs are included in the prompt to demonstrate the desired task pattern, allowing the model to infer and replicate it on a new input.
  • Retrieval-Augmented GenerationAn architecture that provides a language model with access to external documents at generation time, shifting the model's task from recalling training data to reading and synthesizing retrieved information.
  • EmbeddingsA dense numerical vector that maps a token to a point in high-dimensional space such that relationships between concepts are preserved in that space.
  • PretrainingThe computationally intensive first phase of building a large language model where the model learns from an enormous text corpus to minimize prediction error across billions of next-token prediction tasks.
  • Fine-TuningThe process of continuing training a pretrained model on a smaller, focused dataset to steer its behavior toward a specific task or domain.
  • HallucinationThe tendency of large language models to generate fluent and confident text that is factually incorrect or unsupported by any real source.
  • Context WindowThe maximum number of tokens a language model can process at once, containing all visible text from system prompts, conversation history, documents, and the current input.
  • LLM AgentsA system where a language model actively plans, makes decisions, takes actions, and observes results in a goal-driven loop rather than responding passively to single queries.
  • Prompt EngineeringThe practice of deliberately designing text input to a language model to elicit higher-quality, more accurate, or more useful outputs by narrowing the space of possible responses.
  • LLM InferenceThe process of running a trained language model on new input to produce output, where the model's parameters remain frozen and no learning occurs.
  • Transformer ArchitectureA neural network design built around an attention mechanism that processes sequences of tokens in parallel, allowing each position to directly attend to every other position regardless of distance.
  • LLM APIs and DeploymentThe infrastructure and standardized interfaces that expose trained language model capabilities as network services accessible to developers and users.
  • AlignmentA set of techniques used after pretraining to shape a language model's behavior so it is helpful, honest, and unlikely to produce harmful outputs.
  • Tokens and VocabularyTokens are the basic indivisible units of text a model processes, and vocabulary is the fixed set of all possible tokens a model recognizes.
  • TokenizationThe process of converting text into discrete units called tokens that a language model can process, often using subword splitting rather than whole words.
  • Base Model vs. Chat ModelA base model is a pretrained next-token predictor, while a chat model is a base model further trained through alignment to behave as a helpful conversational assistant.
  • Tool Use and Function CallingA structured protocol that allows an LLM to request execution of external functions by returning special outputs indicating which function to call and with what arguments.
  • Model Parameters and ScaleThe numerical knobs in a neural network's weight matrices and bias vectors that encode everything the model has learned during training and determine its outputs.
  • Guardrails and Content FilteringAdditional safety mechanisms applied at inference time to detect and handle problematic inputs or outputs beyond what training-time alignment provides.
  • Instruction Fine-TuningThe supervised learning process that trains a pretrained model to recognize and respond appropriately to human instructions using curated instruction-response pairs.
  • System PromptsInstructions prepended to a language model conversation that configure the model's behavior, persona, and constraints throughout the interaction.
  • Chain-of-Thought PromptingA technique where a language model writes out intermediate reasoning steps before reaching a final answer, improving accuracy on multi-step problems.
  • Model Evaluation and BenchmarksThe systematic testing of language models on well-defined tasks using standardized metrics to measure performance across diverse capabilities like coding, reasoning, translation, and conversation.
  • Training Data and CorporaThe collection of text assembled from diverse sources like web crawls, books, Wikipedia, and code repositories that a language model learns from during pretraining.
  • Attention MechanismThe core operation in a transformer that allows each token to decide how much weight to give other tokens when computing its representation.
  • Prompt Injection and SafetyA class of attack where malicious input overrides or ignores a model's hidden system instructions by exploiting the lack of architectural separation between instructions and user data.
  • Reinforcement Learning from Human FeedbackAn alignment technique that trains a model on human preferences between responses rather than demonstrations, allowing it to optimize for subjective quality dimensions at scale.
  • Zero-Shot PromptingAsking a language model to perform a task with no examples provided, requiring it to rely entirely on its pretrained knowledge and understanding of the instruction.
  • Semantic SearchA search method that matches documents by conceptual similarity using numerical embeddings rather than exact keyword matching.
  • Temperature and SamplingParameters that control how a language model selects from its probability distribution over tokens, influencing randomness and creativity of generated text.
  • Reward ModelA neural network trained to predict human preference between LLM outputs, converting subjective response quality into a scalar score that drives reinforcement learning in RLHF.
  • GroundingThe practice of anchoring a language model's outputs to concrete, verifiable external sources so responses can be traced back to specific documents or data.
  • Vector DatabasesA data store purpose-built to efficiently find stored vectors most similar to a query vector by measuring proximity in high-dimensional space.

About this course

Large Language Models: A Map of the Territory

Large Language Models (LLMs) are AI systems that learn to understand and generate human language by training on enormous quantities of text. The name captures three key ideas: they work with language, they are models (mathematical systems that approximate some process), and they are large — both in the volume of data they consume and in the number of internal parameters they use to store what they've learned.

At their core, LLMs are surprisingly simple in objective: given a sequence of text, predict what comes next. Yet when this objective is pursued at massive scale — billions of words, billions of parameters, months of computation — the result is a system that develops a remarkably broad and nuanced grasp of language, facts, reasoning patterns, and even stylistic tone. The simplicity of the goal belies the sophistication of what emerges.

The Core Idea: Learning from Prediction

Every LLM starts with the same fundamental training task, called next-token prediction. A token is a small chunk of text — roughly a word or part of a word — and the model is trained to assign probabilities to what token should come next, given all the tokens before it. Mathematically, the model learns to approximate:

P(wt∣w1,w2,…,wt−1)P(w_t \mid w_1, w_2, \dots, w_{t-1})

where wtw_t is the next token and w1,…,wt−1w_1, \dots, w_{t-1} is the preceding context.

To do this well across billions of diverse sentences, the model must implicitly learn grammar, facts about the world, logical relationships, and much more. No one explicitly teaches it these things — they emerge as a side effect of learning to predict text accurately.

The Building Blocks

Understanding LLMs requires understanding a small set of interconnected ideas:

Tokenization is the first step in processing any text. Raw characters are grouped into tokens — the actual units the model reads and writes. How text is tokenized affects everything from what the model finds easy to what it finds unexpectedly difficult.

Pretraining is the large-scale initial phase of training, where the model is exposed to a vast corpus of text — web pages, books, code, and more — and learns general-purpose language representations through next-token prediction. This phase is computationally expensive and produces a model with broad knowledge but no particular disposition to be helpful.

Training data and corpora refers to the actual text used during pretraining. The scale, diversity, and quality of this data fundamentally shapes what the model knows and how it behaves. Biases, gaps, or errors in the data propagate into the model.

Alignment is the process of shaping a pretrained model's behavior so that it is helpful, honest, and safe. A raw pretrained model completes text — it doesn't help you solve problems. Techniques like Reinforcement Learning from Human Feedback (RLHF) use human judgments to steer the model toward responses people actually find useful.

Prompting is the art of communicating effectively with a deployed LLM. Because the model is sensitive to how questions are framed, techniques like few-shot examples (showing the model what good answers look like) and chain-of-thought reasoning (asking it to think step by step) can dramatically improve output quality without changing the model itself.

Retrieval-Augmented Generation (RAG) addresses a fundamental limitation: a model's knowledge is frozen at the time of training. RAG pipelines let a model query an external document store at inference time, pulling in fresh or specialized information before generating a response.

How the Pieces Fit Together

Training Corpora Web, books, code Tokenization Text → tokens Pretraining Next-token prediction Pretrained Model Raw text completer Alignment (RLHF) Human feedback → helpful model Deployed LLM Prompting + RAG

The LLM lifecycle: raw text is tokenized, used to pretrain a model, which is then aligned into a helpful assistant and deployed — where prompting and RAG govern its real-world behaviour.

Why Scale Changes Everything

Small language models trained on small datasets produce brittle, unimpressive results. Something qualitatively different emerges at large scale. Researchers have observed that certain capabilities — multi-step reasoning, translation between languages the model wasn't explicitly tuned on, solving math problems — appear almost suddenly once models cross certain size thresholds. These are called emergent capabilities, and they are one reason why the field moved so rapidly once compute and data became abundant.

The scaling relationship is often described empirically by scaling laws, which relate model performance to three factors: the number of model parameters NN, the size of the training dataset DD, and the amount of compute CC. Understanding these relationships helps researchers decide how to allocate resources when training a new model.

What LLMs Are and Aren't

LLMs are not databases. They do not store and retrieve facts verbatim — they compress statistical patterns from training data into a web of parameters. This means they can generalize and reason flexibly, but also that they can confidently produce plausible-sounding but incorrect statements (a phenomenon called hallucination).

LLMs are not reasoning engines in the classical sense either. They don't execute symbolic logic; they approximate the surface form of reasoning well enough that the outputs are often correct. Understanding this distinction is important for knowing when to trust a model and when to verify its output.

What they genuinely are is an extraordinarily effective interface between human intent expressed in natural language and a vast, compressed representation of human knowledge. Used well — with appropriate prompting, retrieval augmentation, and awareness of their limits — they are a genuinely new kind of cognitive tool.