A sophisticated Retrieval-Augmented Generation (RAG) system designed to analyze and query AI research papers using Google's Gemini models and ChromaDB.
- PDF Processing: Automatically processes AI research papers in PDF format
- Local ChromaDB: Uses local ChromaDB for efficient vector storage and retrieval
- Multiple Interfaces: CLI, Web API, and Streamlit web interface
- Session Management: Persistent chat sessions with auto-save functionality
- Streaming Responses: Real-time response streaming for better user experience
pip install -r requirements.txt
Create a .env
file with your Google API key:
GOOGLE_API_KEY=your_google_api_key_here
GEMINI_MODEL=gemini-2.0-flash-thinking-exp-01-21
GEMINI_TEMPERATURE=0.4
Place your AI research papers (PDF files) in the Data/
directory.
Run the initialization script to process PDFs and create the vector database:
python init_database.py
# Interactive mode (recommended)
python main.py --mode interactive
# Direct query
python main.py --mode gemini --query "What are transformers in deep learning?"
# Raw document retrieval
python main.py --mode direct --query "neural networks" --documents 5
Start the FastAPI server:
python server.py
API endpoints:
POST /query/
- Submit queriesGET /health
- Health check 748FGET /sessions
- List sessions- And more...
Launch the web interface:
streamlit run st.py
RAG/
├── Data/ # PDF research papers
├── Chroma_db/ # Local ChromaDB storage
├── SavedStates/ # Session backups
├── Src/
│ ├── configs.py # Configuration settings
│ ├── vector_db.py # ChromaDB operations
│ ├── gemini_query.py # Gemini integration
│ ├── prompts.py # System prompts
│ ├── interactive.py # Interactive session handling
│ ├── state.py # Session state management
│ └── Rag.py # Document processing
├── main.py # CLI interface
├── server.py # FastAPI server
├── st.py # Streamlit app
├── api_client.py # API client
└── init_database.py # Database initialization
Key configuration options in Src/configs.py
:
chunk_size
: Document chunk size (default: 1000)chunk_overlap
: Chunk overlap (default: 200)collection_name
: ChromaDB collection name (default: "AI_Papers")persist_directory
: ChromaDB storage location (default: "./Chroma_db")
The system is optimized for AI research with specialized prompts that:
- Focus on technical accuracy
- Provide paper citations
- Explain complex concepts clearly
- Compare different approaches across papers
- Automatic session persistence
- Configurable auto-save thresholds
- Multiple storage backends (JSON, Vector DB)
- Session restoration and backup
- Health monitoring
- Session management
- Streaming responses
- Background task processing
- Automatic session cleanup