AI glossary

Large Language Model (LLM)

A large language model (LLM) is a neural network, almost always built on the transformer architecture, trained on very large amounts of text to predict the next piece of text given what came before, which in practice lets it generate, summarize, translate, and answer questions about text.

How an LLM is built

LLMs are built on the transformer architecture, which uses a mechanism called self-attention to let the model weigh the relevance of every other piece of text in its input when processing each piece, rather than reading strictly left to right. This architecture allows the model to understand context and relationships between words regardless of their distance from each other in the text sequence.

The model is trained by repeatedly predicting the next token in enormous amounts of text and adjusting its internal numbers (parameters) to make its predictions more accurate over many training passes. This iterative process of prediction and adjustment is what enables the model to learn linguistic patterns, factual associations, and reasoning capabilities.

Parameters

“Parameters” are the internal numeric weights a neural network learns during training; a model with more parameters has more capacity to store patterns learned from its training data, though more parameters also mean more memory and compute are needed to run it. These weights determine how the model processes input data and generates output.

OpenAI’s GPT-3, described in the paper “Language Models are Few-Shot Learners” (Brown et al., 2020), had 175 billion parameters, a scale that was widely cited at the time as showing how far this “bigger model, more data” approach could be pushed. Understanding hyperparameters is also crucial, as they are the settings chosen before training begins, such as learning rate or batch size, which influence how the parameters are adjusted.

Tokens and context windows

LLMs don’t read raw characters or whole words directly; text is first split into tokens by a tokenizer, and the model’s context window is the maximum number of tokens it can take into account at once, spanning both the prompt and its own generated response. Tokens can be as short as a single character or as long as a common word, depending on the tokenizer’s design.

The context window size is a critical constraint. If the input text exceeds this limit, the model may truncate earlier information or require specialized techniques to handle long documents. Understanding tokens is essential for optimizing prompts and managing costs, as most API charges are based on the number of tokens processed.

Pre-training and fine-tuning

Most LLMs go through a pre-training stage, learning general language patterns from a broad, largely unlabeled text corpus, followed by a fine-tuning stage that adapts the pre-trained model to specific behaviors, such as following instructions or holding a conversation, often using smaller, more curated datasets. Pre-training builds the foundational knowledge, while fine-tuning refines the model for particular tasks or domains.

The pre-training phase consumes vast amounts of data and compute, establishing the model’s core capabilities. Fine-tuning then tailors these capabilities, often resulting in models that are more responsive, accurate, or specialized for specific use cases without requiring retraining from scratch.

Well-known examples

Well-known LLM families include OpenAI’s GPT series, Anthropic’s Claude, Google’s Gemini, and Meta’s Llama, each released and updated by its respective company as a family of models rather than a single fixed model. These families often include multiple variants with different sizes, capabilities, and pricing structures to suit various needs.

You can explore specific model specs and pricing on our AI model pricing and specs page, or use our Compare models tool to evaluate different options side-by-side. Each family continues to evolve, with new versions typically offering improved performance, larger context windows, or enhanced reasoning abilities.

Limitations

LLMs can produce fluent, confident-sounding text that is factually wrong, a failure mode commonly called hallucination, because the model is optimized to produce plausible continuations of text rather than to verify facts against a ground truth. This happens because the model predicts what is statistically likely to come next, not necessarily what is factually true.

An LLM’s knowledge is limited by what was in its training data up to its training cutoff date, plus whatever additional information is supplied to it directly in its context window at the time it is used. This means that without external tools like retrieval-augmented generation (RAG) or real-time search, the model cannot know about events or data that occurred after its training period ended.

FAQ

What is the difference between an LLM and a traditional NLP model?

Traditional NLP models often handle specific tasks like sentiment analysis or named entity recognition using rule-based or simpler statistical methods. LLMs, built on transformers, are trained on vast datasets to understand and generate human language more flexibly, allowing them to perform multiple tasks with a single model.

How do I choose the right LLM for my project?

Consider factors like context window size, reasoning capabilities, cost per token, and whether you need an open-source model for self-hosting or a proprietary one for ease of use. Reviewing AI model pricing and specs can help you compare options based on your specific requirements.

Can LLMs understand code?

Yes. Many LLMs are trained on code repositories and can generate, debug, and explain programming languages. The underlying mechanism is the same: predicting the next token, which in this case might be a programming keyword or function.