A production-oriented Agentic RAG pipeline designed for researchers and engineers to query academic literature using a combination of:
- Local research paper retrieval
- Real-time web search
- Intelligent query routing
- Reranking
- Citation-grounded generation
- Automated evaluation
The system dynamically decides whether a query should be answered using:
- Internal research documents
- External web knowledge
- A hybrid combination of both
flowchart TD
A[User Query]
A --> B[Intent Router]
B -->|Local| C[Vector Retrieval]
B -->|Web| D[Web Search]
B -->|Hybrid| C
B -->|Hybrid| D
C --> E[Qdrant Vector Database]
D --> F[Tavily / Brave Search]
E --> G[Reranker]
F --> G
G --> H[Context Builder]
H --> I[LLM Generation]
I --> J[Answer + Citations]
J --> K[Streamlit UI]
The system uses an LLM-based router to classify queries:
Question
|
▼
Router
|
├── local
|
├── web
|
└── hybrid
Examples:
| Query | Route |
|---|---|
| Explain transformer architecture from papers | Local |
| Latest AI announcements | Web |
| Compare research papers with current industry trends | Hybrid |
Research papers are processed through:
PDF
|
▼
Layout-aware Parser
|
▼
Hierarchical Chunking
|
▼
Metadata Extraction
|
▼
Embedding Generation
|
▼
Qdrant Index
The ingestion pipeline preserves:
- Paper title
- Authors
- Page numbers
- DOI information
- Source metadata
The retrieval pipeline contains:
Vector similarity search using:
- Qdrant
- Dense embeddings
Retrieved documents are refined using:
- Cross encoder reranking
- Relevance filtering
Pipeline:
Query
|
▼
Vector Search
|
▼
Top-K Documents
|
▼
Reranker
|
▼
LLM Context
The system is orchestrated using LangGraph.
Graph:
Query
|
▼
Intent Router
/ | \
/ | \
Local Web Hybrid
| | |
▼ ▼ ▼
Qdrant Search Combined
\ | /
Generation
|
▼
Citation Answer
- Python
- FastAPI
- LangGraph
- Async architecture
- OpenAI API
- Embedding models
- Qdrant
- Semantic search
- Hybrid retrieval
- Cross encoder reranking
- Tavily API
- Brave Search API
- Streamlit
- Ragas
- Docker
- Docker Compose
- GitHub Actions
agentic-rag-researcher/
├── src/
│ ├── api/
│ ├── graph/
│ ├── ingestion/
│ ├── retrieval/
│ ├── search/
│ ├── llm/
│ ├── evaluation/
│ └── utils/
├── scripts/
├── tests/
├── streamlit/
├── docker/
├── data/
├── docker-compose.yml
├── pyproject.toml
└── README.md
git clone https://github.com/<username>/agentic-rag-researcher.git
cd agentic-rag-researcherpython -m venv .venv
source .venv/bin/activateWindows:
.venv\Scripts\activatepip install -e .Create:
.env
Example:
OPENAI_API_KEY=
QDRANT_URL=http://localhost:6333
TAVILY_API_KEY=
BRAVE_API_KEY=Run:
docker compose upServices:
FastAPI
|
localhost:8000
Qdrant
|
localhost:6333
Streamlit
|
localhost:8501
Place PDFs:
data/papers/
Run:
python scripts/ingest_papers.pyBackend:
uvicorn src.main:app --reloadFrontend:
streamlit run streamlit/app.pyEndpoint:
POST /api/v1/query
Request:
{
"query":
"Explain retrieval augmented generation"
}Response:
{
"query":
"Explain retrieval augmented generation",
"route_taken":
"local",
"answer":
"RAG combines retrieval systems with language models..."
}The project includes automated RAG evaluation.
Metrics:
Measures whether answers are supported by retrieved evidence.
Measures whether the response answers the user's question.
Measures retrieval quality.
Run:
python scripts/evaluate_rag.pyThis project demonstrates:
✅ Agentic workflow orchestration
✅ Stateful graph execution
✅ Hybrid retrieval architecture
✅ Vector database management
✅ Async API design
✅ Citation-aware generation
✅ RAG evaluation pipeline
✅ Production-style repository organization
This project was developed with the assistance of AI coding tools for code review, refactoring suggestions, documentation support, and debugging assistance. The architecture, engineering decisions, and final implementation were designed and validated by the developer.
Planned:
- Streaming token responses
- Authentication layer
- Distributed vector indexing
- Better document parsing with LlamaParse
- Human feedback loop
- Retrieval analytics dashboard
MIT License