LyraLearn AI Learning Platform
Exams
← Module 12 Β· Gap Drills: The Mechanical Layer
🎧 Listen

What an LLM Actually Does

The single most common wrong mental model about LLMs β€” held by many working engineers β€” is that the model "searches its knowledge base" for the closest match to your question. It feels right because vector search exists nearby (in RAG systems), but it describes the wrong component. If you carry this model into an interview, an AI-literate panelist will hear it immediately. This lesson replaces it.

The correct model: a next-token predictor

An LLM does exactly one thing. Given a sequence of tokens, it outputs a probability distribution over what token comes next. That's the whole machine.

Two consequences worth saying out loud in interviews:

The context window is the model's entire working memory. The model can only condition on the tokens in front of it β€” the system prompt, the conversation, any documents you pasted. That's why "give the model good context" is the core engineering activity of the whole LLM era: what's in the window is the only thing the model knows for sure, as opposed to what it vaguely absorbed at training time.

Temperature is choice among plausible tokens. The model produces a probability distribution; sampling settings decide whether it always takes the top choice (deterministic, good for structured tasks) or samples more adventurously (varied, good for creative tasks).

Why hallucination is structural, not a bug

Now the hallucination answer writes itself, and it's much stronger than "vector search is approximate":

The model's objective is plausibility, not truth. It always produces a fluent next token β€” including where its training data was thin, contradictory, or silent. A correct answer and a confident fabrication are generated by the same mechanism; the model has no internal fact-checker and, by default, no mechanism for "I don't know." It doesn't know that it doesn't know.

This is why hallucination can't be "fixed" from inside β€” and why the entire responsible-AI toolkit exists on the outside: retrieval grounds answers in real documents, citations make them checkable, instructions permit "I don't know," thresholds route uncertainty to humans, and evaluation measures how often the whole assembly is right. One sentence to keep: truth is added to an LLM system from outside the model.

Where the "vector search" confusion comes from

Vector search is real β€” it's just a different component. Embedding models and vector indexes live in the RAG layer that engineers bolt on around an LLM (next lesson). The confusion is understandable: both involve "closeness of meaning." Keep them apart with this rule: embeddings retrieve, the LLM generates. If someone asks "how does the model find the answer?", the correct reply is: it doesn't find anything β€” it writes the answer, and if you want the writing grounded in real sources, you must find those sources and put them in the context window first.

Interview drill

Practice these three out loud until they're automatic:

  1. "What is an LLM doing when it answers?" β€” Next-token prediction: knowledge lives in trained weights, answers are generated token by token, nothing is retrieved internally.
  2. "Why do LLMs hallucinate?" β€” Objective is plausibility, not truth; same mechanism produces right and wrong answers; no built-in fact-checker; that's why grounding and verification are external.
  3. "What's the context window?" β€” The model's only working memory; everything reliable the system does depends on what engineering puts into it.
🧠 Quiz yourself on this lesson →

Ask the AI Tutor

Grounded in the course lessons β€” it cites its sources and says when it doesn't know.