Skip to main content
    listerineh.dev
    • About
    • Experience
    • Projects
    • Skills
    • Blog
    • Talks
    • Contact
    • Why
    • About
    • Experience
    • Projects
    • Skills
    • Blog
    • Talks
    • Contact
    • Why

    © 2026 Sebastian Alvarez

    All projects

    RAG Evals

    A RAG service with an evaluation harness that reports measured numbers. The harness overturned the plan: on SciFact, vector search beat hybrid search, so vector became the default.
    Source Code
    RAG Evals
    Role
    Backend & AI Engineer
    Timeline
    November 2026
    Status
    In Progress

    In numbers

    Recall@10 on 300 SciFact claims, vector search
    0.8290.829
    Median retrieval time, query embedding included
    6.06.0ms
    Recall@10 of equal-weight hybrid search: lower, and 6.6× slower
    0.7560.756
    Tests in CI, 6 of them against real Postgres + pgvector
    3131

    About the Project

    RAG Evals is a retrieval-augmented generation service built around its own evaluation. It indexes documents, answers questions with Claude, and cites the exact chunks it used, but the point is the harness next to it: every run writes recall, MRR and latency to a JSON file, and only those files feed the numbers I quote.

    The API is FastAPI with async SQLAlchemy 2.x, Pydantic v2 and Alembic migrations over Postgres 17 with pgvector. Documents are split into 220-word chunks and embedded locally with bge-small through fastembed, so there is no embedding bill and CI uses the same vectors as production. A question is embedded, matched against an HNSW index, and the top six chunks go to Claude Haiku as native search result blocks, so every citation points back to a chunk id the API returned. The evaluation uses BEIR SciFact: 5,183 scientific abstracts and 300 test claims with expert relevance labels.

    The plan was hybrid search, full text plus vectors fused with Reciprocal Rank Fusion. Measured, equal-weight hybrid reached a recall@10 of 0.756 against 0.829 for vectors alone, and was 6.6 times slower. Tuning the full-text weight on the train split drove it to zero, so vector search became the default and hybrid stayed as an option. I built it in November 2026 because RAG is easy to demo and hard to prove; the answer-quality evaluation with an LLM judge is written and still to be run.

    Technologies
    1. AI

      • Claude
    2. API & backend

      • Python
      • FastAPI
    3. Data

      • PostgreSQL
      • pgvector
      • Alembic

    Relevance

    RAG treated as an engineering problem: a measured retrieval pipeline, citations you can verify, and an evaluation that is allowed to change the design.

    How it works

    The path a request takes, step by step.

    1. 01 · PersonClientAsks a question on /ask
    2. 02 · ServiceFastAPIAsync SQLAlchemy and Pydantic v2
    3. 03 · AI modelEmbeddingsbge-small, local, no API cost
    4. 04 · DatapgvectorHNSW index, top 6 chunks
    5. 05 · AI modelClaude HaikuChunks sent as search result blocks
    6. 06 · ResultAnswerCitations that point to real chunk ids, and its cost
    Offline, the harness runs the same retrieval over 300 SciFact claims with expert labels and writes recall, MRR and latency to one JSON file per run.

    Decisions

    The choices that shaped it, and what each one cost.

    1. 01

      Let the evaluation pick the search mode

      Why
      Hybrid search was the plan. Measured, equal-weight hybrid reached a recall@10 of 0.756 against 0.829 for vectors, and tuning its full-text weight drove it to zero.
      What it cost
      SciFact is one domain. On keyword-heavy documents hybrid may win, so it stays available as an option.
    2. 02

      Tune on train, report on test

      Why
      The fusion weight was tuned on 809 train claims and the metrics come from the 300 test claims, so the reported number is not fitted to the test.
      What it cost
      Every change to retrieval needs two evaluation runs instead of one.
    3. 03

      Run the embeddings locally

      Why
      bge-small through fastembed means no embedding bill and the same vectors in CI and production.
      What it cost
      A small model with 384 dimensions, and indexing 5,183 abstracts takes about four minutes on a laptop CPU.
    4. 04

      Send chunks as search result blocks

      Why
      Claude cites the blocks it was given, so every citation points back to a chunk id the API returned instead of text the model made up.
      What it cost
      Generation is tied to Claude’s API format.

    Next project

    Payments LedgerA double-entry payments ledger in Go and Postgres: each transfer posts exactly once per idempotency key, balances always match their entries, and events leave through a transactional outbox.Next project
    listerineh.dev

    Full-stack engineer building AI agents, cloud platforms and web products. Based in Quito, working remotely.

    Open to new projects

    Work

    • Projects
    • Experience
    • Skills
    • Blog
    • Talks

    About me

    • About
    • Why Listerineh?
    • Contact

    Connect

    • GitHub
    • LinkedIn
    • Instagram
    • Email

    © 2026 Sebastian Alvarez · All rights reserved.

    • Privacy Policy
    • Terms of Use
    • Unsubscribe from the newsletter
    • Component Library