Getting Better Answers Within the Context Window: Retrieval, Temperature and Response Shaping

This post is a practical, scenario-led guide covering three core skills for getting better output from large language models: selecting only the relevant document sections for context window retrieval, understanding what temperature actually does to token probability distributions, and using respon

Getting Better Answers Within the Context Window: Retrieval, Temperature and Response Shaping
Quick answer

Send the model only the parts of a document that answer your question, not the whole thing, because irrelevant context dilutes the answer. Set temperature on purpose: low (about 0 to 0.3) for configs and procedures, higher for brainstorming. Then tell the model the exact structure and length you want back, which is called response shaping.

You have a 50-page network runbook and you need the AI to help you write a change procedure for a BGP route reflector failover. The tempting move is to paste the whole document into the prompt and let the model figure it out. It feels thorough. It is actually one of the most common mistakes engineers make when working with large language models, and it costs you accuracy, speed, and tokens.

This post walks through three decisions you will face constantly when using AI in an IT workflow: what to send, how creative to let the model be, and how to control the shape of the answer you get back.

Selective Context Window Retrieval: Send Less, Get More

Every LLM has a context window, the total number of tokens it can process at once across your prompt, any retrieved content, and its own response. Filling that window with irrelevant content does not make the model smarter. It introduces noise and can dilute the signal your actual question provides.

The right approach is targeted extraction before you prompt. Instead of pasting the full runbook, pull only the section that covers BGP configuration, the relevant IP addressing table, and the escalation procedure. That is probably three pages instead of fifty.

This is the foundation of context window retrieval done well. In production systems, this is handled by vector databases and retrieval-augmented generation (RAG) pipelines. At the individual workflow level, you do it manually by reading the document and selecting the relevant chunks. Either way, the principle is identical: match the retrieved content to the specific question before it enters the context window.

A quick way to think about it:

  • Too much context: the model averages across everything and produces generic output
  • Targeted context: the model grounds its response in exactly what matters for your task

Temperature Explained: What It Actually Controls

Temperature is one of those settings that gets described as "creativity," which is technically true but not very useful when you need to decide what value to set.

Here is the accurate version: when an LLM generates each token, it calculates a probability distribution across its entire vocabulary. Temperature scales that distribution before the model samples from it. A low temperature (closer to 0) makes high-probability tokens dramatically more likely. The model plays it safe and picks the statistically expected word almost every time. A high temperature (closer to 1 or above) flattens the distribution, making lower-probability tokens more competitive. The model takes more risks and produces more varied output.

For IT use cases, the practical mapping looks like this:

  • Temperature 0.0 to 0.3: configuration generation, change procedures, structured output, anything where correctness matters more than variety
  • Temperature 0.5 to 0.7: drafting documentation, summarizing tickets, writing clear but not robotic prose
  • Temperature 0.8 to 1.0: brainstorming, generating multiple options you will evaluate, creative naming or phrasing tasks

The wrong choice is leaving temperature at the default and assuming the model will intuit when to be careful. For anything going into a production change window, set it low explicitly.

Response Shaping: Getting Shorter LLM Answers With the Right Structure

Even with clean context and the right temperature, models will often over-explain. If you ask for a BGP failover procedure, you may get a three-paragraph history of BGP before the actual steps. This is not a bug in the model. It is a reflection of how language models are trained. Without constraints, they default to comprehensive.

The fix is to instruct the model on the exact elements your answer must contain. This is response shaping, and it is the most underused technique for getting shorter LLM answers that are actually more useful.

Compare these two prompts:

Prompt A: "Write a BGP route reflector failover procedure."

Prompt B: "Write a BGP route reflector failover procedure. 
Structure your answer as: 
1. Pre-checks (maximum 3 bullet points)
2. Failover steps (numbered, CLI commands inline)
3. Validation commands (numbered, one per line)
4. Rollback trigger (one sentence)
Do not include background on BGP or explanatory prose."

Prompt B will consistently return something you can hand to a technician. Prompt A is a starting point that requires editing. For recurring tasks, build the structure into a saved prompt template so you are not writing it from scratch each time.

Quick Decision Checklist

  1. Have you identified which sections of your source document are actually relevant before prompting?
  2. Have you set temperature explicitly based on whether this task requires correctness or variety?
  3. Have you told the model the exact structure, sections, and length constraints you expect in its response?

These three questions cover the majority of output quality problems engineers run into when using AI for technical tasks. They cost almost no extra time once they become habit.

Context, temperature and response shaping: common questions

What is a context window?

The total number of tokens a model can work with at once, covering your prompt, any retrieved content and the model's own response.

Why not paste a whole document into the prompt?

Irrelevant text adds noise and dilutes the part that matters, so answers get more generic. It also costs more tokens and takes longer. Extract the relevant sections first.

What temperature should I use for configuration work?

A low setting, around 0.0 to 0.3, where correctness matters more than variety. Set it explicitly rather than relying on the default.

What does temperature actually do?

It scales the probability distribution the model samples each token from. Low values favour the most likely tokens; higher values flatten the distribution so less likely tokens get picked more often.

How do I get shorter, more useful answers?

Spell out the exact sections, order and limits you want, for example "pre-checks, maximum 3 bullets; numbered steps; one-line rollback trigger; no background", and save it as a template for recurring tasks.

What's Next

Now that you can shape what goes into a prompt and what comes out, the next logical step is understanding how to evaluate whether the output is actually trustworthy. The next post covers hallucination, grounding, and how to build simple verification steps into your AI-assisted workflows.

๐Ÿ”ง
If you are regularly pulling targeted sections from large runbooks or technical documents, a tool like Notion AI or Confluence with smart search can help you surface the right chunks fast before they ever hit your prompt. Obsidian is also worth a look for engineers who want a local, structured knowledge base they control. Notion AI, Obsidian and Confluence.