Enterprise RAG on Romanian Legal Corpus: From PDF to Cited Answer
Romanian law lives in PDFs. Monitorul Oficial publishes acts, decisions, and executive orders as layout-fixed documents designed for print, not search.
Enterprise RAG on Romanian Legal Corpus: From PDF to Cited Answer
Romanian law lives in PDFs. Monitorul Oficial publishes acts, decisions, and executive orders as layout-fixed documents designed for print, not search. Any enterprise RAG pipeline on this corpus starts with a hard problem: extraction that preserves article structure, article numbers, and amendment history, with every answer traceable back to a specific paragraph.
Our teams run this stack for internal legal review and for Lexnomia compliance workflows. The pipeline below is the version we ship, not a reference diagram.
The pipeline
Extraction is where most teams underestimate the effort. Scanned acts from the 1990s need OCR; recent acts are text-born but still require layout parsing to recover article boundaries. Diacritics matter — a model that strips Romanian diacritics will mis-match “art.” against “ârt.” tokens generated by poor OCR, and recall drops hard.
Citation evidence, not just retrieval
The business requirement is not “give me a relevant answer”. It is “give me the article number, paragraph, and amendment version I can cite to a client”. That changes the index design.
Each chunk carries structured metadata that the LLM must emit alongside the generated text:
chunk_id: lege-85-2014-art-5-para-2
act: "Legea nr. 85/2014"
article: 5
paragraph: 2
amended_by: "OUG 88/2018"
in_force_from: "2018-10-15"
in_force_to: null
source_pdf: "mo-466-2014-06-25.pdf"
page: 7
A retrieval hit without this metadata is useless for a lawyer. The generator must refuse to answer when metadata is missing — a design choice that aligns with ENISA guidance on verifiable AI outputs and with the audit trail obligations under GDPR Art. 5(2) accountability.
What breaks in production
Three failure modes dominate once the stack sees real queries.
Amendment confusion. The user asks about Legea 85/2014 but means the current consolidated text. Our index tracks in_force_from / in_force_to on every chunk; the retriever filters by query date. Without this, the LLM happily cites a repealed article from a 2016 PDF.
Query drift. Lawyers paraphrase. “Procedura insolvenței” and “procedura de reorganizare judiciară” map to overlapping but distinct chunks. We run hybrid BM25 + dense retrieval and let a reranker decide.
Hallucinated citations. The model invents an article number that does not exist in the retrieved context. We fix this at the output layer: the citation builder validates every art. X string against the chunk metadata before the answer leaves the gateway.
The EU AI Act transparency obligations treat legal-advice systems as high-risk; a RAG stack that cannot prove where its answer came from fails the first audit. That is why we build the citation layer before we tune the retriever.
If you run compliance queries against Romanian corpora today, the RAG pillar collects the engineering notes from this stack, and the Lexnomia workbench is where we deploy it against live regulatory feeds.