A production-ready RAG (Retrieval-Augmented Generation) system featuring advanced chunking strategies, document cleaning, batch processing, and semantic search.
- Semantic Chunking: AI-powered semantic boundary detection
- Context Chunking: Adds surrounding context for better retrieval
- Late Chunking: Contextual embeddings for improved accuracy
- Markup Chunking: Structure-aware document splitting
- Hybrid Chunking: Combine multiple strategies
- Remove table of contents automatically
- Strip acknowledgements and references
- Clean headers and footers
- Smart section detection
- Upload multiple PDFs at once
- Select All / Deselect All functionality
- Progress tracking with real-time statistics
- Individual and aggregate metrics
- Semantic vector search using Sentence Transformers
- Heuristic reranking with diversity scoring
- Contextual result display
- Configurable score thresholds
- View all indexed documents
- Delete documents from index
- Interactive Qdrant dashboard
- Collection statistics
# Install UV (recommended - fast package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone repository
git clone <repository-url>
cd document_search_pdf
# Install dependencies
uv sync
# Or use pip
pip install -r requirements.txt# Using Docker Compose (recommended)
docker-compose up -d qdrant
# Or standalone Docker
docker run -p 6333:6333 -p 6334:6334 \
-v $(pwd)/qdrant_storage:/qdrant/storage \
qdrant/qdrantVerify Qdrant is running:
- Dashboard: http://localhost:6333/dashboard
- REST API: http://localhost:6333
streamlit run apps/streamlit_upload_app_enhanced.pyFeatures:
- β Multiple file upload with batch processing
- β All chunking strategies (Semantic, Context, Late, Markup, Hybrid)
- β Document cleaning options
- β Real-time statistics and visualizations
- β Full context display in search results
streamlit run apps/pdf_manager_app.pyFeatures:
- β Document management (view, delete)
- β Advanced search with filters
- β Separate collection for PDFs
- β Metadata management
streamlit run apps/streamlit_pubmed_app.pyFeatures:
- β Search pre-indexed PubMed articles
- β Scientific paper search
- β Citation information
- Quick Start Guide - 5-minute setup
- Installation Guide - Detailed installation
- How to Run - Running applications
- Batch Upload Guide - Upload multiple files
- Chunking Strategies Guide - Choose chunking method
- Document Cleaning Guide - Clean documents
- Search Features - Advanced search
- PDF Manager - Document management
- Streamlit Apps - Application overview
- View Qdrant Database - Inspect indexed documents
- Delete Documents - Remove documents from index
- Test Connection - Verify setup
- System Architecture - Overall design
- Project Structure - File organization
- Testing Guide - Run tests
- Troubleshooting Guide - Common issues
- Qdrant Quick Start - Qdrant setup help
- Connection Troubleshooting - Connection issues
# Start the enhanced app
streamlit run apps/streamlit_upload_app_enhanced.py
# In the UI:
# 1. Configure chunking strategy (sidebar)
# 2. Upload multiple PDFs
# 3. Click "Select All"
# 4. Click "Process Selected"
# 5. Wait for batch processing to complete# Use the search tab in any app
# Enter query: "What is machine learning?"
# View results with full context
# Adjust score threshold for precision/recall# Option A: Use PDF Manager App
streamlit run apps/pdf_manager_app.py
# Option B: Use Python utility
python view_qdrant.py
# Option C: Use Qdrant Dashboard
# Open: http://localhost:6333/dashboard# Interactive deletion
python delete_documents.py
# Command-line deletion
python delete_documents.py --collection documents --document-name "file.pdf"
# Delete entire collection (careful!)
python delete_documents.py --collection documents --delete-collection| Strategy | Use Case | Context Aware | LLM Required |
|---|---|---|---|
| Semantic | General purpose, good quality | β | β |
| Context | When surrounding text matters | ββ | β |
| Late | Best retrieval accuracy | βββ | β |
| Markup | Structured documents (headings) | β | β |
| Token | Simple, fast chunking | β | β |
| Semantic + Late | High-quality hybrid | βββ | β |
| Markup + Context | Structured with context | ββ | β |
Recommendation: Start with Semantic for general use, upgrade to Semantic + Late for best quality.
- 5 Streamlit Applications (Enhanced, PDF Manager, PubMed, Upload, Legacy)
- 8 Chunking Strategies (5 base + 3 hybrid)
- 4 Document Cleaning Methods
- 3 Search Applications
- 20+ Utility Scripts
- Full Test Coverage (pytest-based)
- Python 3.8+ - Programming language
- Streamlit - Web UI framework
- Qdrant - Vector database
- Sentence Transformers - Embedding models
- Docker - Containerization
- PyPDF2 / pdfplumber - PDF extraction
- docling - Document parsing
- chonkie - Advanced chunking
- rich - Terminal UI
- plotly - Visualizations
- pytest - Testing
document_search_pdf/
βββ apps/ # Streamlit applications
β βββ streamlit_upload_app_enhanced.py # β¨ Enhanced app (recommended)
β βββ pdf_manager_app.py # Document management
β βββ streamlit_pubmed_app.py # PubMed search
β βββ streamlit_upload_app.py # Legacy upload app
βββ src/ # Core source code
β βββ processing/ # Document processing
β β βββ advanced_chunking.py # Chunking strategies
β β βββ hybrid_chunking.py # Hybrid strategies
β β βββ document_cleaner.py # Document cleaning
β β βββ document_processor.py # Main processor
β β βββ pdf_processor.py # PDF extraction
β βββ retrieval/ # Search & retrieval
β β βββ base_rag.py # Base RAG system
β β βββ enhanced_rag.py # Enhanced with reranking
β βββ storage/ # Vector storage
β βββ vector_store.py # Qdrant interface
βββ scripts/ # Utility scripts
β βββ index_pdfs.py # Batch indexing
β βββ test_qdrant_connection.py # Connection test
β βββ runners/ # Shell scripts
βββ docs/ # Documentation
β βββ getting-started/ # Getting started guides
β βββ user-guide/ # User guides
β βββ architecture/ # System architecture
β βββ troubleshooting/ # Troubleshooting
βββ tests/ # Test suite
βββ config.yaml # Main configuration
βββ docker-compose.yml # Docker setup
βββ view_qdrant.py # View database utility
βββ delete_documents.py # Delete utility
βββ README.md # This file
Edit config.yaml to customize:
processing:
# Chunking strategy
chunking:
strategy: semantic # semantic, token, markup, context, late
chunk_size: 512
chunk_overlap: 50
# Document cleaning
cleaning:
enabled: true
remove_toc: true
remove_acknowledgements: true
remove_references: false
qdrant:
host: localhost
port: 6333
collection_name: documents
embeddings:
model_name: "sentence-transformers/all-MiniLM-L6-v2"
batch_size: 32# Run all tests
uv run pytest tests/
# Run specific test file
uv run pytest tests/test_document_search.py
# Run with coverage
uv run pytest tests/ --cov=src --cov-report=html
# Use test script
./scripts/runners/run_tests.sh- Python 3.8+
- 4GB RAM
- Docker (for Qdrant)
- Python 3.10+
- 8GB+ RAM
- SSD storage
- GPU (optional, for faster embeddings)
# Check if Qdrant is running
curl http://localhost:6333/collections
# Start Qdrant
docker-compose up -d qdrant
# Check logs
docker-compose logs qdrant# Reinstall dependencies
uv sync
# Or with pip
pip install -r requirements.txt --force-reinstallIssue: Search results showing only 5-10 words
Solution: Re-index documents after updating to latest version (context now stored properly)
# Delete old collection
python delete_documents.py --collection documents --delete-collection
# Re-upload documents using enhanced app
streamlit run apps/streamlit_upload_app_enhanced.py- Process fewer files at once (5-10 instead of 50+)
- Close other applications
- Increase Docker memory limit
More help: See Troubleshooting Guide
view_qdrant.py- View indexed documentsdelete_documents.py- Delete documents interactivelyscripts/index_pdfs.py- Batch index PDFs from folderscripts/test_qdrant_connection.py- Test Qdrant setup
examples/chunking_strategies_demo.py- Chunking examplesexamples/hybrid_chunking_example.py- Hybrid chunkingexamples/document_cleaning_example.py- Cleaning examples
config.yaml- Main configurationconfig/pdf_config.yaml- PDF-specific configdocker-compose.yml- Docker setuppyproject.toml- Python project config
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - See LICENSE file for details.
- Qdrant: https://qdrant.tech/
- Streamlit: https://streamlit.io/
- Sentence Transformers: https://www.sbert.net/
- UV Package Manager: https://github.com/astral-sh/uv
- Check the Documentation
- Review Troubleshooting Guide
- Run diagnostic:
python scripts/test_qdrant_connection.py - Open an issue on GitHub
π‘ Tip 1: Use the Enhanced Upload App for the best experience with all latest features
π‘ Tip 2: Start with Semantic chunking, then experiment with Context or Late chunking
π‘ Tip 3: Enable document cleaning to remove TOC and acknowledgements for cleaner search results
π‘ Tip 4: Use batch upload with "Select All" to process entire document collections quickly
π‘ Tip 5: Check Qdrant dashboard (http://localhost:6333/dashboard) to monitor your index
Happy Document Searching! π