Large language models have transformed how we interact with technology, enabling machines to understand and generate human-like text with remarkable fluency. These powerful AI systems underpin tools like ChatGPT and are reshaping education, business, and creative work. In this lesson, you will learn what large language models are, how they work, and how to use them effectively in everyday tasks.

Large Language Models: What You’ll Learn
This lesson traces large language models from their origins in AI research to the neural networks that power them today, covering how they process language and generate responses. You will also meet the practical concepts that shape everyday use, including tokens, context windows, and temperature settings, which together determine the quality of the results large language models produce.
What Is Artificial Intelligence?
Artificial intelligence, or AI, is the field of computer science focused on building systems that perform tasks normally requiring human intelligence, such as recognising images, understanding speech, and processing natural language. The concept has existed for decades, but recent breakthroughs in computing power and data availability have accelerated progress enormously. AI is a collection of approaches rather than a single technology: some systems follow explicit rules programmed by humans, while others learn patterns from large datasets. That second category, machine learning, is where large language models live, and within it a subfield called deep learning uses neural networks with many layers that learn complex patterns, which is why large language models are built from deep learning architectures designed for text.
From Narrow AI to General Intelligence
It is important to distinguish narrow AI from artificial general intelligence. Narrow AI, which includes all current large language models, is designed to excel at specific tasks, so a model can write essays or answer questions but cannot drive a car or cook a meal without specific training. Artificial general intelligence, by contrast, would match or exceed human capabilities across all domains and remains a theoretical goal. Today’s large language models are among the most advanced narrow AI systems ever built, but they are specialised tools rather than thinking beings.
What Are Large Language Models?
Large language models are AI systems trained to understand and generate human language by analysing vast amounts of text and learning the statistical relationships between words, phrases, and sentences. When you type a prompt into ChatGPT, the large language model behind it predicts what text should come next based on patterns learned during training. The word “large” refers to both the size of the training dataset and the number of parameters in the model, the internal values adjusted during training to improve predictions. Modern large language models contain billions or even trillions of parameters, allowing them to capture nuanced patterns in language.
Large language models do not truly “understand” language the way humans do. Instead, they recognise statistical regularities: after seeing the phrase “once upon a” millions of times during training, the model learns that “time” is a likely next word. This predictive capability, scaled across enormous datasets, produces surprisingly coherent and useful output.
How Large Language Models Differ from Traditional Software
Traditional software follows explicit instructions written by programmers, so if you want a program to sort a list, you write step-by-step logic for sorting. Large language models work differently: instead of being told the rules, they discover patterns from data, which makes them far more flexible but also less predictable. They can handle open-ended requests that would be impossible to program with rigid rules, but they can also make mistakes that rule-based systems would avoid.
A Brief History: From n-grams to Transformers
Large language models are the latest step in a seventy-year effort to teach machines human language, and each generation solved a real limitation of the one before it. The earliest models were n-gram systems that predicted the next word using only the frequency of short word sequences seen before, so a three-gram model had no memory beyond the previous two words and could not track long-range context. Through the 1990s and 2000s, researchers built increasingly sophisticated alternatives: statistical machine translation, word embeddings such as word2vec, and recurrent neural networks like the Long Short-Term Memory variant, which carried a hidden state forward token by token and finally let a model remember context from many steps earlier.
The wall recurrent models hit was training speed, because they processed tokens one at a time and so could not use modern parallel hardware efficiently. A 2014 breakthrough called seq2seq with attention let a decoder look back at specific parts of the input while generating each output word, and in 2017 the paper “Attention Is All You Need” removed the recurrence entirely, leaving only the attention mechanism. That architecture was named the transformer, and every major large language model in production today is built on it. Once the transformer existed, researchers found that given enough data and compute the same architecture kept improving predictably as you added parameters, an observation now called a scaling law, which is why the field calls these systems large language models rather than just language models.
Parameters, Scale, and What “Large” Really Means
The word “large” in large language models refers to three quantities that grow together: the number of parameters in the model, the amount of training data it has seen, and the compute used to train it. A parameter is a single number the model adjusts during training, and modern large language models hold billions or trillions of them, each a tiny knob set so that predictions match the training data. It is tempting to assume more parameters means a smarter model, but a model with ten times as many parameters also needs roughly ten times as much high-quality data to reach its potential; train a huge model on a small dataset and it memorises, train a small model on a vast dataset and it under-fits. The 2022 Chinchilla result suggested roughly twenty tokens of data per parameter for best efficiency, which is why the best large language models are fed enormous, carefully filtered text corpora.
Scale is also what unlocked the most surprising property of large language models, the emergent capabilities the models were never explicitly trained to perform. Below a certain size a model can barely summarise a paragraph, but above it the same architecture suddenly translates, writes working code, and answers trivia without a separate training phase for each task. For you as a user, the practical takeaway is that “large” is not marketing: it is the reason one model can draft a contract, debug Python, and tutor a child on fractions while another, built only a few years earlier, could barely hold a conversation.
Embeddings and the Meaning of Words
Before a transformer can do anything useful with a word, it has to turn that word into numbers. The first step is an embedding, a list of thousands of numbers that represents the word’s meaning, where words that appear in similar contexts end up with similar embeddings. The classic demonstration turns word relationships into geometry: take the embedding for “king”, subtract “man”, add “woman”, and the nearest neighbour is very close to “queen”, showing the model has learned that the relationship between “king” and “queen” parallels that between “man” and “woman”.
Embeddings matter for two reasons. They let large language models handle synonyms and paraphrase without explicit rules, because “happy”, “pleased”, and “glad” sit near each other and behave similarly at inference time, and they are the foundation of semantic search and retrieval-augmented generation, where a system looks up relevant passages and hands them to the model as context. Understanding embeddings also clarifies why large language models sometimes confuse near-synonyms: modern models use contextualised embeddings, where the vector for a word shifts depending on its sentence, which is one of the things attention makes possible.
Inside the Attention Mechanism
The attention mechanism is the heart of a transformer, and a rough sense of how it works makes large language models much less mysterious. When the model processes a sentence, attention lets each token look back at every earlier token and decide how much each one matters for its own meaning. The mechanism produces three derived vectors per token, the query, the key, and the value: a token’s query is compared against every other token’s key to produce a relevance score, and those scores mix the corresponding values together.
Imagine each word in a sentence is a person in a room holding one sign describing what they offer, the key, and another describing what they seek, the query. Each person walks around comparing their query to everyone else’s key, and where two signs match well that pair exchanges information carried in their value sign. Transformers run many of these attention steps in parallel as attention heads and stack dozens of rounds into layers, so one head tracks grammar, another tracks names, and another tracks numbers, all on the same sentence. Stacking layers lets the model build meaning hierarchically, from words to phrases to whole paragraphs, which is why large language models can follow ideas across a long passage.
The other reason attention won is efficiency. Because every token can be compared with every other in a single matrix operation, the whole step runs easily on the parallel hardware modern AI depends on, which gave large language models both better context handling and faster training and made scale affordable.
Neural Networks: The Engine Behind Large Language Models
Neural networks are the computational structures that power large language models. Inspired loosely by the human brain, a neural network consists of layers of interconnected nodes called neurons, where each connection has a weight that determines how strongly one neuron influences another and these weights are adjusted during training so the network produces better outputs. A typical network has an input layer, one or more hidden layers, and an output layer: data enters through the input, flows through the hidden layers where transformations occur, and exits as a prediction. The depth of those hidden layers is what gives deep learning its name.
Large language models use a specific neural network architecture called the transformer, which processes text in parallel rather than sequentially and so trains far more efficiently than earlier designs. The self-attention mechanism lets each token attend to every other token regardless of position, which is why large language models can handle long-range dependencies in text. Virtually every major large language model today, from OpenAI’s GPT series to Google’s Gemini, is built on this transformer architecture.
Training vs Inference: Two Critical Phases
Every large language model goes through two distinct phases: training and inference. Training is the process of building the model by exposing it to enormous datasets of books, articles, and websites, then adjusting its parameters through repeated iterations so it gets better at predicting the next word in a sequence. This phase requires massive computational resources, can take weeks or months on clusters of specialised hardware like GPUs, and can cost millions of dollars for the largest models; once it ends the parameters are fixed.
Inference is the phase where the trained model is actually used: when you send a prompt to ChatGPT, the model takes your input, processes it through its neural network, and generates a response. Understanding the difference between training and inference helps you set realistic expectations, because a large language model cannot learn new information during inference and its knowledge is frozen at the point training ended. This is why models can have outdated information, why fine-tuning is sometimes used to update them, and why they sometimes produce confident but incorrect answers drawn from patterns rather than real-time lookup.
The Training Pipeline: Pretraining, Supervised Tuning, and RLHF
The jump from a raw large language model to a polished assistant like ChatGPT is not a single training run but a pipeline of stages, each of which shapes behaviour differently. The first stage is pretraining, in which the model reads enormous amounts of text and learns to predict the next token; a freshly pretrained model is a remarkable text-completer but a poor conversationalist, and pretraining is by far the most expensive stage. The next stage is supervised fine-tuning (SFT), where humans write thousands of ideal question-and-answer pairs and the model learns to imitate them, which is comparatively cheap because it builds on patterns the pretrained model already knows.
The third stage is reinforcement learning from human feedback (RLHF): raters compare two or more model responses to the same prompt, a small reward model is trained on those comparisons, and the main model is fine-tuned to maximise that reward. RLHF aligns large language models with human preferences for helpfulness, honesty, and safety, and it is where most subtle behaviour tuning happens, such as refusing dangerous instructions while staying useful. Many production systems add further stages like safety classifiers, tool-use training, and region-specific tuning, so the politeness, refusals, and careful hedging you observe are products of these later stages rather than the raw pretrained model.
Tokens: How Large Language Models Read Text
Large language models do not process text word by word; they break it into smaller units called tokens, which can be a whole word, a part of a word, or even a single character. The word “hamburger” might split into “ham,” “bur,” and “ger,” with common words usually kept whole and rare or complex words split apart. Tokenisation affects both cost and performance, because when you access large language models through an API you are typically charged by the number of tokens processed, so understanding tokens helps you write efficient prompts and manage costs.
import tiktoken
# Load the tokenizer used by GPT models
enc = tiktoken.encoding_for_model("gpt-4")
# See how text becomes tokens
text = "Large language models are fascinating."
tokens = enc.encode(text)
print(f"Text: {text}")
print(f"Tokens: {tokens}")
print(f"Token count: {len(tokens)}")
# Decode tokens back to text
decoded = enc.decode(tokens)
print(f"Decoded: {decoded}")
You can see from this example that a single sentence becomes multiple tokens, and the mapping between tokens and text is not always intuitive. A useful rule of thumb is that one token corresponds to roughly four characters of English text, or about three-quarters of a word, so a 1,000-word essay contains roughly 1,300 tokens. Token limits matter because every large language model has a maximum number of tokens it can process in a single request, which leads to the next concept: context windows.
Context Windows in Large Language Models
The context window is the maximum amount of text a large language model can consider in a single interaction, including both your input prompt and the model’s generated response. Think of it as the model’s short-term memory: within the window the model can reference everything said, but once the conversation grows beyond the limit the earliest content falls out of scope. This is why providing relevant context upfront, rather than burying it in a long conversation, leads to better results from large language models.
Different large language models have different context window sizes. Early models handled only a few thousand tokens, while modern models support tens of thousands or even millions, enabling analysis of long documents, code repositories, and extended conversations. To get the best results, keep your context window focused on relevant information: avoid pasting long documents when a concise excerpt will do, and include specific facts in your prompt rather than hoping the model will recall them.
Temperature: Controlling Creativity in Large Language Models
Temperature is a parameter that controls how random or deterministic a large language model’s output is, by adjusting the probability distribution over possible next tokens. A low temperature makes the model more likely to choose the highest-probability token, producing focused and consistent output, while a high temperature introduces more randomness for creative but less predictable results. A temperature of zero means the model always picks the most likely next token, which is ideal for factual tasks, coding, and analytical work where consistency matters.
Temperature guide for large language models:
0.0 - Fully deterministic; best for code, math, factual Q&A
0.3 - Low randomness; good for summaries, structured output
0.7 - Balanced; good default for general conversation
1.0 - More creative; good for brainstorming, storytelling
1.5+ - Highly random; experimental, often incoherent
Choosing the right temperature depends on your goal: for technical work with large language models a low temperature ensures reliable, repeatable answers, while for creative writing or idea generation raising it produces more varied results. Most ChatGPT users never adjust temperature manually because sensible defaults are built in, but if you access large language models through an API, start with the default and adjust gradually, since small changes can noticeably affect output quality.
How ChatGPT Works
ChatGPT is an application built on top of a large language model. When you type a message, your text is tokenised and sent to the model, which processes your tokens through its transformer layers using attention to understand context and intent, then generates a response token by token with each new token influenced by everything before it. The model does not plan its full response in advance; it predicts the most likely continuation at each step until it produces a stop token or reaches a length limit, yet the results usually appear coherent and well-structured.
ChatGPT also includes additional training beyond the base large language model. The reinforcement learning from human feedback process described earlier aligns responses with human preferences, and behind the scenes the system applies a system prompt, may retrieve relevant information, formats your input, and applies safety filters, all in seconds. For a deeper dive, you can explore the official OpenAI documentation on GPT models, which covers these concepts in greater technical detail.
Hallucinations: Why Large Language Models Invent Things
The most important limitation to understand about large language models is hallucination, the tendency to produce fluent, confident statements that are simply wrong. Hallucinations are not bugs but a direct consequence of how the models work: a large language model is a next-token predictor trained to produce plausible-sounding text, and plausibility is not the same as truth. The model has no built-in way to check whether its words match reality, so when it does not know a fact it still produces the most likely-sounding continuation, which reads as confidently as a correct answer because the model has been trained on fluent human writing.
Certain patterns trigger hallucinations more than others. Asking for a specific citation, a precise number, or a biographical detail about a less-famous person raises the chance of an invented answer, because the model is being asked to retrieve a narrow fact from a statistical predictor rather than a database. Demanding “and what else?” repeatedly, or asking for something authoritative that does not exist such as a fake reference, are other common triggers. The practical defence is to treat every factual claim from a large language model as a draft, not a verdict: for anything that matters, verify against a trusted source, since many hallucinations are caught by a single web search. The goal is to trust large language models the way you would trust a knowledgeable colleague who occasionally misremembers details, useful for first drafts and explanations but never the final word on a load-bearing fact.
Capabilities Landscape in 2026
Large language models in 2026 are no longer text-only tools. The same core idea, a transformer trained to predict the next token, now spans text, code, images, audio, and tool use, often inside a single model. On the text side, the major advance is reasoning models trained to spend more compute thinking before they answer, producing an internal chain of thought that improves performance on hard problems like multi-step mathematics and competitive programming; they are slower and more expensive, so reach for them where correctness matters more than speed and use faster defaults for everyday writing.
Most major large language models now accept images and audio as input alongside text, so you can upload a whiteboard photo for cleaned-up notes or hand the model an error screenshot for a fix. Tool use is the third broad capability: a large language model can call external systems to run a web search, execute code, browse a database, or send an email, and weave the results into its answer, which turns the model from a static knowledge base into an agent. The practical takeaway is that the question is rarely whether a large language model can do something, but which capability to engage, a chat answer for a quick explanation, a reasoning model for hard analysis, an image upload for a visual question, or a tool-using agent for a multi-step task.
A Worked Example: From Prompt to Token
Let us trace what happens when you send a prompt to a large language model. Imagine you type “Explain what a neural network is in one paragraph” into ChatGPT; this simple sentence triggers a pipeline that turns your words into a response. First, the text is tokenised into a sequence of numeric tokens that each map to an entry in the model’s vocabulary, where “Explain” might be a single token while “neural” could be split. These tokens are then converted into high-dimensional vectors called embeddings, where similar words have similar vectors, and the transformer layers process them with self-attention to build a contextual understanding of your entire prompt.
Now the model begins generating output, predicting the most probable next token given everything it has processed so far and adding each predicted token back into the sequence. Each new token is chosen from a probability distribution shaped by the model’s training and the current temperature, so a low temperature yields a clear, direct explanation while a higher one might take creative liberties with analogies. Generation continues token by token until the model emits a stop signal or reaches the maximum length, and the tokens are decoded back into human-readable text in your chat interface, typically within a few seconds for a paragraph-length response.
A Second Look: Multi-turn Conversations and Building Context
Real use of large language models is rarely one-shot; most value comes from multi-turn conversations where you and the model build shared context across several exchanges. Imagine you open a fresh chat and write “I am planning a three-day trip to Lisbon for a family of four with two young children”; the model tokenises your message, runs it through the transformer, and produces a response with mechanics identical to the single-prompt case. The difference emerges on your second turn, when you type a follow-up such as “give me a kid-friendly version of day two”: the chat application does not send only that new sentence, but the entire conversation so far, your original message, the model’s first reply, and your new instruction, all as one long input.
This is what “memory” inside a conversation actually is, since the model is not quietly remembering anything between turns; instead the application re-sends the full transcript each time so the model can re-read it. The benefit is that the model can refer back to “the family of four” or “day two” without you restating those facts, because they are in its input, and the cost is that every turn grows the prompt, which is why very long conversations eventually push old messages out of the context window. Two practical patterns follow: start a fresh chat for an unrelated topic so old messages do not distract the model, and when a long conversation starts to drift, summarise the key decisions and paste them into a new chat rather than continuing in the old one.
How Researchers Evaluate Large Language Models
If you read that a new large language model “scores 85% on a benchmark”, it is worth knowing what that number measures. Standard benchmarks are fixed question sets that test a specific capability: MMLU covers broad academic and professional knowledge, HumanEval asks the model to write small programs and checks whether they pass tests, and GPQA tests reasoning at the level of a trained specialist. Benchmarks are cheap and easy to compare, which is why every release quotes them, but they have a known weakness: once public, future models may have seen the questions during training, which inflates scores without improving real capability.
Human evaluation addresses that weakness by paying people to rate real conversations, and a common method called chatbot arena presents two anonymous models answering the same prompt and asks a human judge which is better. Aggregated across thousands of matchups this tracks real-world usefulness better than any single benchmark, though it is costly, subjective, and shaped by the prompts the audience submits. Open-ended or “vibe” evaluation, what you do when you try a new model on the tasks you care about, is the most relevant test for any individual user; a healthy habit is to treat benchmarks as a first filter and your own hands-on testing as the deciding factor when you choose among large language models.
Open and Closed Large Language Models
The large language model ecosystem in 2026 splits into two broad camps. Closed models such as OpenAI’s GPT, Anthropic’s Claude, and Google’s Gemini are accessed through official apps and APIs, and their weights are kept private; you send a prompt, receive an answer, and the company handles the inference. Open, or open-weight, models publish the trained parameters so anyone can download and run them, with prominent families including Meta’s Llama, Mistral, and Qwen; running one yourself requires suitable hardware, but in exchange you can fine-tune on private data without sending it anywhere, audit the model, and serve it without per-token fees.
Each approach has clear trade-offs: closed models tend to be the most capable per query because their builders pour enormous compute into every release and handle safety and scaling, while open models give privacy, customisability, and independence from any vendor at the cost of doing more engineering yourself. For most readers the practical choice is simple: if you are learning to use large language models, start with a polished closed product like the ChatGPT account you will set up in the next lesson, because it removes every obstacle between you and a working tool. If you later need to run models on private data or study how they behave, the open ecosystem and the concepts you learn here will both transfer directly.
Large Language Models: Common Mistakes to Avoid
Working with large language models is powerful, but certain pitfalls can undermine your results and lead to frustration or misinformation. The four mistakes below are the ones new users encounter most often, so recognising them early saves time and prevents avoidable errors.
- Treating output as fact. Large language models can produce convincing but incorrect information. Always verify important claims with trusted sources before acting on them.
- Ignoring context limits. Stuffing too much text into a prompt can cause the model to miss key details. Keep your inputs focused and relevant.
- Overcomplicating prompts. Long, convoluted instructions often confuse the model. Clear, direct prompts yield better results from large language models.
- Expecting real-time knowledge. Models are trained on data up to a certain point. They cannot access current events unless connected to live data sources.

Large Language Models: Best Practices
- Write clear, specific prompts with all necessary context for better results.
- Start simple, then iterate based on the quality of responses you receive.
- Use low temperature for factual tasks and higher values for creative work.
- Break complex requests into smaller steps the model can handle sequentially.
- Always verify critical information from large language models against reliable sources.

Large Language Models: Frequently Asked Questions
What is a large language model?
It is a neural network trained on massive amounts of text to predict and generate language. Models like the one behind ChatGPT learn statistical patterns well enough to write, summarize, and answer questions in natural language.
How do tokens and the context window affect what it can process?
Text is broken into tokens before processing, and every model has a fixed context window limiting how many tokens it can consider at once. Once a conversation exceeds that window, earlier content starts falling out of view.
What does the temperature setting control?
Temperature controls how much randomness goes into generated text. Lower values produce focused, predictable output suited to factual tasks, while higher values add variety and creativity at the cost of consistency.
Why can these models produce confidently wrong answers?
They generate the statistically likely next words, not verified facts, so they can state incorrect information with the same fluent confidence as correct information. Always verify important outputs independently rather than trusting tone alone.
How is ChatGPT related to this technology?
ChatGPT is a product built on top of a large language model, adding a chat interface, memory, and safety layers around the underlying model so people can interact with it conversationally rather than through raw API calls. Every concept in this lesson, from tokens and context windows to temperature, applies directly to how ChatGPT receives and answers your messages.
Large language models represent one of the most significant advances in artificial intelligence, transforming how we create and interact with text. By understanding how these models work, you can use them more effectively and avoid common pitfalls.