﻿# Beyond Document Grounding: finding unsupported code and tool spans

A reviewed reading of the LettuceDetect study separates character-span detection, answer-level scores and synthetic errors from production reliability.

Author: Retrivium editorial team
Updated: 2026-11-05
Canonical URL: https://retrivium.ai/journal/beyond-document-grounding-code-tool-span-detection/
Language: en

A coding assistant can write a plausible patch containing one invented method or report the wrong status from a tool observation. Beyond Document Grounding studies whether a separate verifier can locate that unsupported substring after generation. Its benchmark adds concrete evidence about code verification that document-only evaluations cannot provide.

## Verify the answer against a defined context

The [paper](https://arxiv.org/html/2607.00895) supplies the request, evidence and completed answer to the detector. It does not require the original generator's internal probabilities. Code examples use repository state and requested behavior; document examples use supplied text. This makes evidence completeness part of the task.

For example, a real helper omitted from the verifier's context can resemble an invented identifier. A sensible review therefore preserves the repository revision and supporting definitions alongside the proposed change. Correct syntax alone cannot establish that a modification follows the user's request.

## Interpret the published scores separately

The [model card](https://huggingface.co/KRLabsOrg/lettucedect-v2-qwen-2b/raw/main/README.md) reports span-F1 of 0.689 over 10698 test examples for the fine-tuned Qwen3.5-2B detector. Its code-agent span-F1 is 0.602, while the RAGTruth slice reaches 0.574. These are character-overlap localization results. They are not proportions of production answers certified correct.

The same release exposes answer-level metrics, which ask whether any error exists anywhere in an answer. A verifier can identify an answer as problematic while selecting the wrong substring. Keep those outcomes separate when deciding whether to highlight text, reject a patch or request human review. A single aggregate also hides the different difficulty of prose and code.

## Account for the constructed errors

The benchmark creates localized edits to grounded answers. The paper describes model-assisted review and author arbitration for the code test split; it does not claim independently repeated human annotation of every label. Other generated labels retain the limitations of the construction process.

This design helps measure whether a detector finds a controlled unsupported change. It does not estimate how frequently deployed assistants invent APIs, nor does it cover complete agent trajectories. A final answer can be supported while the preceding actions were inappropriate, or unsupported because relevant evidence was never supplied to the checker.

## Preserve the localization contract

The [project documentation](https://raw.githubusercontent.com/KRLabsOrg/LettuceDetect/main/README.md) distinguishes generative typed-span detection from encoder-based alternatives. For a proposed integration, retain the exact answer and require each reported substring to map back to it. Repeated names and reformatted code deserve explicit handling: a plausible explanation without an unambiguous location is insufficient for an editor annotation.

Evaluate missed errors and false alarms on clean patches separately. Include real examples from the intended language and repository style, and keep the detector revision fixed during comparisons. The [RAGBench guide](/journal/data-guide-ragbench-document-grounding-labels/) explains why label provenance matters; the [FACTS Grounding guide](/journal/data-guide-facts-grounding-source-support/) separates support by supplied evidence from unrestricted factual truth. This study supports a focused verifier evaluation, with application-specific validation still needed before automatic rejection becomes an operational policy.
