TL;DR
LMLineage is an "out-of-band" system that provides sentence-level attribution for LLM agents, mapping every output sentence back to its specific input source (e.g., a web document or user prompt) without requiring access to the model's internal weights. By tracking which inputs are actually being used, the system enables "micro-compaction"—surgically summarizing only stale, "drifted" context to prevent the accidental deletion of critical instructions during long sessions.
What Problem Does This Paper Address?
As LLM agents move into production, they consume a messy mix of system prompts, tool results, and retrieved documents. When an agent "hallucinates" or ignores a constraint, developers face a fundamental interpretability gap: which specific input caused this output?
Existing solutions fall short. "White-box" methods require expensive access to model internals, while "self-citation" (asking the LLM to cite its sources) is often unfaithful. Furthermore, standard context management—like summarizing the entire history when a token limit is reached—can "wash away" vital instructions (e.g., a "do not delete" rule), leading to catastrophic failures. LMLineage aims to provide a lightweight, black-box way to track content provenance and govern context intelligently.
Methods
The authors propose a "sidecar" architecture that observes agent events asynchronously, ensuring no latency is added to the user's experience.
The core of the system is the Window-First Sentence Attribution algorithm:
- Word Mapping: It creates a token-level cosine similarity matrix between the output sentence and input documents.
- Greedy Window Search: Instead of comparing a sentence to every line in a document, it identifies the best contiguous "window" (span) within each document that matches the output.
- Embedding Similarity: It then uses sentence embeddings to score these document-level candidates.
- Confidence Calibration: It assigns "metadata triplets" (source, value, confidence) to each output sentence, explicitly reserving some confidence for the model's internal parametric knowledge.
This lineage data feeds into a Concept-Drift Micro-Compaction trigger. If a document hasn't been referenced for several turns, it is flagged as "drifted" and replaced with a 1–2 sentence summary, preserving the rest of the context verbatim.
Datasets
The researchers evaluated LMLineage using a multi-tier corpus:
- Tier 1 (Gold-annotated): 71 sentences from 10 Chinese web-QA cases, manually annotated for source set, primary source, and supporting spans.
- Tier 2 (Multi-model): The same 10 cases regenerated using
gpt-4o-mini,qwen3.8-27b, anddeepseek-v4-flashto test model-agnostic performance. - Tier 3 (Multi-turn): 90 turns of independent multi-turn sessions used to evaluate the operational feasibility of drift detection.
Key Insights and Ideas
- The "Multiple-Comparisons" Bias: The authors found that exhaustive "line-matching" (comparing an output to every single line in a massive document) actually decreases accuracy. Because the candidate pool is so large, the probability of a random, high-similarity "spurious match" increases. Their "greedy window" approach avoids this by picking the best span per document first.
- Embeddings > Lexical: Standard lexical tools like BM25 or edit distance fail miserably on LLM outputs because of heavy paraphrasing. Window-level embeddings proved far more robust.
- Lineage as Governance: Lineage isn't just for debugging; it's a control signal. By knowing what isn't being used, you can manage memory more safely than traditional "summarize-everything" approaches.
- Fishbone Visualization: To make this data useful for humans, they developed a "Fishbone UI" that maps the complex lineage graph onto a timeline of "beats" (turns and compactions).
Key Results
- Accuracy: The greedy window path achieved significantly higher accuracy (~0.66–0.79) compared to the line-match baseline (~0.41–0.57) across different models.
- Latency: Attribution is fast enough for real-time use, completing in ~1 second per turn on a single GPU. It remains stable even as context grows to 40 turns.
- Efficiency: The greedy window method is roughly 17x faster than exhaustive line-matching.
- Micro-Compaction: The drift detection mechanism is highly conservative, reporting a 0% false-positive rate (it never compacted a document that was actually still in use).
Limitations and Future Work
- Scale and Language: The current gold benchmark is relatively small (71 sentences) and limited to Chinese. The authors plan to expand to larger, multi-language datasets.
- Annotation Bottleneck: Gold labels were produced using an LLM-assisted protocol; future work will involve more independent third-party human annotation.
- Algorithmic Refinement: The greedy search currently uses random perturbation; the authors suggest a deterministic DP-based (Dynamic Programming) window search as a future improvement.
- Security: While lineage could theoretically help detect "compaction-washed" prompt injections, exploring the security implications of this system is currently out of scope.
Summary updated