What Is an LLM (Large Language Model)?
Learn what a large language model is, how pretraining and RLHF shape it, how it generates text, and its key limitations like hallucination and context window.
Expected Interview Answer
A large language model (LLM) is a neural network, typically built on the transformer architecture, trained on massive amounts of text to predict the next token in a sequence, and that single objective, scaled with billions of parameters and vast data, gives rise to broad abilities like answering questions, writing code, and reasoning through problems.
Training happens in stages: pretraining on huge unlabeled text corpora teaches general language patterns and world knowledge purely from next-token prediction, then instruction tuning and reinforcement learning from human feedback (RLHF) shape the raw model into one that follows instructions helpfully and safely. At inference, the model generates text autoregressively, one token at a time, conditioning each new token on everything generated so far. Key characteristics include a fixed context window limiting how much text it can consider at once, a tendency to 'hallucinate' plausible-sounding but false statements, and no built-in mechanism for real-time knowledge beyond its training cutoff unless augmented with retrieval or tools.
- Generalizes across many language tasks from one pretrained model
- Can follow natural language instructions without task-specific training
- Enables few-shot or zero-shot performance on new tasks
- Can be extended with retrieval, tools, or fine-tuning for specific domains
- Powers chat, coding, summarization, and reasoning applications from one base
AI Mentor Explanation
An LLM is like a commentator who has watched millions of hours of match footage and learned to predict the next ball's likely outcome from pure pattern exposure, without ever being taught explicit rules directly. That deep, statistical familiarity is what lets them fluently narrate a brand-new, never-before-seen match convincingly.
Step-by-Step Explanation
Step 1
Pretrain on massive text
The model learns to predict the next token across huge, mostly unlabeled text corpora, absorbing grammar, facts, and reasoning patterns.
Step 2
Instruction tune
The base model is fine-tuned on examples of instructions paired with helpful responses to make it follow user requests.
Step 3
Align with human feedback
Reinforcement learning from human feedback (RLHF) further shapes outputs toward helpful, honest, and safe behavior.
Step 4
Generate autoregressively
At inference, the model produces one token at a time, each conditioned on the full sequence generated so far.
Step 5
Augment when needed
Retrieval, tools, or further fine-tuning extend the base model with fresh knowledge or domain-specific behavior.
What Interviewer Expects
- Explains the next-token prediction training objective
- Distinguishes pretraining from instruction tuning and RLHF
- Knows about context window limits and knowledge cutoffs
- Understands hallucination as a known failure mode
- Can mention retrieval-augmented generation as a mitigation
Common Mistakes
- Assuming an LLM 'looks things up' rather than generating from learned patterns
- Confusing model size (parameters) with guaranteed accuracy
- Ignoring the fixed context window as a practical limitation
- Treating hallucinations as rare bugs rather than an inherent generation risk
Best Answer (HR Friendly)
“A large language model is an AI system trained on huge amounts of text that learns to predict what word comes next, and from that simple skill it becomes able to answer questions, write content, and hold conversations. Tools like ChatGPT and Claude are built on this kind of model.”
Code Example
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=200,
messages=[{"role": "user", "content": "Summarize what an LLM is in two sentences."}],
)
print(response.content[0].text)Follow-up Questions
- What is the difference between pretraining and fine-tuning an LLM?
- What causes LLM hallucinations and how can they be reduced?
- What is a context window and why does it matter?
- How does retrieval-augmented generation help an LLM stay current?
- What is RLHF and why is it used after pretraining?
MCQ Practice
1. What is the core training objective of a large language model?
LLMs are pretrained primarily to predict the next token given the preceding text, from which broader abilities emerge.
2. What is a hallucination in the context of LLMs?
Hallucination refers to the model generating confident, fluent text that is not actually factually correct.
3. What does the context window of an LLM limit?
The context window caps how many tokens of input and generated text the model can attend to in a single request.
Flash Cards
What is an LLM trained to do at its core? — Predict the next token in a sequence of text, learned from massive text corpora.
What is RLHF? — Reinforcement learning from human feedback, used after pretraining to align model outputs with helpful, safe behavior.
What is a hallucination? — A fluent, confident-sounding statement generated by the model that is factually incorrect.
What limits how much text an LLM can consider at once? — Its context window, a fixed maximum number of tokens for input plus output.