A production-grade Hybrid Retrieval-Augmented Generation system that processes documents using Azure OpenAI embeddings and multiple chunking strategies.
- Python 3.8+
- Docker (for Qdrant)
- Azure OpenAI account with API key
docker-compose up -dThis starts Qdrant on http://localhost:6333 with persistent storage.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtCopy .env.example to .env and fill in your Azure OpenAI credentials:
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_API_VERSION=2024-02-15-preview
AZURE_EMBEDDING_DEPLOYMENT=text-embedding-large
AZURE_EMBEDDING_MODEL=text-embedding-3-large
QDRANT_URL=http://localhost:6333
QDRANT_COLLECTION_NAME=rag-collectionpython scripts/run_rag.py --ingestThis processes documents from the configured input directories (see config/files/rag_config.yaml).
python scripts/run_rag.py --search "your query here"python scripts/run_rag.py --interactiveCommands:
ingest- Ingest documentssearch <query>- Search for a queryclear- Clear the vector storequit- Exit
- Multiple Chunking Strategies: Recursive, semantic, and fixed-size chunking
- Hybrid Search: Combines semantic (vector) and keyword search with reranking
- Reranking: Boosts results based on query term position and site context
- Site Context: Automatically enriches results with navigation links and site metadata
- PDF-to-Markdown Matching: Intelligently links PDF-derived markdown files to source pages
- Qdrant Vector Store: Scalable vector database with full metadata support
Reranking is enabled by default (rerank: true in config). It boosts results based on:
- Position Boost: Query terms appearing at the beginning of content get higher scores
- Site Context Boost: Results with navigation links and site metadata get boosted (+0.15)
- Site Query Boost: Extra boost (+0.25) for queries containing "site" or "this site"
To disable reranking, set rerank: false in config/files/rag_config.yaml.
Edit config/files/rag_config.yaml to customize:
- Chunking: Enable/disable strategies, adjust sizes
- Hybrid Search: Adjust semantic/keyword weights, enable/disable reranking
- Vector Store: Choose Qdrant or in-memory storage
- Data Source: Configure input directories
Qdrant connection issues:
- Ensure Docker is running:
docker ps - Check Qdrant logs:
docker-compose logs qdrant
No documents found:
- Verify paths in
rag_config.yamlpoint to your document directories - Check that the configured directories contain supported file types (.md, .json, .txt, .html)
Embedding errors:
- Verify Azure OpenAI credentials in
.env - Check API endpoint and deployment names match your Azure configuration