> cd ../projects / narayan

Narayan

A citation-backed RAG pipeline over academic research PDFs on Azure AI Foundry, using two-stage retrieval to cite every claim with its source file and page number.

2025
RAG System
Python FastAPI Azure AI Foundry Azure OpenAI Azure AI Search React
View on GitHub

Narayan is a citation-backed Retrieval-Augmented Generation system for academic research PDFs. Upload documents, ask a question in plain language, and get an answer grounded in the text — with the exact file and page every claim came from.

The Problem

Researchers spend days skimming PDFs for a single finding. Compliance officers, lawyers, and engineers hit the same wall: the information exists, but finding it eats hours, and teams duplicate work because the person who solved it last quarter already moved on. And because people make real decisions on the answers, every response has to be traceable — no confidence without evidence.

Architecture

Narayan runs on Azure AI Foundry — Azure OpenAI for generation and embeddings, Azure AI Search as the vector store, a FastAPI backend, and a React frontend.

Ingestion. Standard parsers like PyPDF butcher two-column academic layouts, interleaving the left and right columns so the embeddings land on garbage. Narayan uses block-order PDF extraction that respects reading order, pulling blocks top to bottom within each column. SHA-256 content hashing skips duplicate uploads before anything is indexed.

Chunking. 1,000-character chunks with 200-character overlap — small enough to stay focused, big enough to hold a full paragraph, with overlap so context doesn’t vanish at the boundary.

Retrieval. Two-stage: over-fetch 10 candidate chunks from Azure AI Search, then rerank to the top 3 before handing them to the model.

Generation. The system prompt is strict — use only the provided sources, cite them with source file and page number, and say so when the answer isn’t in the documents. No source, no answer.

Why It Matters

The real value is traceability. Every answer points back to an exact page. In medicine, law, or compliance that isn’t optional — and even in lower-stakes work, being able to check the source is what makes people trust the answer.