Abstract
Current evaluations of Large Language Models (LLMs) often underestimate their internal parametric knowledge due to rigid metrics like Exact Match. This paper introduces Retrieval-Constrained Decoding (RCD), a method that restricts model outputs to a set of valid entities retrieved from a knowledge base. By bypassing surface-form variations and partial correctness issues, RCD reveals that models—especially smaller ones—possess significantly more factual knowledge than standard benchmarks suggest.
Introduction: The Evaluation Gap
The AI community primarily measures "parametric knowledge"—facts stored directly in a model's weights—using benchmarks that rely on Exact Match (EM) scoring. However, this approach is fundamentally flawed. A model may be factually correct but penalized for using a synonym (e.g., "PSG" instead of "Paris Saint-Germain") or for providing a partially correct list of answers to a multi-cardinality question. These "surface form variations" and "partial correctness" issues create a vocabulary hurdle that masks the true extent of a model's internal knowledge.
Methodology: Retrieval-Constrained Decoding (RCD)
To address these limitations, the authors propose Retrieval-Constrained Decoding (RCD). Unlike standard decoding, which allows a model to generate any token from its entire vocabulary, RCD restricts the output space to a predefined set of "Unique ID Surface Forms" (IDSFs).
The RCD process follows three primary steps:
- Candidate Retrieval: A retriever identifies potential answer entities from a knowledge base (e.g., YAGO or Wikidata) based on the input question.
- Trie Construction: These candidates are organized into a prefix tree (trie), representing all valid token sequences for the candidate names.
- Constrained Decoding: During generation, the model is forced to navigate the trie, ensuring it only selects tokens that form one of the retrieved entities. A special separator token (
[SEP]) allows the model to list multiple entities for complex questions.
This method requires no fine-tuning, preserving the model's original weights and providing a pure measurement of its existing knowledge.
Experimental Setup
The researchers evaluated RCD using two key datasets:
- YAGO-QA: A new dataset of 19,137 questions derived from YAGO, a high-quality, semantically consistent version of Wikidata.
- KAMEL: A challenging benchmark focusing on niche, domain-specific knowledge in areas like sports and medicine.
Results and Key Insights
The application of RCD led to substantial performance improvements across various model families and sizes.
Uncovering Hidden Knowledge
The most significant finding is the dramatic increase in F1 scores when switching from vanilla decoding (VD) to RCD. For instance, Llama-3.1-70B's F1 score rose from 32.3% to 46.0% on YAGO-QA. On the more difficult KAMEL dataset, the same model saw its score nearly quadruple, jumping from 8.7% to 32.0%.
Efficiency and Scaling
RCD allows smaller models to compete with much larger counterparts. A Llama-3.2-3B model using RCD (24.3% F1) outperformed a Llama-3.1-8B model using standard decoding (20.8% F1). This suggests that factual accuracy is often limited by the decoding process rather than the model's capacity, potentially allowing for the use of smaller, more efficient models in production environments.
RCD vs. Prompting
The study also found that RCD is more effective than standard Retrieval-Augmented Generation (RAG). While RAG provides candidates as context in the prompt, RCD enforces them as hard constraints, more effectively eliciting the model's internal facts.
Conclusion and Future Work
Retrieval-Constrained Decoding demonstrates that current LLMs are significantly more knowledgeable than standard evaluations suggest. By removing the "vocabulary hurdle," RCD provides a more accurate assessment of parametric knowledge.
While powerful, RCD currently depends on the quality of the underlying knowledge base and the retriever. Future research may explore more advanced retrieval strategies and the application of RCD to specialized domains, such as e-commerce or technical support, to enhance the reliability of factual AI assistants.
Summary updated