Field Manual RAG By Scratch System for Constraints-Based Hardware
A lightweight, offline Retrieval-Augmented Generation system designed for aviation maintenance manuals. Optimized for No GPU/Legacy/Embedded hardware.
⚠️ DISCLAIMER: All sample manuals included in this project are Distribution Statement A: Approved for public release; distribution is unlimited. Ensure compliance with applicable regulations when adding additional technical documentation.
.\setup.bat# KoboldCPP No-AVX build (~410 MB)
curl -L -o "server.exe" "https://github.com/LostRuins/koboldcpp/releases/download/v1.107/koboldcpp-oldpc.exe"
# Qwen 2.5 0.5B Q4_K_M (~463 MB) - OR use any model of your choice
curl -L -o "qwen2.5-0.5b-instruct-q4_k_m.gguf" "https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF/resolve/main/qwen2.5-0.5b-instruct-q4_k_m.gguf"# 1. Install requirements
pip install -r requirements.txt
# 2. Injest PDFs
python src/ingest.py
# 3. Start LLM server (separate terminal) [Set threads accordingly to the CPU]
.\server.exe --model qwen2.5-0.5b-instruct-q4_k_m.gguf --port 5001 --threads 4
# 4. Launch CLI chat (in separate terminal)
python src/main.pyflowchart LR
subgraph Ingestion
A["PDFs<br/>(Manuals)"] --> B["ingest.py<br/>(PyMuPDF)"]
B --> C["JSON KB<br/>(3.5 MB)"]
end
subgraph Retrieval
D["User Query"] --> E["Keyword Search<br/>(No Embeddings)"]
C --> E
E --> F["Top-K Chunks"]
end
subgraph Generation
F --> G["Build Prompt<br/>(ChatML)"]
G --> H["KoboldCPP<br/>(Qwen 0.5B)"]
H --> I["Response"]
end
| Platform | Type | Chunks | Source Documents |
|---|---|---|---|
| RC-12 | Reconnaissance Plane | 1,327 | 6 manuals |
| AH-1 | Attack Helicopter | 505 | 2 manuals |
| C-12 | Utility Plane | 342 | 2 manuals |
| UH-1 | Utility Helicopter | 184 | 1 manual |
| RD-12 | Reconnaissance Plane | 164 | 1 manual |
| OH-58 | Observation Helicopter | 122 | 1 manual |
| Total | 2,644 | 12 PDFs |
- Drop PDF files into the
Manuals/folder - (Optional) Add platform pattern to
ingest.pyif needed:PLATFORM_PATTERNS = { # ... existing patterns ... "NEW-PLATFORM": re.compile(r"pattern", re.IGNORECASE), }
- Re-run:
python ingest.py
MANTIS/
├── src/
│ ├── ingest.py # PDF → JSON indexer
│ └── main.py # CLI RAG interface
├── data/
│ └── knowledge_base.json # Indexed chunks (generated)
├── Manuals/ # Source PDFs
├── server.exe # KoboldCPP (No-AVX)
├── *.gguf # Quantized LLM
└── setup.bat # Auto-downloader
- Python 3.8+ (3.6+ may work)
pymupdf— PDF text extractionrequests— Offline API calls to KoboldCPP
- Make sure
server.exeis running in a separate terminal - Check that port is not blocked by firewall
- Run
/statuscommand to verify connection
- Run
python ingest.pyfirst to build the index - Ensure
Manuals/folder contains PDF files
- Reduce
max_lengthinmain.pyfor faster responses - Close other applications to free RAM
- Add new patterns to
PLATFORM_PATTERNSiningest.py - Re-run
python ingest.pyto rebuild the index
MIT