Skip to content
Ignacio Perales

RAG and LLMs

I build LLM features that answer from the right knowledge and only call the model when cheaper steps can't decide.

At Eniax I worked on a RAG assistant that answered common questions about each client clinic, using that clinic's own knowledge. In my own project, mercadopublico, an LLM is the last step of a categorization cascade that costs about US$6 a month.

Where I've used it

Eniax

Health-tech company, Chile

Employer2022-06 → now

Each client clinic has its own information, and the same questions about it come up again and again.

Built

  • A RAG assistant that answers common questions about each client clinic from that clinic's own knowledge.
  • RAG
  • LLMs

mercadopublico

Own project

Own

Chile's public procurement tenders are published on Mercado Público (ChileCompra), but finding the relevant ones takes work.

Built

  • A NestJS extractor and API, documented with Swagger and protected by API keys with roles, plus a Next.js review console.
  • A categorization cascade (rules, then UNSPSC product codes, then Gemini Flash reading the PDFs) at about US$6 a month, followed by relevance scoring.
  • Resilient fetching, with a circuit breaker per host and backoff with jitter.
  • A daily API budget gate with a mutex and a hard cutoff.
  • Compliant scraping, with an identifiable user agent, robots checks and no CAPTCHA evasion.
  • Personal-data redaction, and snapshots of changes to each tender.
  • Docker deployments through a self-hosted CI/CD pipeline.
per month for the categorizer
~US$6
test files
168
  • NestJS
  • Next.js
  • MongoDB Atlas
  • Docker
  • Swagger
  • Gemini Flash

Architecture

Per-clinic RAG. Each client clinic has its own information, and the same questions about it come up again and again. The assistant retrieves from the knowledge of the clinic being asked about, and answers from that.

Categorization cascade. mercadopublico collects Chile's public procurement tenders and sorts them into categories. Each tender goes through three steps, and stops at the first one that can decide:

  1. Rules.
  2. UNSPSC product codes.
  3. Gemini Flash reading the tender's PDFs.

Eniax · Per-clinic RAG

    • Question about a clinic
    • That clinic's knowledgeretrieval
    • Answerfrom what was retrieved

mercadopublico · Categorization cascade

    • Tenderfrom Mercado Público
    • Rules
    • UNSPSC product codes
    • Gemini Flashreads the tender's PDFs
  • Service
  • Storage
  • External

A question about a clinic is answered from what is retrieved from that clinic's own knowledge. In mercadopublico, each tender goes through rules, then UNSPSC product codes, then Gemini Flash reading its PDFs, and stops at the first step that can decide.

Demo

Simulated demo

Ask my portfolio

A retrieval playground over this site's own content. Ask a question and see which passages are retrieved and how they rank, using embeddings computed at build time.

Coming soonThis demo isn't built yet. The title and description above say what it will show.

Decisions & lessons

  1. Scope retrieval to the tenant. Knowledge is per clinic, so retrieval is per clinic too.
  2. Make the LLM the last resort. Rules and product codes are free and predictable, so the model only sees the tenders they can't place. That keeps the whole categorizer at about US$6 a month.

Stack

  • RAG
  • LLMs
  • Gemini Flash
  • NestJS
  • MongoDB Atlas