الانتقال إلى المحتوى
Deep Learning و LLMsTransformers· 7 دقائق للقراءة

An LLM Doesn't Look Up Answers: It Predicts the Next Token

No database, no matching row: a probability for every possible next token, one token at a time.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

A customer asks your support assistant about refunds. It answers, politely and confidently, that refunds are accepted within 60 days. Your policy says 30, and the number 60 appears nowhere in your docs. The product manager files a ticket: "Find the wrong entry in the model and correct it." The engineer who picks it up comes back empty-handed, because there is no entry. The model didn't retrieve "60 days" from anywhere. It generated it, one token at a time.

The common misconception

Many developers picture an LLM as a giant database of facts: your question goes in, the model searches its store, and the best-matching entry comes back. The picture is reasonable:

  • The interface looks like a search box. You type a question, you get an answer.
  • For well-known facts, answers are correct and stable. Ask for the capital of France ten times and you get Paris ten times, which is exactly how a lookup behaves.
  • "Trained on a huge amount of text" sounds like "keeps a copy of that text inside".
  • Some assistants really do search: with a web search tool, the app fetches pages before the model answers, which blurs the line.

It's a half-truth. The model does carry a lot of knowledge from training: Roberts, Raffel and Shazeer showed that language models can answer questions with no documents at hand, storing and retrieving knowledge implicitly in their parameters. But implicitly is the key word. There is no table, no index and no matching step.

What actually happens

Google's Machine Learning Crash Course defines a language model as one that estimates the probability of a or sequence of tokens occurring within a longer sequence. A does the same with a very large number of parameters: GPT-3, for example, has 175 billion. Generating an answer is a loop around that single prediction.

  1. Split the text into tokensYour prompt is cut into tokens: whole words, pieces of words or single characters. The model never sees raw text.
  2. Score every possible next tokenThe network reads every token in the context and outputs a probability for each token in its vocabulary. Not one answer: a whole distribution of candidates.
  3. Pick oneA sampling step chooses a token: the most likely one, or a random pick among the likely ones.
  4. Append it and repeatThe chosen token joins the context and the whole prediction runs again with it, until the model signals that the answer is complete or a length limit is reached.

Where the facts actually live

Training adjusts the parameters so the model gets better at predicting the next token across a huge amount of text. To predict "The capital of France is ___" well, it has to absorb that "Paris" goes there. That knowledge doesn't land in a row labeled France. It's spread across many parameters that also encode grammar, style and countless other facts.

Three consequences follow. You can't list, edit or delete one fact the way you'd update a row. There is no "not found": every question produces a distribution, and something always has the highest probability. And the right answer is only as likely as training made it.

Declining to answer is learned behavior, not a failed lookup. Anthropic's interpretability team found that Claude's default circuit says it can't answer, and a "known entity" signal switches that default off for names it recognizes. When that signal misfires on a name it recognizes but knows little about, the model produces a plausible, untrue answer.

"Just autocomplete" is the opposite mistake

Google's course calls LLMs essentially autocomplete mechanisms. That's accurate about the output, one token at a time, but it doesn't mean the computation behind each token is shallow. When Anthropic traced Claude answering "the capital of the state containing Dallas", they saw it first represent "Dallas is in Texas", then "the capital of Texas is Austin". When they swapped the Texas concept for California, the answer became Sacramento. Writing a rhyming couplet, Claude picked the rhyme word before it wrote the line that ends on it.

So an LLM is neither a database nor a parrot. It produces text one token at a time, and each step can combine facts and plan ahead.

See the loop in a toy model

This script builds the oldest kind of language model, an n-gram model: it counts which word follows each run of n words in a tiny corpus. Real LLMs replace the count table with a Transformer of billions of parameters and a far longer context, but the generation loop is the same.

Python toy_next_token.py
from collections import Counter, defaultdictcorpus = """the capital of france is paris . the capital of egypt is cairo .the language of egypt is arabic . the language of france is french .""".split()def train(n):  # "training": count which token follows every run of n tokens    table = defaultdict(Counter)    for i in range(len(corpus) - n):        table[tuple(corpus[i:i + n])][corpus[i + n]] += 1    return tabledef generate(prompt, n):    table, tokens = train(n), prompt.split()    while tokens[-1] != ".":        counts = table[tuple(tokens[-n:])]  # context = the last n tokens        probs = {tok: c / sum(counts.values()) for tok, c in counts.items()}        tokens.append(max(probs, key=probs.get))  # greedy: most likely token    return " ".join(tokens)print(train(1)[("is",)])  # 4 candidates, 1 count each: 25% eachprint(generate("the capital of egypt is", n=1))print(generate("the capital of atlantis is", n=1))print(generate("the capital of egypt is", n=4))

With one token of context, all the model sees after "is" is four equally likely words, so it picks the first one and says the capital of Egypt is Paris. Atlantis doesn't exist, yet it gets Paris too: nothing comes back "not found", because nothing is searched. With four tokens of context, the same counts give "cairo". The knowledge was there all along; what changed is how much context the prediction used.

MythReality
The model searches a store of factsIt computes a probability for every possible next token
Each answer is a saved entryEach answer is generated token by token, fresh every time
No match means "not found"Some token always wins; saying "I don't know" is learned and can misfire
A wrong fact can be fixed in placeKnowledge is spread across parameters; change the context or retrain
A confident tone means it found the answerRight and wrong answers come out of the same process

How to apply it in your project

  1. Ground factual answers in your own dataFor anything that must be right, such as policies, prices or account details, retrieve it from your system and include it in the prompt.
  2. Fix the context, not the modelWhen the model states a wrong fact, read what was in its prompt first. Missing or ambiguous context is the usual cause, and the fix takes minutes. Retraining is slow and still won't give you a row to edit.
  3. Test with many prompts, not oneAnswers are generated, so a rephrased question or a second run can change them. Evaluate on a set of realistic variations before trusting a feature.
  4. Check what code can checkNumbers, dates, IDs and URLs in model output can be compared against your source of truth before they reach a user.

Key takeaways

  • An LLM doesn't search stored answers: it predicts a probability for every possible next token and generates text one token at a time.
  • Its knowledge lives implicitly in its parameters, so there's no record to read, edit or come back "not found".
  • A wrong answer comes out of the same process as a right one, so fluency isn't evidence.
  • "Just autocomplete" undersells it: inside, a model can chain facts and plan ahead.
  • When facts must be right, put them in the context and check the output.

📚 المصادر

  1. Introduction to Large Language Models — Google Machine Learning Crash Course
  2. LLMs: What's a large language model? — Google Machine Learning Crash Course
  3. Brown et al., Language Models are Few-Shot Learners (GPT-3), arXiv:2005.14165
  4. Roberts, Raffel and Shazeer, How Much Knowledge Can You Pack Into the Parameters of a Language Model?, arXiv:2002.08910
  5. Tracing the thoughts of a large language model — Anthropic

التعليقات (0)