# QuCo-RAG

The official implementation of a paper on retrieval-augmented generation that decides when to retrieve based on statistics from the model's pre-training corpus, rather than relying on the model's own, often miscalibrated, internal confidence signals.

QuCo-RAG is dynamic retrieval-augmented generation code accompanying a paper accepted to ACL Findings 2026. Instead of triggering retrieval from a model's internal signals such as logits or entropy, it uses Infini-gram to query entity frequencies and co-occurrences in a large pre-training corpus, checking before generation for low-frequency entities that indicate long-tail knowledge gaps, and during generation for entity co-occurrence patterns that indicate a risk of hallucination.

The paper reports the method as model-agnostic, tested with OLMo, Llama, Qwen and GPT-family models, with exact-match gains of five to twelve points over prior baselines on multi-hop question-answering benchmarks. The repository includes data preparation steps for a Wikipedia dump and BM25 index, scripts to run the method and baselines, and evaluation code, along with a downloadable pre-computed cache to speed up experiments on the included datasets.

It is written in Python and released under the MIT license.

Website: https://arxiv.org/abs/2512.19134
