Inspiration

In Colombia, health care is delivered through insurers called EPS. When an EPS denies a prescribed medicine, never schedules an appointment or delays an authorization, the law gives every citizen two free tools: the derecho de petición (the EPS must answer in writing within 15 days) and the acción de tutela (a judge must decide within 10 days when a fundamental right such as health is at risk, no lawyer needed).

Health is one of the most common reasons Colombians file tutelas, yet the people who need them most (older adults, parents of sick children, rural patients) often don't know which document fits their case, which laws to cite, or how to write it. Lawyers are expensive, and generic chatbots invent laws and court rulings, which is dangerous in a legal document. Subvenio is Latin for "I come to help".

What it does

The citizen describes what happened in their own words. Subvenio:

  1. Extracts the facts of the case: who is affected, how urgent it is, whether the patient has special constitutional protection, whether someone writes on their behalf.
  2. Chooses the right document (tutela or petition) with a fixed legal rule.
  3. Searches official government sites for Constitutional Court rulings.
  4. Writes the document, citing only verified laws and quotes that appear word for word in an official source.
  5. Explains it in plain words: what it asks for, which blanks to fill in, and what to do next, with the legal deadlines.

The page has four tabs: Explanation, Document (download), Sources (every search snippet, so each quote can be checked) and Metrics (model, tokens and time per step). A language switch shows everything in English; the document to file always stays in Spanish.

How we built it

The core rule is: the model reasons; the code handles everything that must be exact.

Step Model Why
Intake: facts as JSON Nemotron 3 Nano, reasoning off Fast structured extraction; turning reasoning off cut tokens ~5x with the same result
Route: tutela or petition Code A fixed legal rule; a model call flipped its answer between runs
Research: up to 3 queries Nemotron 3 Super Needs legal vocabulary; our code runs Tavily on 5 official Colombian domains
Draft the reasoning sections Nemotron 3 Super, reasoning on The hardest step: apply laws and rulings to the facts
Explain in plain language Nemotron 3 Nano Short summary for someone with no legal training
Optional English translation Nemotron 3 Nano Blanks, URLs and quotes are protected with tokens and restored

Every model call runs at runtime on Nebius Token Factory through its OpenAI-compatible API, from a single module with timeouts, retries and logging of model, tokens and latency (never the user's text). Because the API is OpenAI-compatible, the standard openai client worked unchanged, switching between Nano and Super is one string, and Nemotron's reasoning switch is one request field, so we measured each step with and without reasoning in minutes and kept it only where it pays off.

Guards enforced by code:

  • The model may only cite a mini legal code of 30 articles (Constitution, Decreto 2591/1991, Ley 1755/2015, Ley 1751/2015), verbatim and checked against the government's official pages.
  • Every quoted ruling must appear word for word in a Tavily snippet, or the whole citation is removed.
  • Any URL that didn't come from the search or the legal code is replaced.
  • Title, parties, oath, annexes and signature are built by code with blanks like [NOMBRE]; "what to do next" is hand-written.

Stack: Python, Streamlit, Pydantic (validates every JSON answer, one retry with the error), pytest (87 tests, all mocked, no credits spent) and ruff.

Challenges we ran into

  • Invented citations. Early drafts quoted a ruling the wrong way (the patient had died; the draft claimed the Court ordered a delivery). That's why quotes must now match a source verbatim.
  • Unstable decisions. In our first evaluation the model changed tutela vs. petition between runs in two cases, so routing became code and classification steps use temperature 0.
  • Lost accents. 79 of 86 Court snippets from the search had lost their accented letters ("prestacin"), so correct quotes never matched. Quotes are now compared ignoring accents, and ruling citations went from 6/12 to 9/12 documents.
  • Translation breaking blanks. Nano translated [NOMBRE] into [NAME]; protected tokens fixed it, with a fallback to Spanish if a token is lost.

Accomplishments that we're proud of

An evaluation set of 12 invented cases, graded by plain code (not another model): 12/12 pass every rule, 9/12 cite at least one Constitutional Court ruling, averaging ~12k tokens and ~21 s of model time per case. Every failure we found became a rule enforced by code, with a test.

What we learned

  • Use the smallest model that does the job, and turn reasoning on only where it pays off.
  • In a legal product, anything that must be exact (deadlines, laws, URLs, the document type) belongs in code, not in a prompt.
  • An evaluation set checked by code finds problems that a few manual tries never show.
  • Use new tools to optimize tokens using tavily for AI searching

What's next for Subvenio

  • A small verified set of key health rulings, so every document can cite one.
  • More legal areas (pensions, labor), PDF/Word download and a filing guide per city.
  • A larger evaluation set and optional removal of personal data before it reaches the model.
  • Scalate it to a legal document to not depend on a lawyer.

Subvenio is a support tool, not legal advice: the citizen should review the document before filing it.

Built With

  • nebius-token-factory
  • nvidia-nemotron
  • openai-api
  • pydantic
  • pytest
  • python
  • ruff
  • streamlit
  • tavily
Share this project:

Updates

Submission history