What is a large language model (LLM)?
What is a large language model? Definition and key properties
A large language model is a neural network that uses transformer architecture and stores what it learns in parameters (i.e., the numeric weights that are adjusted during training). Transformer architecture detects dependencies between parts of a sequence regardless of how far apart they sit. That is what lets a model connect a pronoun to a noun several paragraphs earlier.
Large language models cover the range of natural language processing (NLP) tasks: sentiment analysis, conversational question answering, translation, classification, summarization, and generation. One model does all of them, because all of them reduce to predicting text.
You have probably already used one. ChatGPT, Claude, Gemini, and Microsoft Copilot are consumer and workplace products built on large language models, and the coding assistant in your editor most likely is, too. Behind each product sits the same pattern: a model trained on text, asked to continue text.
A brief history of large language models
Large language models grew out of three decades of statistical language modeling, and one architectural change in 2017 made the current generation possible. Before that, NLP systems leaned on n-gram counts, then on word embeddings such as Word2Vec, and then on recurrent neural networks that read text one token at a time.
The transformer architecture was published in 2017 in the paper "Attention Is All You Need."3 Replacing recurrence with attention removed the sequential bottleneck and let training run in parallel across hardware.
The next two years split the field into the two branches still in use. BERT arrived from Google in 2018 as an encoder-only model for understanding text. The GPT line from OpenAI took the decoder-only path for generating it, scaling from GPT-2 in 2019 to GPT-3 in 2020.
ChatGPT's release in November 2022 moved these models from research artifacts to consumer products, and it did so on the back of alignment rather than a new architecture. The years since have added multimodal inputs, longer context windows, and open-weight families that anyone can download and run.
What does the "large" in large language model mean?
The "large" in a large language model refers to two things at once: the number of parameters in the model and the volume of text it was trained on. There is no official agreed-upon threshold for what makes a language model large, so the word describes a scale rather than a category boundary.
A parameter is a learned numeric weight adjusted during training. It is not a stored fact, and it is not a copy of a training document. The model keeps the weights that its training text pushed into place and discards the text.
Earlier statistical language models, such as n-gram models, tracked counts of word sequences and ran on a single machine. Modern models are trained on corpora and parameter counts far beyond that, which is why they need clusters of accelerators rather than one server. For scale: Llama 3.1 405B, released by Meta in July 2024, has 405 billion parameters and was trained on more than 15 trillion tokens.1
Size has a price. OpenAI's GPT-4o, for example, currently bills $2.50 per million input tokens and $10.00 per million output tokens.2 More parameters mean more compute to train, more memory to hold the model, and a higher cost for every query at inference time. Hosted models bill per token of input and output, so a long prompt costs more than a short one on every single call. Prompt length is one of the few costs you, the LLM user, control directly.
How do LLMs work?
A large language model works by predicting one token at a time and then feeding its own output back in and predicting again. Each step feeds the next, so a change at tokenization changes everything downstream.
- Tokenization: The tokenizer splits your input text into tokens: words, word fragments, or single characters. Models process numbers rather than characters, so each token maps to an integer index in a fixed vocabulary. Byte-pair encoding, the most common method for building that vocabulary, starts from individual characters and repeatedly merges the most frequent adjacent pair.
- Embedding: Each integer index maps to an embedding vector: a list of numbers that positions the token relative to every other token the model knows.
- Processing: The transformer layers process those vectors together and output a probability distribution over the entire vocabulary for the next token.
- Sampling: A sampling step selects one token from that distribution. Settings such as temperature decide how strictly the model favors the highest-probability option.
- Repetition: The selected token joins the input, and the loop runs again until the model emits a stop token or hits a length limit.
Everything the model can see while doing this lives in its context window, the maximum number of tokens it can hold at once. Anything outside that window is invisible to it.
The model predicts statistically likely continuations of text, and it has no internal check for truth. Fluency and accuracy are separate properties. A model can be wrong and still sound right, and that is where hallucination comes from.
3 key components of a large language model
The three key components of a large language model are the neural network layers that every input passes through in order: the embedding layer, the attention mechanism, and the feedforward layer.
- Embedding layer: The embedding layer converts each token into a vector embedding (a list of numbers learned during training). Tokens that appear in similar contexts end up with similar vectors, so the model starts from a representation where "laptop" sits closer to "notebook" than to "banana." Semantic search uses the same idea one level up. A separate text embedding model encodes whole queries and passages. That is how a search for “laptop battery life” can match a passage about notebook charge duration with no words in common.
- Attention mechanism: The attention mechanism weighs every token against every other token in the input and scores how relevant each one is to the token being processed. Think of a reader who, before writing each new word, glances back over the whole page and decides which earlier words matter most right now. Scoring across the whole sequence is how the model resolves long-range dependencies, such as which noun a pronoun five sentences back refers to.
- Feedforward layer: The feedforward layer applies nonlinear transformations to the attention output through fully connected layers. It processes the contextualized representation that attention produced, and by stacking these blocks dozens or hundreds of times, it builds the large model’s vast capacity.
What is a transformer model?
A transformer model is the architecture nearly every modern large language model is built on. It processes data by tokenizing the input and then running mathematical operations across all tokens at once to discover the relationships between them.
Transformers come in three shapes, and the difference decides what a model is good at.
- Encoder-only models such as BERT are built to understand text, so they suit classification, retrieval, and extraction.
- Decoder-only models such as GPT are built to generate it.
- Encoder-decoder models such as T5 do both, which fits sequence-to-sequence work like translation.
Self-attention scores every token in the input against every other token at the same time. Recurrent models such as long short-term memory (LSTM) networks process tokens one after another, so training time grows with sequence length and computation cannot be spread across hardware. Parallel scoring made training at today's scale economically possible, and it improved how well models capture relationships between distant words.
How are large language models trained?
A large language model is shaped at three points: pretraining, fine-tuning, and alignment, in decreasing order of cost and permanence.
- Pretraining is self-supervised and does the heavy lifting. The model reads books, articles, websites, and code; predicts masked or next words; and adjusts its weights by backpropagation when it gets them wrong. No human labels the data; the next word in the text is the label. This phase consumes most of the compute budget and produces a base model that knows language structure but follows no instructions.
- Fine-tuning continues training on a much smaller labeled dataset built for a task or a domain: medical notes, legal contracts, support tickets, one company's code. It adjusts the same weights, so the change is permanent, and a model trained on narrow data can drift away from general capability.
- Alignment turns a predictor into an assistant. In reinforcement learning from human feedback (RLHF), people rank alternative model responses. Those rankings train a separate reward model, and the language model is then tuned to score well against it. RLHF is why a modern chat model answers your question instead of continuing your sentence.
The quality of the data the model is trained on will reflect directly in the quality of the outputs it produces. Teams perform preprocessing to clean up the data before training begins, including deduplicating near-identical documents, striping boilerplate, and filtering low-quality or harmful text.
Training data also must stop at a certain date. That date is the model's knowledge cutoff, which means it can’t tell you about an event, a release, or a document that appeared afterward, including anything inside your own organization.
Why do larger models get better? Scaling laws and emergent abilities
Scaling laws describe the predictable part of making a model bigger, and emergent abilities describe the unpredictable part.
- Scaling laws are empirical relationships linking compute, parameter count, and training tokens to a model's loss (a numerical value representing the errors it makes). Researchers analyzing the optimal model size and number of tokens for training language models found an influential result with the Chinchilla model, which reported that parameters and training data should grow together, and that several earlier headline models were undertrained rather than too small.4 Under that finding, a smaller model fed more tokens can beat a larger model fed fewer, for the same compute.
- Emergent abilities are capabilities absent in smaller models that appear abruptly once a model passes some size threshold, rather than improving gradually. Researchers originally claimed in a 2022 preprint that such jumps cannot be predicted from smaller models.5 But a later analysis pushed back, arguing that apparent emergence is largely an artifact of scoring with discontinuous, all-or-nothing metrics rather than a real property of the model.6 A separate study showed that some apparent emergence reflects in-context learning, where the model picks up the task from examples in the prompt, rather than a capability that appears abruptly at scale.7 Neither line of research settles the question.
For anyone choosing a model, the takeaway is practical: Capability does not scale smoothly with spend. Benchmark candidate models on your own task instead of extrapolating from a size number or a leaderboard.
What is the difference between large language models and generative AI?
Generative AI is the umbrella term for artificial intelligence models that create content of any kind, including text, code, images, video, and music. Large language models are the text-trained subset of that category. All LLMs are generative AI, but not all generative AI is an LLM.
Image generators make the distinction concrete. DALL-E and Midjourney produce pictures rather than text, and they rely on diffusion models: an architecture that learns to reverse the gradual addition of noise to an image. That is a different design from the transformer stack behind a text model.
What is a multimodal large language model?
A multimodal large language model accepts more than one kind of input: text plus images, audio, or video. It relates them inside a single model rather than handing each type to a separate system. Ask a multimodal LLM to explain a screenshot, read a scanned invoice, or describe a chart, and the same model that writes the answer will have also processed the picture.
Most frontier models are now multimodal, which is why "LLM" and "generative AI" get swapped so often in conversation. A model that reads images is no longer purely a language model.
For an application, multimodality changes what has to be retrievable. The input is no longer only text, so diagrams, screenshots, and scanned documents become part of the same retrieval pipeline as your prose, and they need embeddings of their own.
3 types of large language models
Generic, instruction-tuned, and dialog-tuned models share the same underlying architecture but differ in how they were adapted after pretraining.
- Generic or raw language models: A generic model predicts the next word from the distribution it learned in training, with no instruction-following behavior layered on top. It suits completion and retrieval-style tasks, and it is the starting point for the other two model types.
- Instruction-tuned language models: An instruction-tuned model is trained to carry out the instruction stated in the prompt. That adaptation is what makes classification, summarization, and code generation work from a plain request.
- Dialog-tuned language models: A dialog-tuned model is trained on multi-turn exchanges and predicts the next response rather than the next passage. Chatbots and conversational assistants run on this type.
Large language model use cases and examples
Large language models handle any task that can be expressed as text in and text out, from enterprise search to code generation. Each task carries a different tolerance for error, and that tolerance is what decides whether a person must check the output before anyone sees it:
| Use case | Concrete example | Error tolerance |
|---|---|---|
| Information retrieval and enterprise search | Answering "what is our parental leave policy?" from internal documents | Low: a wrong answer is acted on as policy |
| Summarization | Condensing a 40-page incident report into a paragraph | Medium: omissions matter more than errors |
| Sentiment analysis | Scoring thousands of product reviews as positive or negative | High: individual mistakes wash out in aggregate |
| Text generation | "Write me a poem about palm trees in the style of Emily Dickinson" | High: the reader judges the output directly |
| Code generation | Drafting a function and its unit tests from a description | Low: tests and review catch errors, but only if run |
| Conversational assistants | Handling a customer service query end to end | Low: output is customer-facing and unreviewed |
Large language models appear across industries.
- Tech teams use them to improve search responses and help developers write code.
- In healthcare and science, models analyze sequence data from proteins, DNA, and RNA to support research and vaccine development.8 Medical chatbots also handle patient intake and basic triage, which typically requires human oversight.
- Customer service runs chatbots and conversational AI.
- Marketing teams use them for sentiment analysis, content drafts, and campaign brainstorming.
- Legal staff search large document sets and draft filings.
- Banks analyze transactions and customer communications for signals of fraud, usually inside a broader detection system.
Related: How to make a chatbot: Dos and don'ts for developers
4 benefits of large language models
Large language models offer four advantages that older, task-specific NLP systems could not: breadth, adaptation without retraining, a natural-language interface, and speed to a working prototype.
- One model, many tasks: A single pretrained model handles translation, summarization, classification, and generation. The previous approach needed a separate trained system, and often a separate labeled dataset, for each one.
- Adaptation without retraining: In-context learning lets a model take on a new task from a few examples in the prompt, or from none at all. The cost of trying a new idea is writing a prompt rather than funding a training run.
- Natural-language interface: People can query a system without learning its query syntax. That widens who can use it, from the analyst who knows SQL to the support agent who doesn’t.
- Fast time to value: Pretrained hosted models are callable through an API on day one, with no training infrastructure to stand up. You can find out whether the idea works before you commit to any training hardware.
6 limitations and challenges of LLMs
Large language models give the impression of understanding, but they need supervision. Six challenges apply to any deployment.
- Hallucinations: A hallucination is a fluent, syntactically sound output that is factually wrong or unfaithful to its source. It follows directly from next-token prediction: The model optimizes for likely continuations, not true ones. In addition to keeping a person in the loop to spot inaccuracies, hallucinations can be prevented by using retrieval augmented generation (RAG), which grounds the output in retrieved source material. Models can also require citations which help if the application shows the retrieved passage next to the answer, so a reader can check the claim against the source rather than against the model.
- Security: LLMs leak private information from training data or from conversations when they are not managed and monitored, and attackers use them to draft phishing messages or generate spam at scale. Prompt injection, where hostile text in a retrieved document redirects the model, is a risk specific to applications that read untrusted content.
- Bias: Training data shapes output, and a model trained on skewed data produces skewed output in confident prose.
- Consent: Some training corpora were assembled without explicit consent or clear copyright permission. That raises intellectual property questions when content is reproduced without attribution, and privacy questions when personal data is scraped.⁹ Getty Images sued Stability AI in January 2023 over the use of its content; the suit, Getty Images (US), Inc. v. Stability AI, Inc., was filed February 3, 2023, in the U.S. District Court for the District of Delaware.10
- Scaling: Training and serving large models consumes substantial computational power, and keeping them useful means continuous updates, optimization, and monitoring.
- Deployment: Running a model in production takes expertise in deep learning and transformer architectures alongside specialized hardware, which is why most teams start with a hosted API.
What is bias in large language models?
Bias in a large language model is a systematic skew in its output that traces back to the data it was trained on. A corpus drawn from the public web carries the demographic, geographic, and linguistic imbalances of the people who wrote it, and training turns those imbalances into weights.
Bias is measured, not assumed. To measure bias, teams run paired prompts that differ only in a named group; score the outputs for differences in tone, refusal rate, or quality; and track the gap over time. Published benchmark suites exist for this, and they cover only the categories their authors chose. In an early GPT-3 paper, for example, the authors seeded prompts such as “The {race} person was very ..." and scored the generated completions. They found the model reflected racial, gender, and religious stereotypes present in its training data.11
There are a few ways to reduce bias: curating and rebalancing training data, alignment tuning against biased responses, and filtering at the application layer. Testing on your own task with your own population before launching the model, rather than after, matters, too. None of these removes bias, however, and treating the problem as closed is itself a risk.
When should you not use a large language model?
Avoid a large language model where a deterministic system already produces the right answer, because a model predicts likely text and cannot guarantee correctness. Arithmetic, balance lookups, tax calculations, and rule-based eligibility checks belong in code or a database query, with the model calling that code if a conversational interface is wanted.
In addition, questions about current facts need retrieval or a live API, not a model answering from its knowledge cutoff. And high-stakes decisions in medicine, law, credit, or hiring need a human decision-maker, with the model confined to drafting and summarizing. No evaluation gives you a guarantee about the next output.
4 ways to extend an LLM with your own data
A base model knows only what it was trained on up to its knowledge cutoff. But there are four methods you can use to extend a large language model with your own data: prompting, retrieval, tool calling, and fine-tuning, in roughly increasing order of cost.
- Prompting: Prompting supplies the extra information in the request itself. Few-shot prompting includes examples that show the model the pattern you want. Given examples of positive/negative sentiment, the model infers what signals a given phrase. Zero-shot prompting drops the examples and states the task directly, relying on prior training alone. Prompt engineering writes those instructions deliberately, choosing the examples, the ordering, and the wording, and it costs nothing at the model level because nothing about the model changes.
- Retrieval augmented generation: Retrieval gives the model facts it never saw. The application searches your own content and injects the matching passages into the prompt, and the model answers from them. RAG grounds output in current, private, access-controlled material and lets the answer cite its sources. It is the standard solution for both hallucination and the knowledge cutoff. The passages and their embeddings live in a search system or vector database that returns the most relevant matches for each query.
- Tool calling: Tool calling lets the model act instead of answer. It emits a structured call that an external program executes, such as an API request, a database query, or a snippet of code. The result returns to the context for the model to use.
- Fine-tuning: Fine-tuning is the more expensive option. It changes the model's weights and fits a fixed style, format, or domain vocabulary far better than it fits facts that move. The practical rule: retrieval for knowledge that changes, fine-tuning for behavior that does not.
How are large language models evaluated?
Large language model evaluation happens at two levels: statistical measures of prediction quality, and task benchmarks that approximate usefulness.
- Measures of prediction quality: Perplexity scores how well a model predicts held-out text, derived from the average negative log-likelihood per token, and lower is better. Perplexity depends on the tokenizer, so comparing the number across models with different vocabularies is unreliable. It also correlates only loosely with whether a person finds the output useful.
- Task benchmarks: Benchmark suites cover the second level, testing reasoning, factual accuracy, coding, and safety with graded question sets. Their weakness is benchmark contamination: When benchmark questions appear in a model's training data, its score rises without its capability rising. Contamination is hard to rule out for any model trained on a broad web crawl, which makes leaderboard position weak evidence on its own.
Evaluate candidate models on a held-out sample of your own task, with your own data and your own definition of a good answer, because published scores do not transfer.
Examples of popular large language models
LLM is the category and GPT is one branded family inside it; every GPT model is an LLM, and most LLMs are not GPT. Open-weight families publish their parameters, so you can run the model on your own hardware, while proprietary families are reachable only through an API.
Licensing is not always one or the other. OpenAI relies on closed, proprietary access for ChatGPT and GPT-4o, but it released the gpt-oss-120b and gpt-oss-20b models under the open Apache 2.0 license in August 2025.12
| Family | Developer | Architecture | Weights | Best suited for |
|---|---|---|---|---|
| GPT | OpenAI | Decoder-only | Hybrid (proprietary + open-weight) | General generation, reasoning, code |
| BERT | Encoder-only | Open | Classification, retrieval, extraction | |
| T5 | Encoder-decoder | Open | Translation and other sequence-to-sequence tasks | |
| Llama | Meta | Decoder-only | Open | Self-hosted and on-premises generation |
| Claude | Anthropic | Decoder-only | Proprietary | Long-document work, assistants, code |
| Gemini | Decoder-only | Proprietary | Multimodal generation across text and images |
Organizations also fine-tune these foundations for a single domain, such as customer relationship management or financial data. The family that holds the lead can change within months, while the encoder, decoder, and encoder-decoder distinction has held since 2017.
Which AI products are built on large language models?
The AI products most people have used are interfaces over a large language model, with the model named separately from the product. ChatGPT runs on OpenAI's GPT family. Claude is Anthropic's model reached through its own apps and API. Gemini is Google's model, exposed both as a standalone assistant and inside Google Workspace. Microsoft Copilot puts a large language model inside Microsoft 365 and GitHub.
Coding assistants, customer service chatbots, and the summarize button in your note-taking app follow the same pattern. The product is a prompt template, a retrieval step, and a user interface wrapped around a model the vendor either trained or licensed.
Large language models and Elastic
Grounding a large language model in your own data is a search problem before it is an AI problem. If retrieval returns the wrong passage, the answer is wrong, and the model sounds just as confident. Elasticsearch, a distributed search and analytics engine, stores your content alongside its vector embeddings and returns the passages that get passed to the model, using semantic, keyword, or hybrid matching. Once your application is running, LLM observability in Elastic Observability tracks the cost, latency, and errors of those model calls. To start, index a sample of your own content with its embeddings and run a semantic query against it before you wire a model in. Semantic search in Elasticsearch has the implementation steps.
Large language model resources
- Language models in Elasticsearch
- The LLM Safety Assessment
- Get started with generative AI in enterprise
- Overview of natural language processing (NLP) in the Elastic Stack
- Compatible third-party models with the Elastic Stack
- Guide to trained models in the Elastic Stack
Footnotes
- Meta, "Introducing Llama 3.1: Our most capable models to date," July 2024.
- OpenAI API pricing,platform.openai.com/docs/pricing, accessed September 2026.
- Vaswani, Ashish, et al., "Attention Is All You Need," NeurIPS 2017 / arXiv preprint, June 2017.
- Hoffmann, Jordan, et al., "Training Compute-Optimal Large Language Models," NeurIPS 2022 / arXiv preprint, March 2022.
- Wei, Jason, et al., "Emergent Abilities of Large Language Models," Transactions on Machine Learning Research (TMLR), 2022.
- Schaeffer, Rylan, Brando Miranda, and Sanmi Koyejo, "Are Emergent Abilities of Large Language Models a Mirage?," NeurIPS 2023 (Outstanding Paper Award) / arXiv preprint, May 2023.
- Lu, Sheng, et al., "Are Emergent Abilities in Large Language Models just In-Context Learning?," ACL 2024 / arXiv preprint, September 2023.
- Sarumi, Oluwafemi A., and Dominik Heider, "Large Language Models and Their Applications in Bioinformatics," Computational and Structural Biotechnology Journal, vol. 23, April 2024, pp. 3498–3505.
- Sheng, Ellen, "In generative AI legal Wild West, the courtroom battles are just getting started," CNBC, April 2023.
- Getty Images (US), Inc. v. Stability AI, Inc., no. 1:23-cv-00135 (D. Del., filed Feb. 3, 2023); Getty Images statement, January 2023.
- Brown, Tom B., et al., "Language Models are Few-Shot Learners," section 6.2, NeurIPS 2020 / arXiv preprint, May 2020.
- OpenAI, "Introducing gpt-oss," August 2025.