All work
Personal / portfolio projectEvaluated grounded RAG core

Engineering Onboarding Copilot

Engineering onboarding often depends on fragmented documentation and tribal knowledge. This project demonstrates how evaluated Retrieval-Augmented Generation can reduce time-to-context while remaining grounded in source documentation.

Evaluated RAG for grounded engineering knowledge

FastAPIPostgreSQLpgvectorOpenAINext.jsTypeScriptPython
Try the Copilot
Explore the Code

Engineering question → grounded answer

A complete walkthrough of the Retrieval-Augmented Generation pipeline—from asking an engineering question to retrieving evidence, reranking results, generating a grounded response with citations, and managing the underlying knowledge base through document ingestion, inspection, and lifecycle management.

Grounded Answers

Responses are generated only from retrieved engineering documentation.

Evidence Provenance

Every answer includes supporting documentation and citations used during generation.

Evaluated Retrieval

LLM reranking improves retrieval quality and significantly increases precision over vector search alone.

Dynamic Knowledge Base

Upload documentation, inspect indexed chunks, manage embeddings, and extend the knowledge base without rebuilding the application.

Grounded Answers

Responses are generated only from retrieved engineering documentation.

Evidence Provenance

Every answer includes supporting documentation used during generation.

Evaluated Retrieval

LLM reranking improved Top-1 retrieval from 73.3% to 93.3%.

Safe Abstention

Unsupported questions are declined instead of hallucinated.

93.3%Top-1 Retrieval
93.3%Recall@3
0.967MRR
100%Grounding Accuracy
Overview

An evaluated RAG core, not a chatbot demo

A retrieval-augmented generation system that answers engineering questions from internal knowledge — with retrieval evaluation, reranking, grounded generation, citations, and safe abstention built in from the start.

PythonFastAPIPydanticPostgreSQLpgvectorDockerOpenAI embeddingsRAGVector searchRerankingpytestEvaluation pipelines
Problem

Why naive LLM Q&A isn't sufficient

Engineering knowledge is fragmented across documentation, runbooks, architecture guidance, operational standards, and tribal knowledge. LLMs can produce fluent answers, but enterprise knowledge systems need more than fluency.

A model answering from memory can't prove its sources, say "I don't know," or be measured — unacceptable for incidents, rollbacks, and production standards. The system has to meet a harder bar:

  • Relevant retrieval
  • Evidence provenance
  • Measurable quality
  • Grounded generation
  • Citations
  • Safe abstention
Architecture

The pipeline, end to end

  1. 01

    FastAPI API

    Typed, validated request surface with Pydantic contracts

  2. 02

    Retrieval Layer

    Fetches a broad candidate set of relevant evidence

  3. 03

    pgvector

    Semantic vector store inside PostgreSQL

  4. 04

    LLM Reranker

    Reorders candidates by true relevance, not proximity

  5. 05

    Grounded Generation

    Answers strictly from retrieved evidence

  6. 06

    Evidence & Citations

    Validates and attaches supporting sources

  7. 07

    Enterprise UI

    Cited answer delivered to the engineer

Ingestion & section-aware chunking

Documents are split along their structure — headings, sections, and procedures — rather than by arbitrary character counts. Section-aware chunking keeps a piece of evidence attached to the context that makes it meaningful, so a rollback step is not severed from the procedure it belongs to.

Embeddings & pgvector

Each chunk is embedded and stored in PostgreSQL with the pgvector extension. Using Postgres keeps the infrastructure reproducible and familiar: one container, one schema, standard SQL, and vector similarity in the same place as the rest of the data.

Vector retrieval & reranking

Vector retrieval improves semantic matching, but the nearest vector is not necessarily the best evidence. I therefore retrieve a broader candidate set and rerank it before generation — which is exactly where the measured Top-1 jump from 73.3% to 93.3% comes from.

Context assembly & grounded generation

The reranked evidence is assembled into a bounded context, and the model is instructed to answer strictly from that context. Generation is grounded in retrieved sources rather than model memory, which is what makes the answers auditable.

Citation handling & abstention

Citations are validated against the evidence actually used. If the retrieved context does not support an answer, the system abstains instead of fabricating one — a deliberate design choice, because a confident wrong answer is worse than an honest 'I don't know.'

FastAPI layer & testing

A FastAPI interface with Pydantic contracts exposes a typed, validated API surface, and pytest covers the API behavior. The contract makes the system something other services could integrate with, not just a script.

Highlights

Why this project stands out

Grounded Generation
Section-Level Citations
pgvector Retrieval
LLM Reranking
Safe Abstention
FastAPI + Next.js
Product

Inside the product

A look at the interfaces behind the platform — from knowledge ingestion and grounded Q&A to document and chunk-level inspection of everything stored for retrieval.

Knowledge Management Workspace

Knowledge Management Workspace

Upload, index, search, filter, and manage engineering documentation through a dedicated knowledge workspace with live corpus statistics.

Ask Copilot

Ask Copilot

Grounded engineering Q&A with citation-aware retrieval — vector candidate retrieval, reranking, and citation-filtered generation shown inline.

Document Inspector

Document Inspector

Inspect indexed documents, metadata, embedding dimensions, and chunk organization exactly as they are stored for retrieval.

Chunk-Level Inspection

Chunk-Level Inspection

Explore individual chunks as stored in the vector database — section boundaries, indexed text, and embedding metadata, with safe deletion.

Codebase

Repository Highlights

The building blocks that make up the implementation — each isolated as its own concern.

Provider abstraction
pgvector retrieval
LLM reranking
Grounded generation
Evaluation suite
Automated API tests
Section-aware chunking
FastAPI backend
Next.js frontend
Evaluation

Measuring whether it actually works

The evaluation deliberately separates two things: how well the system retrieves the right evidence, and how well it generates grounded answers from that evidence.

Retrieval evaluation

Global corpus

Global chunk-level retrieval evaluation over the full corpus. This is the noisier, more realistic setting — and it shows the measurable effect of reranking.

Vector Vector + Reranking
Top-173.3% 93.3%
Recall@386.7% 93.3%
MRR0.867 0.967

Generation evaluation

Curated suite

Results on the current curated evaluation suite. These measure the behavior of the generation and grounding layer on a defined set of cases — they are not claims of universal model accuracy.

Grounding Accuracy
100%6/6
Citation Presence
100%4/4
Citation Validity
100%4/4
Abstention Accuracy
100%2/2

A note on honesty in evaluation

The repository also contains isolated long-document evaluation results. Those are curated, single-document tests and are labeled as isolated evaluation — not general production accuracy. The global corpus numbers above are the honest measure of retrieval quality.

Results

Measured Results

Top-1 Retrieval73.3% → 93.3%
Recall@393.3%
MRR0.967
Grounding Accuracy100%
Backend Tests5/5 Passing
Failure modes

What measurement exposed

Each of these was discovered by evaluating the system, not by anticipating it. The architecture is the accumulated response to them.

  • Naive lexical retrieval missed semantically relevant passages that used different wording.
  • Pure vector nearest-neighbor sometimes surfaced plausible-but-wrong chunks as the top result — reranking was added specifically to correct this.
  • Long documents diluted retrieval quality until section-aware chunking preserved structural context.
  • Ungrounded generation could produce fluent answers with no supporting evidence — grounding and abstention close that gap.
Decisions

Engineering Decisions

Why Retrieval?

Separating retrieval from generation makes failures diagnosable and measurable.

Why pgvector?

Semantic retrieval scales far better than lexical search for engineering documentation.

Why Reranking?

Embedding retrieval finds candidates while LLM reranking improves precision.

Why Safe Abstention?

Enterprise AI should explicitly decline unsupported questions instead of fabricating answers.

Insights

Lessons Learned

Key engineering insights gained while designing and evaluating a production-style Retrieval-Augmented Generation platform.

Retrieval Matters More Than Prompting

Most answer-quality issues originate in retrieval rather than generation. Measuring retrieval independently made failures diagnosable.

Trust Requires Safe Abstention

An enterprise AI assistant should explicitly decline unsupported questions instead of generating plausible but incorrect answers.

Evaluation Beats Intuition

Separating retrieval evaluation from generation evaluation made improvements measurable instead of subjective.

Architecture Enables Evolution

Separating retrieval, reranking, generation, providers, and API layers allows each component to evolve independently.

How it evolved

Build → measure → discover → improve

Build
Measure
Discover failure
Improve architecture
Evaluate again

The architecture evolved because measurement exposed specific failure modes. Not every design choice was known beforehand — each layer was added in response to something the evaluation revealed.

  1. 1

    Lexical retrieval baseline

    Start simple with keyword matching to establish a reference point.

  2. 2

    Vector retrieval

    Move to embeddings for semantic matching beyond exact terms.

  3. 3

    Retrieval evaluation

    Measure retrieval quality before trusting it — Top-1, Recall@3, MRR.

  4. 4

    Reranking

    The nearest vector is not always the best evidence; rerank a broader candidate set.

  5. 5

    Long-document stress testing

    Push the system on large documents to expose retrieval failure modes.

  6. 6

    Section-aware chunking

    Chunk along document structure so evidence keeps its context.

  7. 7

    Grounded generation

    Generate answers strictly from retrieved evidence, not model memory.

  8. 8

    Citation filtering & abstention

    Validate citations and abstain when evidence is insufficient.

  9. 9

    FastAPI contract

    Expose a typed, validated API surface with Pydantic.

  10. 10

    Automated retrieval & generation evaluation

    Make quality measurable and repeatable in CI-style pipelines.

Enterprise roadmap

From prototype to platform

The evaluated RAG core is real and measured. Turning it into an enterprise knowledge platform is a defined path — clearly separated here from what already exists.

Built

What exists in the repository today

  • Evaluated grounded RAG core
  • Vector retrieval + reranking
  • Section-aware chunking
  • Grounded generation with citations and abstention
  • FastAPI interface with Pydantic contracts
  • Automated retrieval and generation evaluation
Roadmap

How this prototype could evolve into an enterprise knowledge platform — not yet built

Enterprise connectors

  • Google Drive
  • Confluence
  • Notion
  • GitHub
  • Slack

Identity & security

  • SSO
  • RBAC
  • Source-level permissions
  • Audit logging
  • Secrets management

Production operations

  • Observability
  • Tracing
  • Latency monitoring
  • Cost monitoring
  • Feedback loops
  • Evaluation regression testing

AI platform

  • Model routing
  • Provider fallback
  • Prompt / version management
  • Knowledge freshness
  • Incremental ingestion
Lessons learned

What I'd carry into production

  • Measurement is the design tool. Each architectural layer was added in response to a failure the evaluation exposed — not planned up front.
  • Retrieval quality is the ceiling on answer quality. A better model cannot fix evidence it never received.
  • Abstention is a feature. Knowing when not to answer is part of building trustworthy AI.
  • Provider abstraction keeps models replaceable, so the system is not hostage to a single vendor or version.