How it works

A small, inspectable retrieval-augmented generation (RAG) system built on Postgres.

Guidelines
14
Passages
56
Embedded
0
Answer model
Off
  1. 1

    Ingest

    Each Markdown guideline is split into section-sized passages and stored in Postgres.

  2. 2

    Index

    A generated tsvector column powers full-text search; pgvector stores 768-dimension embeddings (nomic-embed-text) with an HNSW index.

  3. 3

    Retrieve

    Keyword search scores passages by the IDF weight of matched words, with a small medical synonym list. Vector search finds nearest neighbors by cosine distance.

  4. 4

    Fuse

    Reciprocal Rank Fusion merges both rankings using rank positions only, so the two scoring scales never need calibrating.

  5. 5

    Generate

    A local Llama model answers from the top passages only and must cite them; citations to sources that don't exist are removed.

Measured, not assumed

A 16-question retrieval eval runs in CI and fails the build if recall@1 or mean reciprocal rank drops below 0.9. Adding IDF weighting and query expansion raised keyword-only recall@1 from 81% to 100%. The set is small and was written alongside the corpus, so treat these numbers as a regression guard, not a benchmark.