An AI-powered Retrieval-Augmented Generation (RAG) application for answering Operating Systems questions from course material.
The system retrieves relevant textbook chunks from Qdrant, reranks them using a cross-encoder model, and generates grounded answers with source references.
- Ask natural-language Operating Systems questions
- Semantic vector search with Qdrant
- OpenAI embeddings using
text-embedding-3-small - Cross-encoder reranking with
ms-marco-MiniLM-L-6-v2 - OpenAI-generated answers
- Source section and PDF-page references
- React + Vite frontend
- FastAPI backend
- Retrieval evaluation using Recall@K
- Frontend: React, TypeScript, Vite, Tailwind CSS, shadcn/ui
- Backend: FastAPI, Python
- Vector Database: Qdrant
- Embeddings and Generation: OpenAI API
- Reranking: Sentence Transformers CrossEncoder
os-scholar-rag/
├── backend/ # FastAPI API and retrieval logic
│ ├── main.py
│ ├── retriever.py
│ └── generator.py
├── ingestion/ # Scripts to chunk, embed, and index documents
├── eval/ # Retrieval evaluation scripts
├── frontend/ # React + Vite user interface
├── data/ # Local source documents (not committed)
├── requirements.txt # Python dependencies
└── .env # Local secrets (not committed)
Install:
- Python 3.10 or later
- Node.js 18 or later
- npm
- Docker Desktop (recommended for local Qdrant)
- An OpenAI API key
git clone https://github.com/YOUR_USERNAME/os-scholar-rag.git
cd os-scholar-ragmacOS/Linux:
python3 -m venv venv
source venv/bin/activateWindows PowerShell:
python -m venv venv
venv\Scripts\Activate.ps1pip install -r requirements.txtIf requirements.txt has not yet been generated:
python -m pip freeze > requirements.txtcd frontend
npm install
cd ..Create a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key
QDRANT_URL=http://localhost:6333Never commit .env or API keys to GitHub.
Using Docker:
docker run -p 6333:6333 -p 6334:6334 \
-v "$(pwd)/qdrant_storage:/qdrant/storage" \
qdrant/qdrantQdrant will be available at:
http://localhost:6333
Place your permitted source documents inside data/, then run your ingestion script:
python ingestion/YOUR_INGESTION_SCRIPT.pyThis creates the gate_os collection and uploads chunks, embeddings, and page metadata to Qdrant.
Do not commit copyrighted textbook PDFs or other material you do not have permission to distribute.
From the project root:
source venv/bin/activate
cd backend
uvicorn main:app --reload --port 8000Backend URL:
http://localhost:8000
Health check:
http://localhost:8000/health
Open a second terminal:
cd frontend
npm run devOpen:
http://localhost:5173
Request:
{
"query": "What is the difference between preemptive and non-preemptive scheduling?"
}Response:
{
"answer": "…",
"sources": [
{
"section": "CPU Scheduling",
"page": 205
}
]
}Run the retrieval evaluation from the project root:
python -m eval.eval_retrievalThe evaluation measures whether the correct source page appears among the top retrieved results.
The following files and directories must remain untracked:
.env
venv/
qdrant_storage/
__pycache__/
*.pyc
frontend/node_modules/- Page-level result deduplication
- Hybrid search with keyword and semantic retrieval
- Better retrieval benchmark dataset
- Dockerized deployment
- Rate limiting and API-cost protection
- Deployable demo using Qdrant Cloud
Satyam Goswami