AI6 min read10 interview questionsNew · November

How a language model writes an answer

Tokens, context and why it sometimes gets things wrong.

In one sentenceA language model reads your text as small pieces called tokens and predicts the most likely next piece, over and over, until the answer is finished.

Think of it like thisIt is a very well-read autocomplete: it has seen a huge amount of writing and continues yours in the most fitting way.

The big picture

Tap any step to see where to use it, how to use it and an example result.

Tokens and context

A token is a word or a part of a word. The model can only look at a limited number of tokens at once, called the context window. Anything outside it is invisible to the model, which is why long chats can forget early details.

Why it sounds sure and can still be wrong

The model is built to produce fluent, likely text, not to look facts up. When it does not know, it may still produce a confident guess, often called a hallucination. Giving it the right facts in the prompt, or letting it use tools, reduces this.

Settings that change the answer

Temperature controls how adventurous the choice of the next token is: low is steady and repeatable, high is more varied. Longer prompts and answers cost more and take more time.

Common mistakes

  • Trusting an answer without checking names, numbers and sources.
  • Pasting a huge document and assuming the model remembers every detail.
  • Treating the model as a database of facts.

Quick recap

  • Text is split into tokens
  • The model predicts one token at a time
  • Context is limited
  • Fluent does not mean correct

Try it yourself

Ask a language model the same question three times with different wording and compare. Then paste the facts into the question and see how the answer changes.

Top 10 interview questions

Ordered from basic to advanced. Try answering out loud first, then open the answer.

  1. What is a large language model?Basic

    A neural network trained on huge amounts of text to predict the next piece of text. By doing that very well it can answer questions, write, summarise and translate.

  2. What is a token?Basic

    A chunk of text the model reads and writes, often a word or part of a word. In English one token is roughly three-quarters of a word.

  3. Why do tokens matter for cost and limits?Basic

    Providers usually charge per token, and the model has a maximum number of tokens it can handle at once, covering both your input and its output.

  4. What is a context window?Basic

    The amount of text, counted in tokens, that the model can consider at once. Anything outside it is not seen by the model.

  5. What does temperature control?Intermediate

    How random the output is. Low values give more predictable answers, higher values give more varied and creative ones.

  6. What is a hallucination?Intermediate

    When a model produces something that sounds confident but is false or invented. It happens because the model predicts plausible text rather than checking facts.

  7. How can you reduce hallucinations?Intermediate

    Provide the facts in the prompt, use retrieval so answers come from trusted documents, ask for sources and an honest "I do not know", and verify important outputs.

  8. What are training, fine-tuning and inference?Intermediate

    Training builds the model from large data. Fine-tuning adjusts it on a smaller, specific set. Inference is using the finished model to produce answers.

  9. What is the difference between prompting, RAG and fine-tuning for adding knowledge?Advanced

    Prompting gives instructions or examples at request time. RAG fetches relevant documents and adds them to the prompt, good for changing facts. Fine-tuning changes the model's behaviour or style and is not a good way to add facts that change often.

  10. Why does a model sometimes ignore text in a very long prompt?Advanced

    Attention is spread across many tokens, so details in the middle of long inputs can get less weight. Keep prompts focused, put key instructions clearly at the start or end, and trim irrelevant text.

Back to Learn Hub

Guides are simplified on purpose. Tool names and details change, so check the official documentation before relying on a detail.