You have probably chatted with an AI assistant such as ChatGPT or Claude. These assistants are built on large language models, and the same kind of model is also used for search, text classification, and agents.
What is a Large Language Model
A large language model (LLM) is an AI model that processes and generates human language. It is trained on huge amounts of text, which lets it summarize, translate, answer questions, and write new text. Most LLMs are neural networks with the transformer architecture.
By learning the statistical relationships between words and phrases in its training data, the model picks up grammar, facts, and some ability to reason. This is enough for tasks such as answering questions, writing emails, generating code, and holding a conversation. The "large" in the name refers to the number of parameters, the values the model learns in training: billions, and in the biggest models, trillions.
LLM development usually has two training stages. The first stage trains a foundation model on large amounts of text. The model picks up patterns from it, such as grammar, word associations, and how meaning depends on context. More formally, it learns statistical representations of the data and the relationships between them. This training is self-supervised: there are no human-made labels, and the training targets come from the text itself, for example, the next word.
Creating the foundation model is called pre-training. A pre-trained model doesn't solve specific tasks yet. Depending on its type (see the next section), it either turns input text into numbers or continues a text by predicting the next words. Both are useful, but limited.
Fine-tuning, usually the second stage, trains the foundation model further in a supervised way, on a labeled dataset that is much smaller than the pre-training data. The goal is either to solve a specific task, such as recognizing named entities, or to adapt the model to a domain, such as medical texts.
Fine-tuning doesn't have to be supervised. It can also use other approaches, such as semi-supervised training or reinforcement learning, but this topic doesn't cover them.
After fine-tuning, a model can handle tasks such as classification or following instructions. The "Chat" in ChatGPT means that GPT, a foundation model, was fine-tuned for conversation, partly on instructions: a labeled dataset of pairs of a task description and the desired response.
Fine-tuning often includes a step called alignment, in which developers adjust the model to behave the way users expect, for example, to be helpful and polite and to refuse harmful requests.
The two types
LLMs fall into two main categories by their output: autoregressive models and representational (or embedding) models.
Autoregressive (or generative) models generate text by predicting the next token (a word or part of a word) from all the tokens before it. They model the conditional probability of a token given the previous tokens. ChatGPT, Claude, Gemini, Llama, Grok, and similar models are all autoregressive, which is why you see their answers appear token by token.
Some representational models, such as BERT, learn by predicting masked words from the words around them, though this isn't the only way to train embedding models. Companies that make autoregressive models often offer embedding models too, for example, OpenAI's text-embedding-3-small.
A pre-trained representational model outputs embeddings. It can then be fine-tuned for a narrower task, such as sentiment analysis, to output a label ('positive', 'negative', or 'neutral') for each input.
Representational models usually don't generate text, while generation is the main job of autoregressive models.
Building with LLMs
A common use of representational models is semantic search, which finds documents by meaning instead of by matching keywords. It is the basis of many question-answering systems, recommendation engines, and document search tools. Fine-tuned representational models also handle classic natural language processing tasks, such as text classification (for example, sentiment analysis), part-of-speech tagging, or checking whether two documents are similar. Fine-tuning for these tasks is supervised, so it needs labeled data.
Autoregressive models are more general-purpose and are used wherever an application needs to generate text. Controlled by prompts, they power chatbots and other conversational AI. Because they generate text by predicting a likely next token, they can "hallucinate": produce text that sounds plausible but is false. They also can't reliably tell which source a fact came from. They handle most everyday tasks well, but you can't fully trust them where accuracy matters most.
Retrieval-augmented generation (RAG) is one way to reduce these problems. RAG combines a technique from representational models, an index of document embeddings for a specific domain, with generation. The system first retrieves facts relevant to the question from this knowledge base and then tells the model to answer based only on them. The answers become more accurate, and the system can show which documents each answer came from.
LLMs are also widely used to power agents, systems that act on their own. An agent uses an autoregressive model to interpret a goal, make a plan, and carry it out with external tools. At each step, the model decides what to do next, such as calling an API, running a script, or querying a database. Personal assistants and automated workflows are often built this way.
Conclusion
An LLM is a neural network, usually a transformer, trained on large amounts of text: first in self-supervised pre-training, then in fine-tuning, which often includes alignment.
Autoregressive models generate text token by token. Representational models encode the input into embeddings for semantic search and classification.
Generated text can be wrong and comes without sources, so applications often ground the model in retrieved documents with RAG.
LLMs also power agents, which plan and act through external tools.