Skip to content
Back to projects

codigo-trabajo-rag

In Development

Ask the Dominican Labor Code a question and get an answer that cites its articles

Role: Solo developer

Solo · Since Nov 2026 · Public repo

.NET 10ASP.NET CoreMicrosoft.Extensions.AIGeminixUnit
738
Articles parsed
21 of 21 questions
Retrieval top-5 (vectors)
41
Tests

A retrieval-augmented question answering page over the 738 articles of the Dominican Labor Code (Law 16-92). Each answer cites the articles it came from, and a citation to an article the model was never given is flagged as unverified.

Problem

A language model asked about a law answers from memory, mixes in other countries' rules and invents article numbers. For a legal text a confident wrong answer is worse than none.

Solution

The official PDF is parsed into articles, each one is embedded with Gemini, and a question retrieves its five closest articles. The model only sees those five and must cite them as [Art. N]. The service then checks every cited number against the five it was given.

Not done yet

Only a static demo is online: it searches by words in the browser, with no model and no server. The answering API is not deployed. The eval measures retrieval, not whether the final answer is right, and it has only 21 questions. The citation check confirms an article was provided to the model, not that the sentence matches it. It is not legal advice, and the text may not include later reforms.

Architecture highlights

  • The PDF mixes page headers, footnotes and a footnote number glued to the article number ("Art. 7288" is article 728 plus note 8). Each article number is validated against the expected sequence, and a test checks that all 738 come out in order
  • I wrote 21 questions and read the answering article for each in the text. Retrieval top-5: BM25 14 of 21, Gemini vectors 21 of 21, and fusing both (RRF) 20 of 21 with the right article first less often, so I kept vectors with BM25 only as a fallback
  • The model client is an IChatClient, so the answer service is tested with a scripted fake and the CI needs no API key. Without a key the page still runs and falls back to word search
  • POST /api/ask is rate limited per IP, rejects questions over 300 characters and never returns the provider's error message