Skip to content
AnwarMOUNIRPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🧠 Scalable Engineering Knowledge Base

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.

🚀 Features

1. Massive Scalability

  • 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.

2. High-Quality Text Extraction

  • 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).

3. Smart Retrieval

  • 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-m3 for state-of-the-art multilingual performance.

🛠️ Tech Stack

⚡ Quick Start

Prerequisites

  • Docker Desktop (Running)
  • Python 3.10+

1. Setup & Install

# Create venv
python -m venv venv
.\venv\Scripts\activate

# Install dependencies (ensure you have torch, pymilvus, dagster, etc.)
pip install -r requirements.txt

2. Get Data

Download real engineering papers from ArXiv:

# Download 100 papers
.\venv\Scripts\python.exe download_data.py 100

3. Ingest Data

Starts the Docker infrastructure and runs the Dagster pipeline.

.\start_dagster.ps1

Go to http://localhost:3000 -> "ingest_knowledge_base" -> "Materialize All"

4. Search

Start the API server:

.\start_api.ps1

Test a query:

.\venv\Scripts\python.exe test_quality.py

📂 Project Structure

.
├── 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

🤖 Using with Agents / LLMs

This API is designed to be a Tool for LLMs (OpenAI, Anthropic, LangChain).

1. Context Construction Mode

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): ...

2. OpenAI Tool Schema

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"]
  }
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages