Variance — Large language model evaluation | variance-inc.com

Variance — Large language model evaluation | variance-inc.com

Context windows without the guesswork

Explain tokens, accumulated inputs, generated output, stopping limits and why advertised capacity is not a quality score.

A context window is the text a model can reference while generating a response, including the response itself. It is not the model's training corpus. That distinction matters because people often read a large window as a measure of knowledge, when it is a measure of how much text can be in view at once.

Prompts, messages, tool results, documents, tool definitions and generated output can all consume context. The exact inclusion varies by provider and model, so the only reliable way to know your budget is to read the provider's documentation for the model you are using.

A language model generates the next token from the prompt and prior generated output, stopping at a configured length or an end-of-sequence token. This is the mechanism behind most length surprises. The model does not know your intended length unless the prompt or the configuration says so.

Hugging Face documents max_new_tokens as a generation-length control. It limits how much new text is produced. It does not control the prompt length, and it does not guarantee that the answer is complete; it only caps the new tokens.

With a decoder-only model, a result may include the initial prompt unless your code separates it. If you count tokens on the raw result, you may be counting the prompt as output. Separate them before you measure length or grade content.

Greedy decoding and sampling are different modes. Hugging Face distinguishes them and advises checking the model's expected prompt or chat template. A model that expects a chat template may behave differently when given a raw string, and that difference can look like a quality problem.

The signature mark of this site, drawn as a plate

On narrow screens, swipe or scroll the plate sideways.

Anthropic cautions that larger context does not automatically improve answers and recommends curating relevant context as conversations grow. Capacity is a limit, not a quality score. A long conversation with irrelevant history can perform worse than a short one with the right context.

For testing, decide the context sizes you expect in real use and test at those sizes. If your real inputs are short, a test with very long contexts measures a situation you do not have. If your real inputs are long, test with long inputs and note where truncation begins.

When an answer is cut off, check three things in order: the output limit, the total context budget, and whether the result includes the prompt. Each has a different fix, and guessing at the cause wastes runs.

Write down the configuration you used: model, prompt template, decoding mode, output limit and context size. Without that, a result cannot be reproduced, and an unreproducible result cannot guide a decision.

To build a test package, write the system instruction first, then the user messages, then any reference material, and finally leave a clearly marked place for the answer. Keep each part in its own field so you can count them separately. State the size of each part in your notes, and label the package as your own test setup. Do not present a made-up example as if it were a provider's real limit. The goal is a package you can rerun and compare, not a claim about what any vendor allows.

To tell a total-context overflow from an output-length cap, watch where the failure appears. If the request is rejected before any text is produced, suspect the total budget. If text starts and then stops mid-sentence, suspect the output limit. Confirm by lowering only the output limit or only the input size, one at a time. Then check the chosen provider's documentation for how it reports each case, because error messages and behavior differ between providers.

  • Context window: text in view, including the response, not the training corpus.
  • max_new_tokens: a cap on new text, not a completeness guarantee.
  • Decoder-only result: may include the prompt unless code separates it.
  • Chat template: check the expected format before comparing outputs.

Questions and answers

Does a bigger context window mean a better model?
No. Anthropic cautions that larger context does not automatically improve answers and recommends curating relevant context. Capacity is a limit on what can be in view, not a measure of quality. Test at the context sizes you actually expect, with the inputs you actually receive.
Why does my output include the prompt?
With a decoder-only model, the result may include the initial prompt unless your code separates it. Hugging Face documents this behavior. Check your code and count only the new text before you measure length or grade content, or your results will be distorted.
What stops a model from generating forever?
A configured length or an end-of-sequence token stops generation. Hugging Face documents max_new_tokens as a generation-length control. Without a configured limit, generation can continue until the model produces an end-of-sequence token or the context budget is exhausted.

Further reading