Applied AI · hybrid RAG · verified citations
Questions about SOPs. Answers you can audit.
Ask a question about the sample procedures below. The engine finds the governing passages with vector and keyword search, fuses and re-ranks them, and lets a language model answer only by quoting the text. Every quote is checked against the stored document before you see it, and if the documents do not say it, the engine says so.
Learning how it works? Under each answer, the walkthrough explains every stage with the numbers from your own question, and links to the code that does it. A map shows where your question landed among the stored chunks, and why the nearest one is not always the passage that answers.
FastAPI · PostgreSQL + pgvector (HNSW) + tsvector (GIN) · RRF · cross-encoder re-ranking · constrained JSON
Ask the corpus
This is a public demo: uploads are closed, questions are limited per visitor and per day, and the corpus below is a set of fictional quality SOPs.
What is in the corpus
- Loading…
How a question is answered
- Embed. The question becomes a vector with a local embedding model (a small ONNX model).
- Hybrid retrieval. One SQL statement runs a pgvector cosine search (HNSW index) and a PostgreSQL full-text search (GIN index) and fuses both with Reciprocal Rank Fusion, keeping the top 50 chunks. Keyword search catches identifiers such as
21 CFR Part 11that embeddings blur. - Re-rank. A cross-encoder (a small ONNX model) reads the question and each candidate together and keeps the best 3.
- Generate. A language model answers under a strict JSON schema: an answer, a confidence score, and quotes copied character for character from the passages, or an explicit "insufficient context".
- Verify. The server looks for every quote in the stored chunk, takes the page number from the database, and drops anything that does not match. An answer that claims to be grounded but has no quote that passes is withheld.
Before any of this, at ingestion, each chunk is stored with a situational preamble (document title, section, pages), following Anthropic's Contextual Retrieval pattern, so a sentence such as "the limit is 10 ppm" stays findable on its own.
Read the rules the language model answers under
Rank fusion lab
The lab needs JavaScript.
Concepts, one at a time
Each idea in a few sentences, with the file that implements it.
The glossary needs JavaScript.