Making legal-text LLMs quote their sources
CoCoLex: confidence-guided, copy-based decoding that keeps legal text faithful to its sources.
The Problem
Legal-language models hallucinate, and in law a fabricated citation is worse than silence. The thesis went after faithful citation: getting a model to quote its sources instead of inventing them.
What We Built
Together with my supervisor, started on copy mechanisms, in the spirit of "Copy Is All You Need," then moved to the decoding side. That shift produced CoCoLex: confidence-guided, copy-based decoding. When the model is unsure, it copies from the source instead of improvising. Accepted at ACL 2025, main conference. Further taking the CoCoLex codebase to the community as an open repository, so anyone can reproduce and build on confidence-guided, copy-based decoding for grounded legal text. Actively cooperating with researchers who want to extend it.
Numbers We Moved
- +15.7 pts
- More correct
- +12.1 pts
- More coherent
- +5.5 pts
- More faithful
- 5 / 5
- Benchmarks more faithful
Due to their ability to process long and complex contexts, LLMs can offer key benefits to the Legal domain, but their adoption has been hindered by their tendency to generate unfaithful, ungrounded, or hallucinatory outputs. While Retrieval-Augmented Generation offers a promising solution by grounding generations in external knowledge, it offers no guarantee that the provided context will be effectively integrated. To address this, context-aware decoding strategies have been proposed to amplify the influence of relevant context, but they usually do not explicitly enforce faithfulness to the context. In this work, we introduce Confidence-guided Copy-based Decoding for Legal Text Generation (CoCoLex)—a decoding strategy that dynamically interpolates the model produced vocabulary distribution with a distribution derived based on copying from the context. CoCoLex encourages direct copying based on models’ confidence, ensuring greater fidelity to the source. Experimental results on five legal benchmarks demonstrate that CoCoLex outperforms existing context-aware decoding methods, particularly in long-form generation tasks.