SAFE: Improving LLM Systems using Sentence-Level In-generation Attribution

João Eduardo Batista, Emil Vatai, Mohamed Wahib · Submission to ICLR 2026 · Withdrawn

TL;DR

Current Retrieval-Augmented Generation (RAG) models often hallucinate or cite whole documents, making verification tedious and error-prone. SAFE introduces an interactive, sentence-level attribution framework that cites source documents in real time as text is generated. By predicting reference counts upfront with 95% accuracy, SAFE improves downstream attribution accuracy by 2.1–6.0% and allows users to catch hallucinations mid-generation.

What Problem Does This Paper Address?

While Large Language Models (LLMs) are widely used for answering factual questions, their lack of verifiable sourcing limits adoption in high-stakes fields like medicine, law, and research. Standard RAG systems typically suffer from two key attribution failures:

  1. Unverifiable grain size: Existing systems often cite entire documents rather than specific sentences, forcing users to read extensive passages just to verify a single claim.
  2. Post-hoc, ungrounded generation: Models often generate an entire paragraph before retrieving references, creating citations that are hallucinated, misaligned, or missing.

Crucially, studies show that users place unwarranted trust in LLM outputs whenever citations are present—even if those citations are completely wrong. SAFE tackles this by shifting attribution from coarse, post-generation checks to fine-grained, sentence-by-sentence verification during generation.

Methods

SAFE structures sentence-level attribution as a two-stage pipeline embedded directly in the text generation loop:

  1. Pre-Attribution Classification: Before searching for evidence, a classifier predicts whether the generated sentence requires zero, one, or multiple references ($0, 1, \text{or } 2+$). The authors tested classifiers (Random Forest, XGBoost, MLP, TabNet) using two feature representations:
  2. 24 textual/linguistic features (syntactic tree depth, reading ease scores, named entity density, word/syllable counts).
  3. Sentence embeddings (384-dimensional vectors from all-MiniLM-L6-v2).
  4. Attribution Retrieval: Once the reference count is predicted, the sentence is routed to an attribution algorithm to retrieve matching source sentences from the input documents. The authors compared several lightweight retrievers suitable for low-latency generation:
  5. Nearest neighbor embedding search (Select Closest One [SC1] and Select Closest Two [SC2]).
  6. Sparse lexical retrieval (SPLADE and BM25).
  7. Diversity-reranked embedding search (MMR).
  8. Rapid string matching (Fuzzy).
  9. Interactive Human-in-the-Loop Generation: The LLM outputs one sentence at a time accompanied by its supporting quote. If an attribution misses or indicates hallucination, the user can pause, probe the model, and steer the response before the full answer is completed.
[Generated Sentence] ──► [Pre-Attribution Classifier] ──► [Predicted Citation Count (0, 1, 2+)]
                                                                     │
                                                                     ▼
[Interactive User Correction] ◄── [Attributed Quote(s)] ◄─── [Attributor (SPLADE / SC / BM25)]

Datasets

  • WebGLM-QA and HAGRID: Standard open-domain QA attribution datasets containing queries, answers split into sentences, and quote pools.
  • HAGRID-Clean (New): The authors found substantial label noise and formatting inconsistencies in HAGRID (e.g., over-referencing trivial claims, under-referencing complex facts, and noisy citation markers). They manually curated and relabeled HAGRID into 7,308 sentences with normalized citation targets and explicit human annotations for reference necessity (403 zero, 6,140 single, 765 multiple references).

Key Insights and Ideas

  • Decoupling "how many" from "which one" works: Predicting citation cardinality prior to retrieval prevents retrievers from force-fitting spurious quotes to transition sentences or returning single quotes for compound facts.
  • Linguistic metrics outperform raw embeddings for reference counts: On clean data, 24 simple textual readability and complexity features matched or outperformed 384-dimensional dense embeddings for pre-attribution classification.
  • Dataset noise hides true retriever potential: Off-the-shelf attribution benchmarks suffer heavily from inconsistent citations. On cleaned data, pre-attribution boosted retriever accuracy dramatically, showing that many apparent retrieval failures were actually annotation issues.

Key Results

  • Pre-attribution Performance: Classifiers reached ~95% test accuracy on HAGRID-Clean using textual features (Random Forest: 95.6%, XGBoost: 95.0%). XGBoost proved optimal for deployment, generating over 38,000 predictions/second on consumer hardware.
  • Attribution Gains: Guiding retrievers with the XGBoost pre-attribution step yielded a +2.1% to +6.0% improvement in normalized accuracy across all attribution methods compared to standard top-1 retrieval:
  • SC2 reached 96.98% normalized accuracy (+5.96% vs. top-1).
  • SPLADE achieved 95.88% normalized accuracy (+2.09% vs. top-1), while offering token-level interpretability.
  • Real-World Scaling: Evaluated in end-to-end chat scenarios with large context pools (e.g., multi-page scientific papers and Wikipedia articles containing over 3,400 candidate sentences), SAFE reliably aligned claims with exact document sentences in near-real-time.

Limitations and Future Work

  • Context Loss: Sentence-level quotes can occasionally miss context from surrounding sentences or lead to quotes taken out of context.
  • Zero-Match Detection: Most standard ranking methods (BM25, vector search) return top hits regardless of relevance; fuzzy and SPLADE thresholds have limited sensitivity for detecting when no valid citation exists.
  • Class Imbalance & Subjectivity: Determining whether a statement is "common knowledge" vs. requiring a citation introduces subjective annotator bias, leaving "zero-reference" samples underrepresented.
  • Future Directions: The authors plan to investigate semi-supervised training to expand clean attribution data and address sentence-boundary artifacts in raw PDF text extraction.

Summary updated

Abstract

Large Language Models (LLMs) are increasingly applied in various science domains, yet their broader adoption remains constrained by a critical challenge: the lack of trustworthy, verifiable outputs. Current LLMs often generate answers without reliable source attribution, or worse, with incorrect attributions, posing a barrier to their use in scientific and high-stakes settings, where traceability and accountability are paramount. To be reliable, attribution systems require high accuracy for short-length attribution on retrieved data, i.e., attribution to a sentence within a document rather than the entire document. We propose SAFE, a Sentence-level A ttribution FramEwork for Retrieve-Augmented Generation (RAG) systems that attributes generated sentences during generation. This allows users to verify sentences as they read them and correct the model when the attribution indicates the generated text is not grounded in the documents, increasing the safety of LLM systems. This framework consists of two steps: predicting the required number of references for a sentence, and attributing the sentence. Our approach achieved 95% accuracy in the first step, which translated to 2.1∼6.0% improvements in the accuracy (normalized for maximum possible accuracy) of all attribution algorithms in our clean dataset, when compared to their top-1 accuracy. We also applied SAFE in real-world scenarios with documents containing hundreds to thousands of sentences. In these settings, SAFE reliably attributed sentences to their source documents, demonstrating that the method generalizes beyond controlled benchmarks. The SAFE framework and the training dataset are publicly available on GitHub.
BibTeX
@misc{batista2025safe,
  author = {João Eduardo Batista and Emil Vatai and Mohamed Wahib},
  title = {{SAFE: Improving LLM Systems using Sentence-Level In-generation Attribution}},
  year = {2025},
  eprint = {2505.12621},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.12621},
}
Figure