AI and Data • Large language models • 6 min read

What Is an LLM (Large Language Model)?

Summary

A large language model (LLM) is a neural network trained on very large amounts of text to predict the next piece of text, called a token. By repeating that prediction one token at a time, it can write, summarize, translate, answer questions, and generate code. It produces likely text, not verified facts, so its output can be wrong.

What an LLM is

A large language model, or LLM, is a type of machine learning model built to work with text. It is trained on a huge collection of text so that, given some input, it can predict what text should come next.

That sounds narrow, but a model that predicts text well enough ends up useful for many tasks: answering questions, drafting and editing, translating, summarizing, and writing code. Products such as ChatGPT, Claude, and Gemini are built on LLMs, and open-weight models such as Llama are used the same way.

The word “large” refers to scale: the number of learned parameters, the amount of training data, and the computing power used to train the model. There is no fixed size at which a model becomes “large”.

How an LLM works

Text becomes tokens

A model does not read letters or words directly. A tokenizer first splits text into tokens, which are chunks such as whole words, parts of words, punctuation, or spaces. Each token maps to a number from a fixed vocabulary.

This is why LLMs can handle rare words and typos reasonably well: unfamiliar text is broken into smaller known pieces. It is also why they can struggle with tasks that depend on individual letters, such as counting the letters in a word.

Tokens become vectors

Each token ID is converted into a list of numbers called an embedding. During training, the model learns embeddings so that tokens used in similar ways end up with similar numbers. Everything after this point is arithmetic on these numbers.

The transformer processes them

Most modern LLMs use an architecture called the transformer. Its key mechanism is attention, which lets the model weigh how relevant each earlier token is when processing the current one.

For example, in the sentence “The trophy didn’t fit in the suitcase because it was too big”, attention helps the model connect “it” with the right earlier word. The transformer stacks many layers of attention and other computations, and each layer refines the representation of every token.

The output is a probability for the next token

At the end, the model produces a score for every token in its vocabulary, which is converted into a probability distribution over what comes next.

Input:   The capital of France is
Output:  " Paris" is very likely; most other tokens are very unlikely

The system then samples one token from this distribution, adds it to the input, and repeats. A response is built one token at a time. Settings such as temperature control how much randomness goes into the choice: low values favor the most likely token, higher values allow more varied output.

How an LLM is trained

Pretraining

In pretraining, the model reads a very large body of text and learns to predict each next token. When its prediction is wrong, an algorithm (gradient descent with backpropagation) adjusts the model’s parameters, also called weights, to make the correct token more likely next time.

Parameters are the numbers the model learns. They are where the model’s “knowledge” about language, facts, and patterns is stored, spread across the whole network rather than kept as separate entries. This stage is by far the most computationally expensive.

Fine-tuning and alignment

A pretrained model is good at continuing text but not necessarily at following instructions or being helpful. A second stage adjusts it for that:

  • Instruction tuning trains the model on examples of prompts paired with good responses.
  • Preference training, such as reinforcement learning from human feedback (RLHF), uses human or automated judgments about which responses are better to steer the model.

The result is the chat-style assistant most people use.

The context window

An LLM can only consider a limited amount of text at once. This limit is the context window, measured in tokens, and it covers both your input and the model’s output.

The model does not keep memory between separate conversations on its own. Any apparent memory comes from earlier text being included in the context, or from a separate system that stores and re-inserts information.

What LLMs are good at

  • Generating, rewriting, and summarizing text
  • Translating between languages
  • Explaining concepts and answering questions on widely documented topics
  • Writing and explaining code
  • Turning messy input into a structured format

Limitations

Hallucination. An LLM is trained to produce plausible text, not to check that it is true. It can state false information fluently, including invented names, references, or details. Fluency is not evidence of accuracy.

Training cutoff. A model only learned from data up to some point. It does not know about later events unless that information is supplied in the prompt or through a tool.

Inconsistent reasoning and arithmetic. Models can solve many multi-step problems, but they can also fail on simple ones, and the same question phrased differently can give different answers.

Sensitivity to the prompt. Wording, order, and included context can change the result.

Limited context. Information beyond the context window is not seen at all.

Common ways to improve results

  • Retrieval-augmented generation (RAG). Relevant documents are found with a search step and placed in the prompt, so the model answers from supplied text rather than from memory alone.
  • Tool use. The model is connected to tools such as a calculator, code runner, or web search, and uses their output.
  • Fine-tuning. A model is trained further on specialized data to improve behavior in a particular domain or format.
  • Verification. Outputs are checked by a person, a test suite, or another program before being trusted.

Common misconceptions

  • “An LLM looks answers up in a database.” It generates text from learned parameters. It has no built-in lookup of stored facts, though it can be connected to search or databases.
  • “It always knows when it is wrong.” Models can express the same confidence in correct and incorrect answers.
  • “Bigger is always better.” Larger models tend to be more capable, but data quality, training method, and the task all matter. Smaller models are often cheaper and good enough for narrow jobs.
  • “An LLM is the same as AI.” LLMs are one kind of AI system. Others include image classifiers, recommendation systems, and game-playing agents.
  • “It remembers me.” Without a memory feature built around it, the model only sees what is in the current context.

Key takeaways

  • An LLM is a neural network trained to predict the next token in text, and it generates responses one token at a time.
  • Most LLMs use the transformer architecture, whose attention mechanism lets the model relate tokens across the input.
  • Training has two broad stages: pretraining on large amounts of text, then fine-tuning to follow instructions and behave helpfully.
  • LLMs produce likely text, not guaranteed facts, so important output needs verification.
  • Retrieval, tools, and fine-tuning can make LLMs more accurate and useful for specific jobs.

FILENAME: what-is-an-llm.md

Related articles in AI and Data

Image preview

Fit