Ontology-Enhanced RAG for Military Domains β proving that a SKOS knowledge layer dramatically outperforms naive vector search in domain-specific retrieval.
SCSP Hackathon 2026 Β· GenAI.mil Track
Standard RAG pipelines treat every query as a bag of tokens β they have no understanding of domain relationships. This fails in any specialized domain where the same concept has many names and where authoritative structured data exists alongside unstructured documents.
The military domain makes this failure obvious:
| What the user says | What basic RAG searches for | What the ontology knows |
|---|---|---|
| "E-4 at Fort Campbell" | Literal text "E-4" and "Fort Campbell" | E-4 = Specialist = SPC = Corporal = CPL β locality code CLARKSVILLE_TN |
| "per diem in Colorado Springs" | "per diem" near "Colorado Springs" | Colorado Springs β Fort Carson β Peterson SFB β CO_SPRINGS_CO β live GSA API lookup |
| "autonomous systems at Aberdeen" | "autonomous" near "Aberdeen" | Aberdeen = APG = Aberdeen Proving Ground β Maryland β NAICS 541715 (R&D) β USAspending API |
The ontology layer expands queries with synonyms, maps installations to locality codes, links allowances to governing regulations, and triggers structured data lookups β all before the vector store is ever queried. The result: answers with real dollar amounts, real contract data, and precise citations instead of vague summaries.
This pattern is transferable. Replace the military ontology with medical terminology (ICD-10 codes, drug brand/generic names) or legal citations (statute cross-references, jurisdiction mappings) and the same architecture delivers the same improvement. The ontology is the domain adapter.
Every query runs two pipelines side by side:
| Basic RAG | Ontology Enhanced RAG | |
|---|---|---|
| Query | Raw text β vector search | Text β entity extraction β SKOS expansion β enhanced search |
| Data sources | ChromaDB only | ChromaDB + SQLite + live APIs |
| Synonyms | None β misses alternate terms | All aliases from SKOS altLabel |
| Structured data | β | β BAH rates, pay tables, per diem, contract spending |
| Citations | Generic doc references | Regulation numbers, CRS report sections, API sources |
The delta between the two columns is the proof of value.
βββββββββββββββββββ
β User Query β
ββββββββββ¬βββββββββ
β
βββββββββββββββ΄ββββββββββββββ
β β
Basic RAG Path Ontology Enhanced Path
β β
β ββββββββ΄ββββββββ
β β Entity β
β β Extraction β
β ββββββββ¬ββββββββ
β β
β ββββββββ΄ββββββββ
β β SKOS Ontology β
β β Expansion β
β β (RDFLib) β
β ββββββββ¬ββββββββ
β β
β ββββββββββββββΌβββββββββββββ
β β β β
ββββββ΄βββββ βββββββ΄ββββββ βββββ΄βββββ ββββββ΄ββββββ
β ChromaDB β β ChromaDB β β SQLite β β Live APIsβ
β Vector β β Enhanced β β Tables β β GSA/USAs β
β Search β β Search β β β β pending β
ββββββ¬βββββ βββββββ¬ββββββ βββββ¬βββββ ββββββ¬ββββββ
β ββββββββββββββΌββββββββββββ
β β
ββββββ΄βββββ ββββββββ΄ββββββββ
β Claude β β Claude β
β Haiku β β Haiku β
ββββββ¬βββββ ββββββββ¬ββββββββ
β β
ββββββ΄βββββ ββββββββ΄ββββββββ
β Basic β β Enhanced β
β Answer β β Answer β
βββββββββββ ββββββββββββββββ
| Component | Count | Details |
|---|---|---|
| Vector Store | 10,281 chunks | 3 ChromaDB collections (benefits, TDY, contracts) |
| Structured DB | 342 rows | BAH rates, base pay, BAS, per diem tables |
| SKOS Ontology | 1,083 triples | 3 Turtle files covering all 3 domains |
| Live APIs | 2 connections | GSA Per Diem API Β· USAspending.gov API |
| Test Suite | 42 tests | Full coverage with pytest |
| Domains | 3 | Benefits & Entitlements Β· TDY Travel Β· Federal Contracts |
- Python 3.11+
- Node.js 18+ (for the frontend)
- Anthropic API key (Claude Haiku)
git clone https://github.com/Marcus-Lind/ragtag-force.git
cd ragtag-force
# Python dependencies
pip install -r requirements.txt
# Frontend dependencies
cd frontend && npm install && cd ..cp .env.example .envEdit .env and add your Anthropic API key:
ANTHROPIC_API_KEY=sk-ant-your-key-here
# Military benefits (PDFs β 9,857 chunks + SQLite tables)
python scripts/ingest.py
# TDY travel (reference docs β 15 chunks)
python scripts/ingest_tdy.py
# Federal contracts (CRS reports, PDFs, HTML β 409 chunks)
python scripts/ingest_contracts.pyAll scripts are idempotent β safe to run multiple times.
# Start the API server (port 8000)
python -m uvicorn src.api.main:app --port 8000
# In another terminal β start the frontend (port 3000)
cd frontend && npm run devOpen http://localhost:3000 and try the example questions.
python scripts/setup.py # Installs deps, ingests data, validatesWhat it proves: Ontology expansion resolves rank synonyms (E-4 β SPC/Specialist/Corporal) and maps installations to BAH locality codes, then pulls exact dollar amounts from SQLite rate tables.
Data sources:
- 4 DoD regulation PDFs β 9,857 chunks
- SQLite: BAH rates (150 rows), enlisted pay (74), officer pay (90), BAS rates (2)
- SKOS ontology: 389 triples β ranks, allowances, installations, regulations
Example questions:
- What BAH am I entitled to as a single E-4 at Fort Campbell?
- How many days of leave can I accrue per year as an O-3?
- What is my BAS rate as an enlisted Soldier?
- What housing allowance changes when I add a dependent?
- What regulation governs my entitlement to OHA overseas?
What it proves: Ontology maps installation nicknames (e.g., "Bragg" β Fort Liberty β Fayetteville, NC) to locality codes, then queries the live GSA Per Diem API for real-time lodging and meal rates.
Data sources:
- TDY reference documents β 15 chunks
- Live GSA Per Diem API (api.gsa.gov) β real-time rates
- SQLite: per diem rates (26 rows)
- SKOS ontology: 337 triples β installations, locations, travel regulations
Example questions:
- What is the per diem rate for TDY to Fort Liberty?
- How much lodging allowance do I get for TDY in Colorado Springs?
- What are the meal rates for travel to the Pentagon?
- Can I get reimbursed for a rental car on TDY to Fort Huachuca?
- What is the per diem for TDY to Joint Base Lewis-McChord?
What it proves: Ontology resolves domain terms (e.g., "autonomous systems" β NAICS codes, "Aberdeen" β APG β Maryland) and queries the live USAspending.gov API for real federal contract data β dollar amounts, contractors, and agencies.
Data sources:
- 7 CRS congressional reports (PDF + HTML from congress.gov) β 409 chunks
- Live USAspending.gov API β real contract spending data
- SKOS ontology: 357 triples β research domains, installations, contractors, NAICS codes
Example questions:
- Find contracts for autonomous systems at Aberdeen Proving Ground
- What are the largest defense AI contracts?
- Find hypersonics research contracts in Alabama
- Show me logistics and supply chain contracts at Fort Liberty
- Who are the top contractors for cybersecurity?
ragtag-force/
βββ frontend/ # Next.js 16 + shadcn/ui + Tailwind
β βββ src/
β βββ app/page.tsx # Main page β domain tabs, side-by-side answers
β βββ components/ # Sidebar, AnswerCard, QueryInput, PipelineDiagram
β βββ lib/api.ts # API client + TypeScript interfaces
β
βββ src/
β βββ api/main.py # FastAPI backend β all domain endpoints
β βββ config.py # Environment config (paths, keys, model)
β βββ ingest/ # Embeddings + ChromaDB vector store helpers
β βββ llm/ # Anthropic Claude client wrapper
β βββ ontology/ # SKOS expanders (benefits, TDY, contracts)
β βββ retrieval/ # Retrieval pipelines (basic + enhanced per domain)
β
βββ ontology/
β βββ military_entitlements.ttl # 389 triples β ranks, allowances, installations
β βββ tdy_travel.ttl # 337 triples β locations, per diem mappings
β βββ federal_contracts.ttl # 357 triples β domains, contractors, NAICS
β
βββ scripts/
β βββ setup.py # One-command setup (install + ingest + validate)
β βββ ingest.py # Benefits domain ingestion
β βββ ingest_tdy.py # TDY domain ingestion
β βββ ingest_contracts.py # Contracts domain ingestion (MD + PDF + HTML)
β
βββ data/
β βββ chroma/ # ChromaDB persistent storage (3 collections)
β βββ documents/contracts/ # CRS reports (PDF + HTML), reference docs (MD)
β βββ raw/ # Source PDFs for benefits domain
β βββ structured/ # SQLite databases (entitlements.db)
β
βββ tests/ # 42 pytest tests
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
| Layer | Technology |
|---|---|
| LLM | Anthropic Claude Haiku 4 |
| Embeddings | sentence-transformers (bge-base-en-v1.5, 768-dim) |
| Vector Store | ChromaDB (cosine similarity, persistent) |
| Ontology | RDFLib + SKOS (Turtle format) |
| Structured Data | SQLite via sqlite3 |
| PDF Parsing | PyMuPDF (fitz) |
| Live APIs | GSA Per Diem (api.gsa.gov) Β· USAspending (api.usaspending.gov) |
| Backend | FastAPI + Uvicorn |
| Frontend | Next.js 16 Β· shadcn/ui Β· Tailwind CSS v4 |
| Testing | pytest (42 tests) |
python -m pytest tests/ -vTests cover ontology loading, entity extraction, query expansion, vector search, structured data lookups, and API response models.
| Source | What We Use |
|---|---|
| Army Publishing Directorate (armypubs.army.mil) | AR 37-104-4, AR 600-8-10 |
| DoD FMR Vol 7A (comptroller.defense.gov) | BAH, BAS, OHA chapters |
| Defense Travel Management Office (defensetravel.dod.mil) | BAH rate tables |
| DFAS (dfas.mil) | Military pay charts |
| Congressional Research Service (crsreports.congress.gov) | 7 CRS reports on AI, cyber, defense industrial base, hypersonics, autonomous weapons |
| GSA Per Diem API (api.gsa.gov) | Live per diem rates |
| USAspending.gov API | Live federal contract data |
RAG-Tag Force Β· SCSP Hackathon 2026 Β· GenAI.mil Track
