Skip to content
Nasr City, Cairo, Egypt · Founding-Engineer Edition
صحيفة
مدينة نصرSuch a lovely font, eh? It's called Ruq'ah and it's a common hand-written arabic style

Hometown paper · covering one Nasr City engineer's exploits abroad · Current stop - München

Vol. VI · No. 07·Circulation · 447·Munich · partly everything·Price: a coffee
Back to the front page
Science

Research

Publications & NLP research.

Science

Making legal-text LLMs quote their sources

CoCoLex: confidence-guided, copy-based decoding that keeps legal text faithful to its sources.

Co-Author · Open Source · 2025

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.

+15.7 pts
More correct
+12.1 pts
More coherent
+5.5 pts
More faithful
5 / 5
Benchmarks more faithful
Filed underPythonHugging FaceLangChainLlamaIndexpgvectorOpenAIOverleaf

Stop Press

  • BREAKING: CoCoLex teaches legal AI to cite its sources. Hallucinations reportedly furious.
    Breaking

    BREAKING: CoCoLex teaches legal AI to cite its sources. Hallucinations reportedly furious.

    Early tests suggest the model now checks the source before it speaks, a courtesy the legal profession has requested for some time. Developing story.

    Read about it →