GyaanSetu (ΰ€ΰ₯ΰ€ΰ€Ύΰ€¨ΰ€Έΰ₯ΰ€€ΰ₯) means Bridge of Knowledge β an intelligent RAG-based tutor that answers NCERT curriculum questions using AI.
- What is GyaanSetu?
- Key Features
- Architecture
- Project Structure
- Getting Started
- Configuration
- API Reference
- Evaluation
- Getting Help
- Contributing
- Maintainers
GyaanSetu is a full-stack educational AI assistant built around Retrieval-Augmented Generation (RAG). It ingests NCERT textbook content from HuggingFace, indexes it into a FAISS vector store, and uses a large language model to answer student questions with relevant context sourced directly from the curriculum.
The system currently supports Class 10 Science and is designed to be extended to other classes and subjects.
- π RAG-powered answers β retrieves the most relevant NCERT chunks before generating a response
- π§ Semantic search β uses
sentence-transformers/all-MiniLM-L6-v2embeddings and FAISS for fast similarity search - π€ Pluggable LLM β supports OpenRouter (any hosted model) or a built-in mock LLM for offline development
- π Built-in evaluation β measures retrieval accuracy, generation quality, latency, and embedding coherence
- β‘ FastAPI backend β clean REST API with CORS support, health checks, and automatic docs at
/docs - π¨ React frontend β landing page, interactive chat interface, and an evaluation dashboard
- π³ Docker support β single-command containerized deployment
HuggingFace Dataset
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Ingestion Pipeline β
β HFLoader β Cleaner β Chunker β Embedderβ
ββββββββββββββββββββ¬βββββββββββββββββββββββ
β FAISS index + metadata
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β RAG Service β
β embed query β FAISS search β build β
β context β LLM (OpenRouter / MockLLM) β
ββββββββββββββββββββ¬ββββββββββββββββββββββββ
β JSON response
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend β
β POST /chat GET /evaluation GET /healthβ
ββββββββββββββββββββ¬ββββββββββββββββββββββββ
β HTTP
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (Vite) β
β Home β Chat β Evaluation Dashboard β
ββββββββββββββββββββββββββββββββββββββββββββ
GyaanSetu/
βββ api/ # FastAPI application (routes, schemas)
βββ config/ # Environment-based settings
βββ evaluation/ # Evaluation framework & test data
βββ ingestion/ # Data loading, cleaning, chunking, embedding
βββ llm/ # LLM factory, OpenRouter client, MockLLM, prompt builder
βββ rag/ # Core RAG service (retrieve β context β generate)
βββ scripts/ # Utility scripts for ingestion, RAG, and retrieval testing
βββ ui/react_app/ # React 19 + Vite frontend (Home, Chat, Evaluation pages)
βββ vector_store/ # FAISS index builder and loader
βββ Dockerfile
βββ requirements.txt
βββ README.md
| Tool | Minimum Version |
|---|---|
| Python | 3.11 |
| Node.js | 18 |
| npm | 9 |
| Docker (optional) | 20 |
1. Clone the repository
git clone https://github.com/anan5093/GyaanSetu.git
cd GyaanSetu2. Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate3. Install Python dependencies
pip install -r requirements.txt4. Configure environment variables
Copy the example below into a .env file in the project root and fill in your values:
# LLM (set USE_MOCK_LLM=false to use a real model)
USE_MOCK_LLM=true
OPENROUTER_API_KEY=your_openrouter_key_here
OPENROUTER_MODEL=nvidia/nemotron-3-super:free
# Dataset / retrieval
CLASS_ID=10
SUBJECT=science
TOP_K=3
SCORE_THRESHOLD=0.3
# API server
API_HOST=127.0.0.1
API_PORT=8000
FRONTEND_URL=http://localhost:5173
ENABLE_LOGS=true5. Run the data ingestion pipeline
This step downloads the NCERT dataset from HuggingFace, cleans it, chunks it, and builds the FAISS index.
python scripts/test_ingestion.py
python -m vector_store.build_faiss_index6. Start the API server
uvicorn api.main:app --host 127.0.0.1 --port 8000 --reloadInteractive API docs are available at http://localhost:8000/docs.
cd ui/react_app
npm install
npm run devThe app is served at http://localhost:5173 by default.
Build and run the full backend in a single container:
docker build -t gyaansetu .
docker run -p 8000:8000 \
-e USE_MOCK_LLM=false \
-e OPENROUTER_API_KEY=your_key_here \
-e FAISS_URL=https://your-host/science_faiss.index \
-e META_URL=https://your-host/science_meta.json \
gyaansetuThe API is then available at http://localhost:8000.
All settings are controlled via environment variables (or a .env file loaded by python-dotenv).
| Variable | Default | Description |
|---|---|---|
CLASS_ID |
10 |
NCERT class number |
SUBJECT |
science |
Subject name |
TOP_K |
3 |
Number of chunks retrieved per query |
SCORE_THRESHOLD |
0.3 |
Minimum cosine-similarity score to include a chunk |
USE_MOCK_LLM |
true |
false to use a real OpenRouter model |
OPENROUTER_API_KEY |
β | Your OpenRouter API key |
OPENROUTER_MODEL |
nvidia/nemotron-3-super:free |
Model identifier on OpenRouter |
MAX_TOKENS |
300 |
Maximum tokens for LLM responses |
API_HOST |
127.0.0.1 |
Host for the FastAPI server |
API_PORT |
8000 |
Port for the FastAPI server |
FRONTEND_URL |
http://localhost:5173 |
Allowed CORS origin |
ENABLE_LOGS |
true |
Print verbose startup and request logs |
FAISS_URL |
β | URL to download the pre-built FAISS index (used in Docker/cloud deployments) |
META_URL |
β | URL to download the FAISS metadata JSON (used in Docker/cloud deployments) |
Ask a question about the NCERT curriculum.
Request body
{
"question": "What is Newton's second law of motion?"
}Response
{
"answer": "Newton's second law states that ...",
"sources": [
{ "topic": "Force and Laws of Motion", "chapter": "Force and Laws of Motion", "type": "concept" }
],
"metrics": {
"latency": 0.42,
"chunks_used": 3
}
}Runs the full evaluation suite and returns metrics.
{
"status": "success",
"evaluation": {
"retrieval": { ... },
"generation": { ... },
"latency": { ... },
"embedding": { ... }
}
}Returns the server and RAG initialization status.
{ "status": "ok", "rag_loaded": true }GyaanSetu ships with a built-in evaluation framework under evaluation/. It measures:
| Module | What it measures |
|---|---|
retrieval_eval.py |
Whether relevant chunks are retrieved for test questions |
generation_eval.py |
Quality of generated answers against expected responses |
latency_eval.py |
End-to-end query latency (p50 / p95) |
embedding_eval.py |
Semantic coherence of keyword embeddings |
Test data lives in evaluation/test_data.json. You can run the evaluation via the /evaluation endpoint or directly:
python scripts/test_rag.py- Bug reports & feature requests β open an issue on the GitHub Issues page
- Interactive API docs β available at
http://localhost:8000/docswhen the server is running - OpenRouter models β see openrouter.ai/models for supported LLM identifiers
- NCERT dataset β hosted on HuggingFace at
KadamParth/NCERT_Science_10th
Contributions are welcome! Please open an issue first to discuss significant changes.
- Fork the repository and create a feature branch
- Make your changes with clear commit messages
- Ensure existing tests pass:
python scripts/test_ingestion.py
python scripts/test_rag.py
python scripts/test_vector_retrieval.py- Open a pull request against
main
| Name | GitHub |
|---|---|
| Anand | @anan5093 |
GyaanSetu is an open-source project. See LICENSE for details.