How nisargkadam/rag_evaluation works
This is an inspectable fitness-and-nutrition RAG learning application. Users ask questions through a Streamlit or terminal interface; the agent retrieves page-ranked evidence, evaluates search quality, optionally retries once with a rewritten query, generates a source-constrained answer, evaluates it, and returns sources, scores, and retry counts. A separate PDF-ingestion path builds the FAISS knowledge base, while labeled benchmarks provide reproducible evaluation. The graph follows documented workflow stages; some internal wiring is inferred only from README descriptions because source excerpts are partial.
Main entry points: agent.py Search evaluation · ingest.py PDF ingestion · run_evaluation.py Benchmark runner · streamlit_app.py Streamlit chat
Components 21
User interfaces
- Streamlit chat
streamlit_app.py - Terminal chat
app/main.py
RAG workflow
- RAG agent
app/agent.py - Page retrieval
app/agent.py - Search evaluation
app/agent.py - Query rewrite
app/agent.py - Answer generation
app/agent.py - Answer evaluation
app/agent.py - Workflow state
app/graph.py
Knowledge ingestion
- FAISS index
- Nutrition PDFs
data/pdfs - PDF ingestion
app/ingest.py - Chunk strategies
app/chunking_strategies.py - Local embeddings
Evaluation
- LLM judge
app/judge.py - Metric calculations
app/evaluation.py - Labeled questions
data/evaluation_questions.json - Benchmark helpers
app/benchmarks.py - Benchmark runner
run_evaluation.py
Other components
- Questioner
- OpenAI model
Connections 27
- Questioner → Streamlit chat: asks in
README.md - Questioner → Terminal chat: asks in
README.md - Streamlit chat → RAG agent: submits query
streamlit_app.py - Terminal chat → RAG agent: submits query
app/main.py - RAG agent → Page retrieval: starts workflow
README.md - Page retrieval → FAISS index: retrieves pages
README.md - Page retrieval → Search evaluation: evaluates results
README.md - Search evaluation → LLM judge: judges relevance
app/agent.py - Search evaluation → Metric calculations: calculates scores
README.md - Search evaluation → Query rewrite: requests bounded retry
README.md - Query rewrite → Page retrieval: retries search
README.md - Search evaluation → Answer generation: approves evidence
README.md - Answer generation → OpenAI model: generates answer
README.md - Answer generation → Answer evaluation: evaluates answer
README.md - Answer evaluation → LLM judge: judges support
app/agent.py - Answer evaluation → Metric calculations: calculates scores
README.md - Answer evaluation → Answer generation: requests stricter retry
README.md - RAG agent → Workflow state: carries workflow state
app/agent.py - Nutrition PDFs → PDF ingestion: loads documents
README.md - PDF ingestion → Chunk strategies: selects strategy
app/ingest.py - PDF ingestion → Local embeddings: embeds chunks
README.md - PDF ingestion → FAISS index: writes index
app/ingest.py - Labeled questions → Benchmark helpers: loads labels
app/benchmarks.py - Streamlit chat → Benchmark helpers: matches questions
streamlit_app.py - Benchmark runner → RAG agent: runs benchmark queries
run_evaluation.py - Benchmark runner → Labeled questions: reads cases
README.md - Benchmark runner → Metric calculations: aggregates scores