Independent Verification of LLM End-to-End Task Performance and Hallucination Rates

    Vendor-published accuracy and hallucination rates come from internal test sets with undisclosed methodology, making them unreliable for deployment decisions. This article presents a practical framework for independently verifying large language model task performance, covering end-to-end task decomposition, hallucination classification, statistical measurement with confidence intervals and significance testing, evaluation set design, agent permission controls, and a pre-launch checklist with code examples.

    Independent Verification of LLM End-to-End Task Performance and Hallucination Rates

    Background and Limitations

    When a model is released, vendors typically publish task completion speed, accuracy, and hallucination rates. These figures are useful references, but they come from test sets built by the vendors themselves. The sample distribution, prompt templates, and judging criteria are not disclosed, and the same “hallucination rate” can vary widely across different test sets. Before selecting or deploying a model, developers should therefore run independent verification using samples that closely resemble their own business data, rather than taking vendor numbers at face value.

    Independent verification has its own limits. If the evaluation set is too small, results will fluctuate randomly. If judging criteria are vague, results will differ between annotators. If the evaluation environment differs from production, results are hard to extrapolate. The methods in this article help you judge whether results are trustworthy, but they do not replace continuous monitoring after launch.

    In practice, prepare at least several hundred business samples for each candidate model, and record the sample source, distribution, and annotation rules. With too few samples, treat conclusions as rough references only.

    Decomposing End-to-End Tasks

    An end-to-end task covers the full pipeline from a user’s request to a deliverable result. It usually involves five stages:

    • Understanding requirements: identify goals, constraints, and acceptance criteria;
    • Planning steps: break down subtasks and determine execution order;
    • Executing operations: read and write files, query data, call external tools;
    • Self-verification: run tests, compare against sources, check output format;
    • Delivering results: generate code, reports, or data tables, and explain the reasoning.

    An error in a single-turn Q&A usually affects only one answer. In end-to-end tasks, errors accumulate along the pipeline. If requirement understanding is off, every subsequent step may proceed in the wrong direction. When evaluating, do not just check whether the final answer reads fluently—verify that each stage is traceable.

    The table below shows a common way to decompose evaluation:

    Stage Input Expected Output Verification Method Failure Attribution Example
    Understanding requirements Raw user description List of goals and acceptance criteria Human scoring Missed a constraint
    Planning steps Acceptance criteria Subtasks and execution order Rule-based checks Wrong step ordering
    Executing operations Subtasks File modifications or query results Executable tests Called a non-existent parameter
    Self-verification Execution results Test report or source comparison Rule-based checks Failed to catch an obvious error
    Delivering results All intermediate artifacts Code, report, or data table Human scoring Conclusion exceeded the evidence

    By scenario, common tasks fall into three categories. Software engineering tasks require locating code from a bug description, modifying the implementation, and passing unit tests. Knowledge work tasks require retrieving multiple documents, summarizing findings, and citing sources. Scientific workflow tasks require cleaning experimental data, running statistical analysis, and generating charts and draft conclusions. Each category requires different verification methods, so design separate evaluation sets for each.

    Hallucination Classification and Measurement Methods

    A hallucination occurs when a model’s output contradicts objective facts or is inconsistent with the provided material. For engineering evaluation, classify hallucinations into three types and measure them separately:

    1. Factual hallucination: a statement contradicts publicly known facts, such as a wrong version number, name, or date.
      • Positive case: citing a stable version of a library that was never released—count as a hallucination.
      • Negative case: citing an older but genuinely existing version number with a note such as “as of a certain date”—do not count as a hallucination.
    2. Faithfulness hallucination: a summary or paraphrase goes beyond the source text and adds conclusions that were not present.
      • Positive case: the source only says “response time has decreased somewhat,” but the summary claims “response time cut in half.”
      • Negative case: the summary restates the original conclusion in plainer words without changing the meaning—do not count as a hallucination.
    3. Tool-call hallucination: referencing non-existent functions, parameters, or file paths, or fabricating tool return values.
      • Positive case: calling an export_report function that does not exist in the documentation.
      • Negative case: the tool returns an empty result and the model honestly answers “not found”—do not count as a hallucination.

    The measurement process has four steps.

    Step 1: Build labeled samples per scenario. Each category should contain at least several dozen samples, with sources recorded.

    Step 2: Write judging rules. Specify exactly what counts as a hallucination, with positive and negative examples, to prevent inconsistent interpretations among annotators.

    Step 3: Have two annotators judge independently and compute agreement. The common metric is Cohen’s kappa, calculated as κ = (p_o − p_e) / (1 − p_e), where p_o is the observed agreement rate and p_e is the expected agreement by chance. A kappa above 0.6 is a typical starting point, but set the threshold based on business risk. Disputed samples go to a third annotator for adjudication, with reasons recorded.

    Step 4: Compute the hallucination rate with a confidence interval. With small samples, point estimates of proportions fluctuate considerably, and a single percentage is easy to misread. The following code computes the Wilson interval for a single model’s hallucination rate:

    1. import math
    2. def wilson_interval(hallucinations, total, z=1.96):
    3. """Wilson confidence interval for a single proportion, 95% by default.
    4. This is not a test for comparing two models; it only describes
    5. the uncertainty range of a single proportion."""
    6. if total == 0:
    7. raise ValueError("Sample size cannot be 0")
    8. p = hallucinations / total
    9. denominator = 1 + z**2 / total
    10. center = (p + z**2 / (2 * total)) / denominator
    11. half_width = z * math.sqrt(p * (1 - p) / total + z**2 / (4 * total**2)) / denominator
    12. return (center - half_width, center + half_width)
    13. hallucinations, total = 37, 500 # example data, fictitious
    14. lower, upper = wilson_interval(hallucinations, total)
    15. print(f"Hallucination rate {hallucinations/total:.1%}, 95% CI [{lower:.1%}, {upper:.1%}]")

    In this example, 37 hallucinations out of 500 samples give a point estimate of 7.4%, with a 95% confidence interval of roughly 5.4% to 10.0%.

    When comparing two models, use a difference test. The following code performs a two-proportion z-test on two independent samples:

    1. import math
    2. def two_proportion_test(x1, n1, x2, n2):
    3. """Two-proportion z-test on independent samples; returns z and two-sided p-value.
    4. If both sets of results come from the same paired cases, use McNemar's test instead."""
    5. if n1 == 0 or n2 == 0:
    6. raise ValueError("Sample size cannot be 0")
    7. p1, p2 = x1 / n1, x2 / n2
    8. p = (x1 + x2) / (n1 + n2)
    9. standard_error = math.sqrt(p * (1 - p) * (1 / n1 + 1 / n2))
    10. if standard_error == 0:
    11. return 0.0, 1.0
    12. z = (p1 - p2) / standard_error
    13. p_value = math.erfc(abs(z) / math.sqrt(2))
    14. return z, p_value

    One caveat deserves special attention: non-overlapping confidence intervals between two models can serve as a conservative signal of a difference, but overlapping intervals do not prove the models are equivalent. To judge differences, use a proportion difference test or a bootstrap method. Before comparing, also confirm that the two sample sets are independent, judged by the same criteria, and annotated with the same rules.

    Evaluation Sets and Agent Permission Controls

    An evaluation set should cover three levels: single-step tasks test basic capability; multi-step tasks test planning and state retention; tasks with external tools test call accuracy and fault tolerance. Each case should include an input, expected output, and verification method. There are three main verification approaches:

    • Executable tests: e.g., run unit tests and judge by pass rate;
    • Rule-based checks: e.g., whether required fields are present, whether values fall in a reasonable range;
    • Human scoring: for open-ended tasks such as writing that cannot be automatically judged.

    Automate verification wherever possible to reduce variability introduced by human scoring. Version the evaluation set and keep change notes for every modification. When real user data is involved, anonymize it first and confirm usage authorization and copyright ownership.

    Below is an evaluation execution framework. It applies timeouts and exception handling to each generation and aggregates pass rates and failure causes:

    1. from dataclasses import dataclass
    2. from typing import Callable, List, Tuple
    3. @dataclass
    4. class EvalCase:
    5. case_id: str
    6. prompt: str
    7. verify: Callable[[str], Tuple[bool, str]] # returns (passed, failure reason)
    8. def run_eval(cases: List[EvalCase], generate: Callable[[str], str]) -> dict:
    9. passed_count = 0
    10. failures = []
    11. for case in cases:
    12. try:
    13. output = generate(case.prompt) # generation should enforce timeout and retry limits
    14. except Exception as e:
    15. failures.append((case.case_id, f"Generation error: {e}"))
    16. continue
    17. passed, reason = case.verify(output)
    18. if passed:
    19. passed_count += 1
    20. else:
    21. failures.append((case.case_id, reason))
    22. total = len(cases)
    23. return {
    24. "pass_rate": passed_count / total if total else 0.0,
    25. "passed": passed_count,
    26. "total": total,
    27. "failures": failures,
    28. }

    Agents can read and write files and call external services, so permission control is a mandatory step before launch. Five core principles apply. First, least privilege: each tool only exposes the operations required for its task. Second, tool whitelisting: reject any unregistered tool. Third, parameter validation: check ranges for paths, amounts, recipients, and similar parameters before execution. Fourth, human confirmation for high-risk operations such as deletion, sending, deployment, and permission changes. Fifth, audit logging for all calls, with no secrets in the logs.

    The following code sketches a tool-call entry point with a whitelist, parameter validation, human confirmation, and auditing:

    1. import logging
    2. from pathlib import Path
    3. logging.basicConfig(level=logging.INFO)
    4. audit_log = logging.getLogger("agent.audit")
    5. sandbox_root = Path("/srv/agent_workspace").resolve()
    6. tool_policy = {
    7. "read_file": {"risk": "low", "requires_confirmation": False},
    8. "write_file": {"risk": "medium", "requires_confirmation": False},
    9. "delete_file": {"risk": "high", "requires_confirmation": True},
    10. }
    11. def validate_path(path_str: str) -> Path:
    12. target = (sandbox_root / path_str).resolve()
    13. if sandbox_root not in target.parents and target != sandbox_root:
    14. raise PermissionError(f"Path escapes sandbox: {path_str}")
    15. return target
    16. def invoke_tool(name: str, params: dict, human_confirmed: bool = False):
    17. policy = tool_policy.get(name)
    18. if policy is None:
    19. audit_log.warning("Rejected unregistered tool: %s", name)
    20. raise PermissionError(f"Tool not in whitelist: {name}")
    21. if "path" in params:
    22. params["path"] = str(validate_path(params["path"]))
    23. if policy["requires_confirmation"] and not human_confirmed:
    24. audit_log.warning("High-risk operation awaiting human confirmation: %s %s", name, params)
    25. raise PermissionError(f"High-risk operation requires human confirmation: {name}")
    26. audit_log.info("Executing tool: %s, param keys: %s", name, list(params.keys()))
    27. # Dispatch to the concrete implementation here; omitted

    This code only illustrates the control flow. In production, sandboxes, credentials, and network egress should be managed by an isolated runtime environment, with permission configurations reviewed regularly.

    Pre-Launch Checklist

    Before going live, confirm each of the following:

    • Evaluation set representativeness: samples cover the main business scenarios and long-tail cases, with a distribution roughly matching production traffic;
    • Annotation agreement: two-annotator kappa meets the team’s agreed threshold, and disputed samples have adjudication records;
    • Statistical reliability: hallucination rates are reported with confidence intervals, and model comparisons include a difference test or bootstrap;
    • Regression gating: the evaluation set runs automatically after every model or prompt change, blocking release if key metrics fall below baseline or exceed tolerance;
    • Permission control: tool whitelisting, least privilege, parameter validation, and human confirmation for high-risk operations are all in effect and pass privilege-escalation tests;
    • Auditing and privacy: call logs are complete and searchable, contain no secrets or personal sensitive data, and evaluation samples are anonymized with confirmed authorization;
    • Monitoring and alerting: continuous sampling with human review after launch, with alerts triggered on abnormal hallucination or tool error rates;
    • Rollback plan: the previous version’s configuration and model references are retained, rollback steps and owners are defined, and at least one rollback drill has been performed.

    Only when these conditions are met do verification results have reproducible value. Selection decisions should be based on measurements from your own samples; vendor figures serve only as a reference.