A powerful Retrieval Augmented Generation (RAG) chatbot designed specifically for .ppt .pdf notes. It combines local LLM capabilities with advanced document retrieval to provide accurate, context-aware answers about software engineering concepts.
demo : youtube DEMO
## π Features-
π Document Processing: Intelligent handling of various file formats
- PDF lecture notes with multi-page support
- PowerPoint (PPTX) presentations
- Automatic chunking with overlap for context preservation
- Text extraction with metadata retention (source, page numbers)
-
π Advanced Retrieval:
- Hybrid search combining semantic (vector) and keyword-based (BM25) retrieval
- ChromaDB vector database for efficient similarity search
- Custom relevance scoring and result ranking
- Configurable retrieval parameters (chunk size, overlap, top_k)
-
π§ Local LLM Integration:
- Runs entirely offline with Ollama
- Multiple model support with live switching (mistral, llama2, etc.)
- Optimized prompting with context window management
- Stream responses for better user experience
-
π Advanced Prompt Engineering:
- Chain-of-thought reasoning
- Few-shot learning examples for complex queries
- Self-reflective answer generation
- Structured output formatting based on query type
- Dynamic prompt selection based on question analysis
-
π» Rich Terminal UI:
- Beautiful interactive interface with Rich
- Markdown rendering for formatted responses
- Progress indicators during processing
- Command system with help, history, and model management
- Syntax highlighting and pretty printing
RagChitChat/
βββ README.md # Project documentation
βββ requirements.txt # Dependencies
βββ setup.py # Package setup for imports
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
β
βββ data/ # Raw lecture notes (.pdf, .pptx)
βββ processed/ # Processed text data
βββ chroma_db/ # Vector database storage
β
βββ src/ # Source code
β βββ __init__.py
β βββ document_processor/ # PDF and PPTX processing
β β βββ __init__.py
β β βββ processor.py # Document processing classes
β β
β βββ vector_store/ # ChromaDB integration
β β βββ __init__.py
β β βββ chroma_store.py # Vector database management
β β
β βββ retriever/ # Haystack retrieval components
β β βββ __init__.py
β β βββ haystack_retriever.py # Document retrieval
β β
β βββ llm/ # Ollama integration
β β βββ __init__.py
β β βββ ollama_client.py # LLM interface
β β
β βββ prompts/ # Prompt engineering
β β βββ __init__.py
β β βββ prompt_templates.py # Advanced prompt templates
β β
β βββ interface/ # Rich terminal UI
β β βββ __init__.py
β β βββ terminal_ui.py # Terminal interface
β β
β βββ main.py # Entry point
β
βββ config/ # Configuration files
βββ __init__.py
βββ settings.py # Application settings
- Python 3.8 or higher
- 8GB RAM minimum (16GB recommended for larger models)
- Storage space for models and vector database (2GB+)
- Windows, macOS, or Linux
# Install Python (if not already installed)
# Download from https://www.python.org/downloads/
# Clone the repository (if using git)
git clone https://github.com/nxdun/RagChitChat.git
cd RagChitChat
# Create and activate virtual environment
python -m venv env
# On Windows
.\env\Scripts\activate
# On macOS/Linux
source env/bin/activate
# Install required packages
pip install -r requirements.txt
# (optional)Install package for imports (optional, if import issues occur)
pip install -e .
# Download and install Ollama from https://ollama.ai/
# Pull required models (after installing)
ollama pull mistral:7b-instruct-v0.3-q4_1 # Default model(You can edit this on env)
ollama pull llama2 # Alternative model (optional)
# Create data directory (root Dir)
mkdir -p data
# Copy your lecture notes into data folder
# Supported formats: PDF, PPTX
# Example: cp ~/Downloads/CTSE_Lecture*.pdf data/
# Copy example environment file
cp .env.example .env
# Edit .env file with your settings
# nano .env or use any text editor
# Start the chatbot
python src/main.py
You can configure the application through environment variables or by editing config/settings.py
:
Variable | Description | Default |
---|---|---|
RAGCHITCHAT_DATA_DIR |
Directory containing lecture notes | data |
RAGCHITCHAT_PROCESSED_DIR |
Directory for processed documents | processed |
RAGCHITCHAT_DB_DIR |
Directory for vector database | chroma_db |
RAGCHITCHAT_MODEL |
Default Ollama model | mistral:7b-instruct-v0.3-q4_1 |
OLLAMA_URL |
Ollama API URL | http://localhost:11434 |
RAGCHITCHAT_CHUNK_SIZE |
Document chunk size | 1000 |
RAGCHITCHAT_CHUNK_OVERLAP |
Overlap between chunks | 200 |
RAGCHITCHAT_TOP_K |
Number of context documents to retrieve | 5 |
Once the application is running, you can interact with it through the terminal:
Command | Description |
---|---|
/help |
Show available commands |
/exit |
Exit the application |
/clear |
Clear conversation history |
/history |
Show conversation history |
/models |
List available models |
/model <name> |
Switch to a different model |
/info |
Show system information |
/about |
About the application |
Here are some examples of questions you can ask:
- "What is continuous integration?"
- "Explain the difference between DevOps and DevSecOps"
- "What are the benefits of microservices architecture?"
- "How does containerization improve software deployment?"
- "Compare agile and waterfall methodologies in software engineering"
You can switch between different LLMs during runtime:
/models # List available models
/model mistral:7b-instruct-v0.3-q4_1 # Switch to Mistral
/model llama2 # Switch to Llama 2
The system automatically selects prompting strategies based on question type:
- Factual questions: Standard RAG with direct answers
- Comparative questions: Structured comparison format
- Procedural questions: Step-by-step instructions
- Complex questions: Self-reflective generation
The retrieval system combines two search methods for better results:
- Vector search: Semantic similarity using embeddings
- BM25 search: Keyword-based traditional search
Problem: Import errors when running python src/main.py
Solution: Install the package in development mode:
pip install -e .
Problem: "Cannot connect to Ollama" error Solution: Ensure Ollama is installed and running:
# Check if Ollama is running
curl http://localhost:11434/api/tags
# If not running, start Ollama application
Problem: Model not found when switching models Solution: Pull the model using Ollama CLI:
ollama pull <model_name>
Problem: High memory usage
Solution: Use a smaller model or reduce RAGCHITCHAT_TOP_K
in settings
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.