A high-performance, multilingual RAG (Retrieval-Augmented Generation) system designed to ingest, deduplicate, and search through 10,000+ engineering research papers. Built with Python, Dagster, Milvus, and BGE-M3.
📖 Read the Technical Reference Manual for a deep dive into the algorithms (Sanitizer, MMR, Hashing) and helper scripts.
- Exact Deduplication: Uses SHA-256 Hashing to instantly skip duplicate files (even if renamed).
- Efficient Storage: Vector storage in Milvus (Dockerized) for billion-scale retrieval.
- Incremental Ingestion: Tracks processed files in DuckDB to allow pausing/resuming updates.
- Multilingual Support: Fixed common PDF extraction artifacts (
s ´eri ie->série). - Structure Aware: Semantic chunking that respects paragraph boundaries and merges floating accents (LaTeX repair).
- Semantic Diversity: Implements Maximal Marginal Relevance (MMR) to avoid redundant results (e.g., getting 5 identical definitions from different papers).
- SOTA Embeddings: Uses
BAAI/bge-m3for state-of-the-art multilingual performance.
- Orchestration: Dagster
- Vector DB: Milvus
- Embedding: Sentence Transformers (BGE-M3)
- API: FastAPI
- Metadata: DuckDB
- Docker Desktop (Running)
- Python 3.10+
# Create venv
python -m venv venv
.\venv\Scripts\activate
# Install dependencies (ensure you have torch, pymilvus, dagster, etc.)
pip install -r requirements.txtDownload real engineering papers from ArXiv:
# Download 100 papers
.\venv\Scripts\python.exe download_data.py 100Starts the Docker infrastructure and runs the Dagster pipeline.
.\start_dagster.ps1Go to http://localhost:3000 -> "ingest_knowledge_base" -> "Materialize All"
Start the API server:
.\start_api.ps1Test a query:
.\venv\Scripts\python.exe test_quality.py.
├── data/
│ ├── raw_pdfs/ # PDF Storage (Gitignored)
│ └── metadata_store.duckdb
├── src/
│ ├── ingestion/
│ │ ├── assets.py # Core logic: Deduplication, Hashing, Chunking
│ │ └── cleaning.py # Advanced Text Sanitizer (French/LaTeX fixes)
│ ├── orchestration/ # Dagster Repo
│ └── api_server.py # FastAPI with MMR Re-ranking
├── start_dagster.ps1 # Infrastructure Launcher
├── start_api.ps1 # API Launcher
├── download_data.py # ArXiv Scraper
└── test_quality.py # Verification Script
This API is designed to be a Tool for LLMs (OpenAI, Anthropic, LangChain).
If you are building a simple RAG chatbot, use as_context_string=True. The API will format the results for you.
import requests
response = requests.post("http://localhost:8000/search", json={
"query": "What is Fuzz testing?",
"top_k": 3,
"as_context_string": True
})
context = response.json()["context"]
# Returns:
# SOURCE [1] (paper.pdf): Fuzz testing is...
# SOURCE [2] (other.pdf): ...To give this tool to ChatGPT/OpenAI Agents, use this function definition:
{
"name": "search_knowledge_base",
"description": "Searches the engineering knowledge base for technical definitions, theorems, and research papers.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The scientific or engineering concept to search for."
},
"as_context_string": {
"type": "boolean",
"description": "Set to true to get a formatted context block."
}
},
"required": ["query"]
}
}