AI & ML

Large Language Model (LLM)

A neural network trained on massive text datasets that can understand and generate human language, powering chatbots, code assistants, and content generation.

Large Language Models (LLMs) are deep learning models trained on vast amounts of text data to understand and generate human language. Models like GPT-4, Claude, Gemini, and Llama have billions of parameters and can perform a wide range of language tasks.

LLMs work by predicting the next token (word or sub-word) in a sequence, using the transformer architecture. During training, they learn patterns in grammar, facts, reasoning, and even code from their training corpus.

Key capabilities include text generation, summarization, translation, question answering, code generation, and reasoning. LLMs can be used through APIs (like OpenAI or Anthropic) or deployed locally using open-source models.

Important considerations when working with LLMs include token limits (context window), cost per token, latency, hallucination risks, and the need for prompt engineering or fine-tuning to achieve optimal results for specific use cases.

How it works

A large language model is an autoregressive model: it reads a sequence of tokens and predicts the next one, then appends that prediction and repeats. Text is split into tokens (words or word pieces) before the model sees it, so limits and prices are counted in tokens rather than words.

Almost all current LLMs are built on the Transformer architecture, whose attention layers let each token weigh the earlier tokens in the context when predicting the next one. Pre-training on a large text corpus sets the model's weights; nothing is looked up from a database at answer time unless an application adds that step, for example with retrieval.

Scale changed what these models can do. The GPT-3 paper (Brown et al., 2020) described a 175-billion-parameter model, 10x more than any previous non-sparse language model, and showed that it could perform many tasks "without any gradient updates or fine-tuning", with the task and a few demonstrations given purely as text in the prompt.

Raw pre-trained models continue text rather than follow instructions. Further training on human feedback turns them into assistants: in the InstructGPT paper, outputs from a 1.3B-parameter model trained this way were preferred by human evaluators to outputs from the 175B GPT-3, despite having 100x fewer parameters.

Example

Few-shot prompting, the behaviour the GPT-3 paper highlighted: the task is defined entirely by examples in the prompt, and the model continues the pattern.

Translate English to French.

sea otter => loutre de mer
cheese => fromage
peppermint =>

No weights change. The model predicts the most likely next tokens given the pattern, here a French translation. Remove the examples and the same model may answer in a different format, which is why prompt design matters.

Common confusion

Does an LLM look facts up when it answers?

Not by itself. A plain LLM generates text from patterns stored in its weights during training, which is why it can state outdated or invented facts confidently. Applications add lookups through retrieval (RAG) or tool calls, and then the answer can rest on fetched text.

Is a bigger model always better?

No. The InstructGPT result showed a much smaller model, trained to follow instructions, being preferred to a model 100x its size. Training method, task fit, latency and price all matter, so the right model depends on the job.

Further reading

Want to learn more?

Explore more developer terms or read in-depth articles on the blog.

Browse all terms