Case study · 01AI System · RAG

RAG System for Academic Institutions: Grounded Answers with Real Citations

A grounded, citation-aware question answering layer over institutional knowledge: syllabi, policies and archived research.

Python · LangChain · LangGraphRead time · 6 minUpdated · October 2026By Lalit Chaudhari
94%
Citation accuracy
1.8s
Answer latency p95
12k+
Sources indexed
Stack · Shipped 2025
PythonLangChainLangGraphpgvectorFastAPIOpenAI
01 · Overview

What this system does.

Universities and colleges sit on years of knowledge: syllabi, academic policies, handbooks and archived research. Finding a precise, trustworthy answer in that material is slow, and general-purpose chatbots make it worse by inventing sources that do not exist.

This system is a retrieval-augmented generation (RAG) layer built specifically for that problem. Every answer is grounded in the institution's own documents, every claim carries a citation back to its source, and when the evidence is not strong enough the system says so instead of guessing.

02 · The problem

Why the existing setup was not good enough.

Academic teams needed answers grounded in their own documents. Off-the-shelf chatbots either hallucinated citations or dropped context across multi-step questions, and faculty needed answers they could trust enough to publish in a course handbook.

03 · The approach

How I solved it.

Hybrid retrieval (BM25 plus dense embeddings), cross-encoder reranking, then a constrained generator that refuses to answer when grounded confidence drops below a threshold. State is managed by a LangGraph state machine with checkpointing for replay and audit.

Step 01
Question
Faculty or staff query
Step 02
Hybrid retrieval
BM25 + dense, top 20
Step 03
Rerank
Cross-encoder, top 8
Step 04
Grounded answer
Citations enforced
Step 05
Refuse or reply
Confidence threshold
04 · Architecture

How it is built.

  1. 01Ingestion → chunking on semantic boundaries → OpenAI embeddings → pgvector
  2. 02Hybrid retriever combines lexical (BM25) and dense recall, top-k = 20
  3. 03Cross-encoder reranker narrows the candidates to the top 8 with calibrated scores
  4. 04Generator runs inside a LangGraph graph with a deterministic refusal node
  5. 05Postgres-backed checkpointer stores conversation state for replay and audit
05 · Key decisions

The engineering choices that mattered.

Hybrid retrieval instead of vectors alone

Academic documents are full of exact identifiers such as course codes, policy numbers and proper names, which dense embeddings tend to blur. BM25 catches those exact matches while dense retrieval catches paraphrased questions, so combining both improves recall on both kinds of query.

A cross-encoder reranker before generation

Retrieval is tuned for recall (20 candidates). The cross-encoder reads each question and passage together and keeps only the 8 most relevant, so the generator sees less noise and cites the right passage.

Refusal is a node in the graph, not a prompt instruction

Asking a model nicely not to hallucinate is not a guarantee. The LangGraph graph has a deterministic refusal path that runs when grounded confidence drops below a threshold, so a weak answer is never shown as a confident one.

pgvector inside Postgres

Embeddings live next to document metadata and the conversation checkpoints in one Postgres database, which keeps filtering, joins, backups and access control in a single system.

Checkpointed state for replay and audit

Every conversation step is persisted. Any answer can be replayed to see exactly which passages were retrieved and why, which matters when the answer ends up in a course handbook.

06 · Outcome

What changed.

94%
Citation accuracy
1.8s
Answer latency p95
12k+
Sources indexed
07 · FAQ

Frequently asked questions.

What is a RAG system for academic institutions?
It is a question answering system that retrieves passages from an institution's own documents (syllabi, policies, handbooks and research) and generates an answer grounded only in those passages, with citations back to each source.
How does this RAG system avoid hallucinated citations?
Answers are generated only from reranked passages, every claim must cite one of them, and a deterministic refusal step in the LangGraph graph declines to answer when grounded confidence is below a threshold.
Why combine BM25 and dense embeddings?
BM25 is strong on exact terms such as course codes and policy names, while dense embeddings handle paraphrased questions. Hybrid retrieval gets the benefits of both before a cross-encoder reranks the results.
Which technologies does the system use?
Python, LangChain and LangGraph for orchestration, OpenAI models for embeddings and generation, pgvector in PostgreSQL for vector search, a cross-encoder reranker, and FastAPI for the API layer.
Can the same approach work for a company knowledge base?
Yes. The pipeline is not specific to education. Internal wikis, policy libraries, support documentation and contracts all benefit from the same hybrid retrieval, reranking and citation enforcement.

Want something like this built?

Happy to walk through the architecture, the trade-offs, and how it would fit your team.

Start a conversation