Skip to main content

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

Answer it out loud in the mock interview about 1 min

Follow-ups to expect

Common mistakes

Learn it

What AI, machine learning and a language model are

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.