cd /news/artificial-intelligence/why-rag-on-legal-text-keeps-hallucin… · home topics artificial-intelligence article
[ARTICLE · art-96567] src=dev.to ↗ pub= topic=artificial-intelligence verified=true sentiment=↑ positive

Why RAG on legal text keeps hallucinating dates - and what actually fixed it

Platanor, an embedded security company for IoT, has released a public repository that fixes hallucination errors in retrieval-augmented generation (RAG) systems when processing legal texts like the EU's Cyber Resilience Act (CRA). The team found that token-based chunking and scattered dates caused models to mix up entry-into-force dates with application deadlines, and solved it by cutting chunks at article headings, embedding source priority and verification dates in the files, and adding an llms.txt index. The approach, packaged as the hardware-compliance-handbook on GitHub, ensures accurate answers without changing the model.

read2 min views1 publishedAug 14, 2026

A couple of weeks ago I dropped the CRA text (the EU's cybersecurity regulation for IoT devices) into ChatGPT and asked when the main requirements actually kick in. The answer was confident and wrong - it mixed up the date the regulation entered into force (2024) with the date the requirements actually apply (2027). Three years off, stated like an obvious fact.

My team (Platanor, embedded security for IoT) has been building an internal reference on CRA/RED/NIS2/CSA for a few months now, and this is exactly the kind of mix-up we kept running into whenever we just threw the regulation PDF at a model.

The problem isn't the model. It's how the source is laid out: dates are scattered across different articles with no explicit link between them, token-based chunking cuts sentences off mid-article, and the model has no way to tell how fresh the text is.

When we rebuilt the base as a public repository, we fixed this with file structure, not prompting.

Cut by article headings, not by tokens:

### Article 13
Obligations of manufacturers
1. When placing a product...

### Article 14
Reporting obligations...

### Article N

is a natural boundary. Each chunk stays whole - the article never gets split mid-sentence.

Source priority, written into the file itself, not the prompt:

primary source > official related documents > third-party summaries > our own analysis. The model sees this right next to the content, not as an instruction that's easy to lose in a long chat.

A verification date on every file:

> Last verified: 2026-08-10.
> Annex I application deadline: 11 December 2027 (not to be confused with the entry-into-force date - 10 December 2024).

That one line is what removed the exact error I opened with.

** llms.txt at the repo root** - an index of every file, so an agent can pick what to load instead of reading the whole repository.

The same questions now get answered correctly - not because the model got smarter, but because the source stopped being one continuous wall of text.

We packaged the whole approach, plus the fact-checked base on CRA/RED/NIS2/CSA, into one repository - pull it into your own RAG pipeline or install it as a Claude Skill: https://github.com/Platanor/hardware-compliance-handbook

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @platanor 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/why-rag-on-legal-tex…] indexed:0 read:2min 2026-08-14 ·