Add COFT: Coarse-to-Fine Highlighting: Reducing Knowledge Hallucination in Large Language Models (https://arxiv.org/abs/2410.15116) #10550
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Summary / Motivation
This pull request introduces COFT into
torch_geometric.llm, a modular component designed to reduce hallucinations in retrieval-augmented and knowledge-grounded LLM workflows.While PyG already provides various utilities for LLM integration, there is currently no built-in mechanism for context selection, entity-driven scoring, or highlight-based grounding. COFT fills this gap by offering a plug-and-play module that:
This reflects the methodology proposed in the COFT research work and enables more accurate downstream LLM reasoning.
What This PR Adds
New modules
COFT: main highlighting pipeline with recaller, scorer, and selectorNew example script
examples/coft.pyDemonstrates full end-to-end usage with
torch_geometric.llm.LLM.New unit tests
Located under
test/llm/models/test_coft.py, covering:Why This Is Useful
Large-context reasoning can hallucinate when irrelevant text overwhelms the LLM.
COFT significantly improves robustness by:
This module complements PyG’s direction toward graph-assisted LLMs and aligns well with existing efforts such as RAG, graph prompting, and KG-augmented workflows.
Breaking Changes
No breaking changes introduced.
COFT is self-contained and does not modify existing LLM APIs.
Example Usage
Test Plan
All tests pass:
Manual validation:
Both example results and unit tests confirm consistent highlighting behavior.