What is a large language model, and how does it produce an answer?
LLM and transformer basics · Beginner 1
Short answer
A large language model is a neural network trained on a huge amount of text to predict the next token. It writes an answer one token at a time, each time choosing a likely next token given everything before it. It has no lookup table of facts; it has patterns learned during training.
Deeper answer
Training happens in stages. Pre-training teaches the model to predict the next token on a very large text corpus, which is where its knowledge of language and the world comes from. Later stages, such as instruction tuning and learning from human feedback, teach it to follow instructions and answer helpfully.
At inference time the model takes your prompt as tokens, computes a probability for every possible next token, picks one (how it picks depends on settings such as temperature), appends it, and repeats until it stops. That is why the same prompt can give different answers, and why a fluent answer can still be wrong: the model optimises for likely text, not for checked truth.
What a strong answer covers
- A neural network trained on lots of text
- Predicts the next token
- Generates one token at a time
- Learned patterns, not a fact database
Answer it out loud in the mock interview about 1 min
Follow-ups to expect
- What does pre-training give the model that instruction tuning does not?
- Why can the same prompt give different answers?
- Where does a model's knowledge cut-off come from?
Common mistakes
- Saying the model searches a database of facts when it answers
- Treating fluent output as evidence that the answer is correct
Learn it
What AI, machine learning and a language model are
- At a high level, what does attention do in a transformer?
- What is a context window, and what happens when a conversation gets too long?
- Your chatbot costs about three times more per reply in Tamil than in English. Why, and what would you do?
- What is DPO, and how is it different from RLHF?
- How is a chat model like ChatGPT trained? What is the difference between SFT and RLHF?
- What does the temperature setting do?
- What is test-time compute, and how can you use it to get better answers?
- What is a token, and why do tokens matter when you build with LLMs?
- What is perplexity, and what are its limits as a metric?
- Why do language models hallucinate, and how do you reduce it in an app?