← All work

Independent lab · not an employer deliverable

Cortex

RAG Knowledge Intelligence Lab

Inspect how a retrieval pipeline selects evidence, grounds an answer, and fails closed when sources are thin.

Jump to interactive demo

Problem

Most RAG demos hide the retrieval step behind a chat bubble. Cortex treats retrieval as the product: query planning, passage selection, citation, and a lightweight evaluation of whether the answer is actually supported.

Interactive demo

Local simulation over sample technical documents. Results are deterministic demo data—not live model output.

Cortex · RAG workbenchLocal simulation · sample corpus
  1. query
  2. retrieve
  3. rerank
  4. ground
  5. cite

Answer · curated, evidence-checked

A RAG pipeline retrieves top-k passages, optionally reranks them, then answers from that evidence with citations. Groundedness checks whether claims are attested in retrieved text; fluency alone is not enough.

Groundedness

73%

Token overlap with retrieved passages

Source coverage

100%

Cited docs present in retrieval

Retrieved passages

Source inspector

Grounded answers in retrieval-augmented generation

Retrieval-augmented generation answers a question from selected passages instead of relying only on model memory.

Supports answer: yes

Corpus

  • Versioned REST APIs with FastAPI
  • At-least-once delivery and idempotent consumers
  • Grounded answers in retrieval-augmented generation · cited
  • PostgreSQL indexing for read-heavy APIs
  • Independent deploys on Kubernetes
  • RED metrics and alerting with Prometheus

Architecture

A query service embeds or tokenizes the question, retrieves candidate passages from a document store, optionally reranks them, then synthesizes an extractive answer strictly from selected evidence. An evaluation module scores groundedness and source coverage. This portfolio build uses a local lexical retriever over bundled sample documents—no model API is called.

Query → tokenize / expand → retrieve top-k passages → rerank by strategy → extractive synthesis → cite sources → evaluate overlap with supporting passages.

Decisions

  • — Keep the answer extractive so every sentence can be traced to a passage.
  • — Expose retrieval strategy and k as first-class controls rather than hidden hyperparameters.
  • — Separate gold-supported answers for curated questions from fallback extractive synthesis for free-text queries.

Trade-offs

  • — Lexical retrieval is inspectable and deterministic, but it will miss paraphrases that a dense embedder would catch.
  • — Extractive answers are honest without an LLM, and they are less fluent than generative copy.
  • — A tiny corpus makes ranking differences obvious; it is not a substitute for production-scale evaluation.

Failure modes

  • — Queries outside the corpus return low coverage and a refused or weakly supported answer.
  • — Raising k can dilute precision if later passages are only loosely related.
  • — A title-heavy rerank can overfit to document names instead of passage content.

Evaluation

Groundedness estimates how much of the answer is attested in retrieved text. Source coverage estimates how many of the cited documents actually appeared in the retrieved set. Both are illustrative checks on demo data, not published quality benchmarks.

Production extensions

Proposed — not implemented in this portfolio.

  • — Swap the lexical index for embeddings and a vector store.
  • — Add a real LLM with citation constraints and a hallucination grader.
  • — Persist query traces for offline evaluation sets.

Python · FastAPI · embeddings · vector retrieval · RAG · evaluation