An Uncertainty Budget for LLM Systems: Finding Risk Across Retrieval, Tools, and Generation
An Uncertainty Budget for LLM Systems: Finding Risk Across Retrieval, Tools, and Generation
- Details
- Category: Language & Agentic AI
An LLM system does not become reliable because the model is fluent. It becomes reliable when weak evidence, incomplete tool results, unsupported claims, and uncertain decisions are detected before they create operational harm.
The difficulty is that uncertainty rarely belongs to one component. A weak answer can result from incomplete retrieval, poor context construction, unsupported generation, stale memory, partial tool output, invalid formatting, or inconsistent human review.
Collapsing these failures into one final quality score makes the system difficult to debug. A low score says that something went wrong, but it does not show whether the team should change the retriever, the prompt, the tool contract, the model, or the review process.
This article uses an uncertainty budget as an engineering diagnostic. The budget assigns observable evidence gaps to workflow stages, adjusts them by risk, and connects the dominant sources with actions such as additional retrieval, tool verification, clarification, refusal, or human review.
The budget is not a calibrated probability that an answer is wrong. It is a structured way to decide where the system lacks evidence and where engineering effort is most likely to reduce risk.
The production decision is whether the system has enough evidence to answer
Consider an internal assistant that answers questions about deployment policy.
A user asks whether a production change can be released without manual approval. The system retrieves policy documents, checks the current deployment state through a tool, and produces a recommendation.
The answer may influence a real release. A fluent but unsupported response can therefore create more harm than an explicit request for review.
Several failures can produce the same incorrect recommendation. Retrieval may omit the approval policy. A tool may return only part of the deployment record. The model may combine correct passages into an unsupported conclusion. The final response may also omit a required review status.
| Stage | Possible failure | Appropriate response |
|---|---|---|
| Retrieval | The required policy or recent amendment is missing | Retrieve again, change the query, or request clarification |
| Generation | The conclusion is not supported by the retrieved evidence | Restrict the answer, add source support, or refuse the claim |
| Tool use | The deployment tool returns partial or stale state | Verify completeness before recommending an action |
| Output contract | The response omits a required approval status | Reject the output through schema validation |
| Human review | Reviewers apply different approval criteria | Clarify the rubric and audit disagreement |
Changing the language model will not repair every one of these failures. The engineering response depends on where the evidence chain became weak.
A single answer score hides the source of failure
A common evaluation process assigns one score to the final response. The score may combine correctness, relevance, style, completeness, and source use.
This approach is useful for release comparison. It can show whether one system version performs better than another on a reviewed evaluation set.
It becomes insufficient for diagnosis. A response can be wrong because the required evidence was never retrieved. Another response can contain the correct evidence but draw an unsupported conclusion. Both may receive the same final score while requiring different fixes.
The same problem appears in production monitoring. An average answer-quality metric can decline without showing whether the cause is a document update, an index change, a model release, a tool outage, or a modified review rubric.
A useful evaluation system should preserve final quality metrics while also measuring the stages that contribute to the result.
The workflow should preserve evidence from request to decision
An LLM application processes information through several dependent stages. It first interprets the user request, then collects external evidence, prepares the model context, generates an answer, and passes that answer to a person or downstream system.
Reliability depends on preserving meaning and evidence across the complete path. A failure introduced early in the workflow can remain hidden because later stages may still produce fluent and correctly formatted output.
| Stage | Responsibility | Possible information loss |
|---|---|---|
| Request interpretation | Identify the user's intent, constraints, and required decision | An ambiguous request is converted into the wrong search or task |
| Evidence collection | Retrieve documents, memory, or tool results needed for the answer | Relevant evidence is missing, stale, filtered out, or only partially returned |
| Context construction | Select, order, and format evidence for the model | Important passages are truncated, duplicated, or placed where they receive insufficient attention |
| Answer generation | Transform the available evidence into claims and recommendations | The model adds unsupported assumptions or overstates what the evidence establishes |
| Decision consumption | Use the answer in a human or automated workflow | A qualified response is interpreted as a definitive instruction |
This decomposition makes diagnosis more precise. Missing evidence should lead to retrieval or tool investigation. Correct evidence combined with an unsupported conclusion points to generation or evaluation. A technically accurate but misleadingly presented answer requires changes in the output contract or downstream decision policy.
The RAG paper by Lewis et al. combines retrieval with generation so that external documents can inform an answer. This architecture creates an explicit evidence layer, but it does not guarantee that the required source will be retrieved, retained in the final context, or used correctly by the model.
The budget is a diagnostic allocation, not a probability
Assume that the workflow contains stages \(s = 1, \ldots, m\).
For each stage, define an evidence score \(e_s\) between zero and one. A larger value means that the available checks provide stronger support for the stage output.
Define a risk weight \(w_s\) representing the operational consequence of failure in that stage.
A simple raw risk score is:
$$u_s = w_s(1 - e_s)$$
The normalized uncertainty allocation is:
$$b_s = \frac{u_s}{\sum_{j=1}^{m} u_j}$$
The value \(b_s\) describes the share of measured risk assigned to stage \(s\) under the selected policy.
It should not be interpreted as the probability that the stage caused an incorrect answer. The stages may depend on one another, the evidence checks may be heuristic, and several failures may occur in the same trace.
The budget is useful because it makes the scoring policy inspectable. Engineers can see which checks produced each stage score, which weights represent business risk, and which routing rule follows from the result.
Evidence scores should come from observable checks
An LLM stating that it is confident is not enough to justify a high evidence score.
The study Language Models (Mostly) Know What They Know shows that model confidence signals can contain information about correctness under selected experimental conditions. This does not make every verbal confidence statement calibrated or reliable across tasks.
Stage scores should therefore be derived from checks that can be validated against observed failures.
| Stage | Possible evidence inputs | What the score does not prove |
|---|---|---|
| Retrieval | Expected-source coverage, Recall at k, freshness, and passage relevance | That the model used the evidence correctly |
| Generation | Claim support, contradiction checks, evaluator agreement, and answer consistency | That the conclusion is causal or universally correct |
| Tool use | Execution status, completeness, freshness, schema validity, and side-effect confirmation | That the underlying data source is correct |
| Formatting | Schema validation, required fields, types, and parsing success | That the semantic content is correct |
| Review | Reviewer agreement, audit coverage, and correction rate | That reviewers share a correct policy |
The score definition should remain stable long enough to compare traces and system versions. When the scoring policy changes, its version should change as well.
Retrieval uncertainty begins with evidence coverage
A retrieval system can return plausible passages while missing the one source required to answer the question safely.
For reviewed evaluation cases, the team can define an expected evidence set \(G(q)\) for query \(q\). If the retriever returns \(R_k(q)\), evidence recall can be measured as:
$$Recall@k = \frac{|R_k(q) \cap G(q)|}{|G(q)|}$$
This metric is useful when the relevant evidence set is known. In open-ended production traffic, the complete set is often unavailable. The system may instead use required source types, freshness checks, query diagnostics, or sampled human review.
Context length does not remove retrieval uncertainty. The Lost in the Middle study shows that model performance can depend on where relevant information appears in a long context. Supplying more text does not guarantee that the model will use the required evidence effectively.
Retrieval monitoring should therefore include both candidate quality and context construction. A required passage can be retrieved and still become ineffective after truncation, ordering, duplication, or prompt assembly.
Generation uncertainty should focus on supported claims
The internal reasoning of a language model is not directly observable as a verified computational proof. A fluent rationale can contain unsupported steps or reconstruct a plausible explanation after producing an answer.
For production evaluation, it is usually more useful to inspect the material claims in the final output and compare them with the available evidence.
A claim-support check can classify each important statement as supported, contradicted, or not established by the retrieved sources and tool results.
For \(n\) material claims, a simple support ratio is:
$$SupportRate = \frac{N_{supported}}{n}$$
This value depends on claim extraction and evaluator quality. It should be validated against manually reviewed examples rather than treated as automatic ground truth.
Repeated sampling or evaluator agreement can provide additional signals, but consistency alone does not prove correctness. A model can repeat the same unsupported conclusion reliably.
Tool uncertainty requires explicit completeness semantics
A tool call can succeed technically while returning incomplete evidence.
An API may return the first page of records without indicating that more pages exist. A search service may time out after returning partial results. A deployment tool may report the requested service while omitting a dependent component.
The model should not infer completeness from a successful transport status.
A tool contract should distinguish complete success, partial success, failure, and unknown state. It should also define freshness, pagination, retries, idempotency, and side effects.
tool_result = {
"status": "partial_success",
"records_returned": 50,
"records_expected": 120,
"freshness": "2026-07-29T20:10:00Z",
"continuation_token": "page-2",
}
This record provides a measurable reason to lower the tool-use evidence score. A plain list of fifty records would not reveal that seventy records were still missing.
Formatting uncertainty should be handled deterministically
Output formatting is one of the easier uncertainty sources to control.
If a downstream consumer expects a structured object, the output should be validated against a schema. Required fields, data types, allowed values, and cross-field rules can be checked before the result reaches the consumer.
A response that fails parsing should not be accepted because its prose looks reasonable. It should be repaired through a bounded retry, routed to review, or rejected according to the workflow policy.
Separating formatting from semantic quality improves diagnosis. A valid JSON object can contain a false claim, while a correct answer can still violate the API contract. These are different failures.
Human review introduces another source of uncertainty
Human review is often treated as the final source of truth. Reviewers can still disagree, miss evidence, or apply changing standards.
Review uncertainty can be measured through agreement, sampled audits, correction rates, and adjudication outcomes.
Low agreement may indicate an ambiguous case rather than poor reviewer quality. It can also reveal that the rubric does not define the expected decision precisely enough.
Corrections should preserve the reviewer, rubric version, reason, and evidence used. Otherwise, review data can become a noisy training signal that hides policy changes.
A budget calculated from explicit stage checks
The following Python example calculates an uncertainty allocation for one synthetic answer trace.
Each stage contains observable checks scored between zero and one. The risk weights represent the relative consequence assigned by the example policy.
The values are illustrative. They are not calibrated probabilities and do not come from a deployed LLM system.
from dataclasses import dataclass
from statistics import mean
@dataclass(frozen=True)
class StageEvidence:
checks: tuple[float, ...]
risk_weight: float
note: str
stages = {
"retrieval": StageEvidence(
(1 / 3, 0.50),
1.4,
"one expected source retrieved; half of key claims supported",
),
"generation": StageEvidence(
(0.75, 0.70),
1.0,
"claim support and evaluator agreement",
),
"tool_use": StageEvidence(
(0.50, 1.00),
1.3,
"partial records returned; schema valid",
),
"format": StageEvidence(
(1.00, 1.00),
0.5,
"response schema and required fields valid",
),
"review": StageEvidence(
(0.80, 0.75),
0.8,
"reviewer agreement and audit coverage",
),
}
evidence_scores = {
name: mean(stage.checks)
for name, stage in stages.items()
}
raw_risk = {
name: (1.0 - evidence_scores[name]) * stage.risk_weight
for name, stage in stages.items()
}
total_risk = sum(raw_risk.values())
budget = {
name: value / total_risk
for name, value in raw_risk.items()
}
largest_source = max(budget, key=budget.get)
reasons = []
if evidence_scores["retrieval"] < 0.60:
reasons.append("retrieve_more_evidence")
if evidence_scores["tool_use"] < 0.80:
reasons.append("verify_partial_tool_result")
decision = "needs_more_evidence" if reasons else "answer"
print(f"decision={decision}")
print(f"largest_source={largest_source}")
print({name: round(value, 3) for name, value in budget.items()})
print(f"reasons={reasons}")
The following output was produced by executing the code:
decision=needs_more_evidence
largest_source=retrieval
{'retrieval': 0.511, 'generation': 0.172, 'tool_use': 0.204, 'format': 0.0, 'review': 0.113}
reasons=['retrieve_more_evidence', 'verify_partial_tool_result']
The result identifies two different blockers
Retrieval receives 0.511 of the normalized budget. The trace retrieved only one of three expected sources, and the second retrieval check shows that only half of the required evidence was covered.
Tool use receives 0.204. The result matched the required schema, but only part of the expected record set was returned.
Formatting receives zero because both formatting checks passed. This does not mean that the answer is correct. It means that the formatting layer did not contribute measured risk under this policy.
The final decision is needs_more_evidence. The system should retrieve additional sources and verify the partial tool result before producing a deployment recommendation.
The budget does not prove that retrieval caused an incorrect answer. It shows that retrieval currently contains the largest measured evidence gap and should receive attention first.
Risk weights should reflect consequences
The same evidence score can require different responses in different applications.
Missing retrieval evidence in a low-risk brainstorming assistant may justify a qualification in the answer. The same gap in a compliance or deployment workflow may require refusal or human approval.
Risk weights should therefore be connected to the consequence and reversibility of stage failure.
| Workflow | High-weight stage | Reason |
|---|---|---|
| Policy assistant | Retrieval and source freshness | Missing policy evidence can create an invalid recommendation |
| Deployment agent | Tool execution and approval | An incorrect action can change production state |
| Structured extraction service | Schema and validation | Malformed output can corrupt downstream records |
The weights should be versioned with the routing policy. Changing a weight changes the operational meaning of the budget.
The budget should change system behavior
A diagnostic that appears only in a dashboard does not protect the user.
The budget should connect defined conditions with bounded actions.
| Dominant source | Possible action | Required evidence before continuing |
|---|---|---|
| Retrieval | Rewrite the query, search another index, or request clarification | Required evidence coverage or explicit acknowledgement of missing sources |
| Generation | Restrict claims, regenerate with evidence constraints, or refuse | Material claims supported by retrieved or tool-provided evidence |
| Tool use | Retry safely, follow pagination, verify state, or request approval | Complete and fresh tool result with known side-effect status |
| Formatting | Repair through a bounded retry or reject the result | Valid schema and business constraints |
| Review | Escalate to adjudication or revise the rubric | Resolved disagreement and documented decision rule |
The thresholds should be tested against real failures. A retrieval score below 0.60 has no universal meaning outside the policy and dataset used to validate it.
Validation requires known root causes
An uncertainty budget is useful only when its dominant component corresponds reasonably well with the actual failure cause.
The evaluation set should contain cases with controlled retrieval omissions, unsupported generation, partial tool output, invalid schemas, and reviewer disagreement.
For every case, the team should record the expected root cause and required operational action. The budget can then be evaluated as a routing mechanism rather than only as a numerical summary.
Useful measurements include root-cause classification accuracy, unnecessary escalation rate, missed-risk rate, and time required to identify the failing layer.
A budget that assigns every failure to generation provides little value even if its final risk score correlates with answer quality.
Component signals should be evaluated separately
A useful combined budget can still contain a weak component detector.
Retrieval coverage should be evaluated against reviewed relevance data. Claim support should be evaluated against human-labelled support judgements. Tool completeness should be tested with partial responses, stale records, and pagination failures.
The combined routing policy should be evaluated only after the component checks have acceptable behavior under representative conditions.
This separation makes it possible to determine whether a bad routing decision came from the normalization formula or from one unreliable stage score.
Automated evaluators add uncertainty of their own
Many LLM systems use language models to judge relevance, correctness, support, or style.
These evaluators can reduce review cost, but their output is another model prediction. It may depend on prompt wording, response order, model version, and the examples included in the evaluator context.
Evaluator agreement should be checked against reviewed data. High-impact decisions may require sampled human audits or independent evaluators.
The uncertainty budget should not hide evaluator uncertainty inside a precise-looking stage score. The evaluator model, prompt, and validation dataset should be versioned with the result.
Runtime and engineering budgets serve different purposes
A runtime budget determines what should happen to one answer trace. It can route the trace to more retrieval, clarification, refusal, or review.
An engineering budget aggregates many traces to identify where development effort should be invested.
For example, retrieval may dominate the runtime budget for a small number of difficult questions, while tool failures may account for most production incidents and correction time.
The engineering view should therefore combine measured uncertainty with frequency, consequence, and remediation cost.
A low-frequency stage with severe consequences may deserve more attention than the most common minor evidence gap.
The trace must preserve the evidence behind the budget
Storing only the normalized percentages is insufficient.
The trace should preserve the raw checks, their versions, the risk weights, the retrieved evidence, tool status, evaluator configuration, and final routing decision.
evaluation_record = {
"answer_id": "llm-2026-07-29-018",
"policy_version": "uncertainty-budget-v3",
"retrieval": {
"index_version": "policies-2026-07-28",
"expected_sources": 3,
"retrieved_expected_sources": 1,
},
"tool_use": {
"status": "partial_success",
"records_returned": 50,
"records_expected": 120,
},
"decision": "needs_more_evidence",
}
This record allows the team to reconstruct why the answer was not released automatically.
It also allows a later policy version to recalculate the decision from the original evidence rather than from a rounded budget percentage.
Memory and stale state require separate checks
An assistant may use conversation state, user preferences, or durable memory in addition to retrieval and tools.
Memory can become stale, incorrectly scoped, or inconsistent with current evidence. A previously valid deployment rule may no longer apply after a policy change.
Memory should preserve its source, creation time, scope, and review status. Current authoritative evidence should override older inferred memory when the two conflict.
Memory uncertainty can be represented as its own budget stage or incorporated into context construction. The choice depends on whether the system has independent memory policies and controls.
Correct refusal belongs in the evaluation set
An evaluation suite that rewards only complete answers creates the wrong operational incentive.
The dataset should include underspecified requests, unavailable evidence, conflicting sources, failed tools, and cases requiring approval.
The expected result for some examples should be clarification, review, or refusal.
A system that answers every question can achieve high apparent coverage while creating unacceptable unsupported claims. Responsible routing should be measured as part of task quality.
The budget remains a model of risk
The selected stages may omit an important failure source. The checks may be poorly calibrated. The weights may not match real consequences. Several stage failures may also interact in ways that a normalized additive budget does not represent.
Moderate retrieval uncertainty and moderate generation uncertainty may combine into a severe unsupported conclusion. Normalization can also make one stage appear small when total measured risk is large.
The raw risk values and absolute routing thresholds should therefore remain available alongside the normalized allocation.
The budget should be revised when incidents reveal missing signals or incorrect assumptions. It is an operational model that must be tested and maintained.
Production implementation needs three control layers
- Measurement control: calculate stage-specific evidence signals from retrieval, generation, tools, formatting, memory, and review.
- Routing control: connect risk conditions to additional evidence, clarification, refusal, approval, or human review.
- Learning control: preserve incidents, root causes, reviewer corrections, and policy outcomes as future regression cases.
The first implementation should use a small number of signals tied to known failure modes. Adding more scores does not improve reliability when their meaning and response policy are unclear.
The budget becomes valuable when it shortens diagnosis and prevents weak evidence from being presented as a confident decision.
Key takeaways
- An LLM uncertainty budget should separate retrieval, generation, tool, formatting, memory, and review risk instead of assigning every failure to the model.
- Normalized stage values are diagnostic allocations, not calibrated probabilities, so their checks, weights, and limitations must remain visible.
- Uncertainty becomes operationally useful only when it changes routing through additional evidence, clarification, refusal, approval, or review.
Sources
- Lewis, P., Perez, E., Piktus, A., et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. Advances in Neural Information Processing Systems, 33, 9459-9474.
- Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., and Liang, P. (2024). Lost in the Middle: How Language Models Use Long Contexts. Transactions of the Association for Computational Linguistics, 12, 157-173.
- Kadavath, S., Conerly, T., Askell, A., et al. (2022). Language Models (Mostly) Know What They Know. arXiv:2207.05221.