Interactive RAG experimentation lab — compare retrieval strategies and generation modes side-by-side on real documents.
Demo / portfolio project. Run it locally to explore how different RAG pipelines behave.
Pick a document, choose how to chunk/embed/retrieve, pick a RAG mode, and ask questions. Streaming answers plus retrieval insights show how each configuration changes quality.
| Area | Options |
|---|---|
| RAG modes | Basic · Self-RAG · Agentic RAG · Graph RAG |
| Retrieval | Vector (FAISS) · Hybrid (BM25 + RRF) · Multi-query · Cross-encoder rerank |
| Chunking | Recursive · Fixed · Semantic · Structure-aware |
| Embeddings | OpenAI text-embedding-3-small · Local SentenceTransformer |
Also included: knowledge-graph extraction, contextual compression, guided UI walkthrough, and SSE token streaming.
| Layer | Stack |
|---|---|
| Backend | Python, FastAPI, LangChain, FAISS, NetworkX, BM25 |
| Frontend | Next.js, React, TypeScript, Tailwind CSS |
| Models | Gemini (generation) · OpenAI / local (embeddings) · MiniLM (rerank) |
RAGLab/
├── .github/workflows/ci.yml # lint, typecheck, build, security
├── Makefile # setup / run / test
├── raglab-backend/
│ ├── main.py # FastAPI app
│ ├── config.py # env config
│ ├── document_store.py # load + index documents
│ ├── api/ # REST + SSE routes
│ ├── chunking/ # text + structure chunkers
│ ├── embeddings/ # embedding providers
│ ├── graph/ # knowledge graph + graph retrieval
│ ├── ingestion/ # PDF parsing
│ ├── middleware/ # error logging
│ ├── retrieval/ # vector / hybrid / multi-query / rerank
│ ├── services/ # RAG generation + compression
│ ├── documents/ # sample PDFs
│ └── verify_system.py # import / config smoke check
└── raglab-frontend/
├── app/ # Next.js App Router
├── components/ # UI
└── lib/ # API client
- Python 3.11+
- Node.js 18+
- OpenAI API key (embeddings)
- Google Gemini API key (generation)
git clone https://github.com/guptaom31619-prog/RagLab.git
cd RagLab
make setupEdit raglab-backend/.env:
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...make dev| Service | URL |
|---|---|
| Frontend | http://localhost:3000 |
| Backend | http://localhost:8000 |
| API docs | http://localhost:8000/docs |
make test # import + config smoke check
make lint # frontend lint
make build # frontend production build| Command | Description |
|---|---|
make setup |
Install deps + create .env |
make dev |
Run backend + frontend |
make stop |
Stop local processes |
make test |
Backend smoke check |
make lint / make build |
Frontend quality checks |
make clean |
Remove __pycache__ / .next |
make clean-cache |
Wipe document + KG caches |
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
GET |
/documents |
List sample documents |
POST |
/load-document |
Index a document with chosen config |
POST |
/ask |
Full answer |
POST |
/ask-stream |
SSE streaming answer |
Example /ask body:
{
"question": "What was Microsoft's total revenue?",
"search_method": "hybrid",
"use_compression": false,
"rag_mode": "basic"
}Interactive docs: /docs when the backend is running.
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY |
Yes | Embeddings |
GEMINI_API_KEY |
Yes | Answer generation |
NEXT_PUBLIC_API_URL |
No | Frontend → backend URL (default http://localhost:8000) |
Never commit .env. Use .env.example as the template.
GitHub Actions runs on every push / PR to main:
- Backend — Python syntax, structure, requirements check
- Frontend —
tsc, ESLint, production build - Security — no committed
.env/ hardcoded API keys
MIT — see LICENSE.