Skip to content

About

Ontology-enhanced RAG for military benefits navigation | SCSP Hackathon 2026

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

RAG-Tag Force πŸͺ–

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

RAG-Tag Force UI


Why Ontology-Enhanced RAG?

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.


What the Demo Shows

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.


Architecture

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   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      β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

System at a Glance

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

Quick Start

Prerequisites

1. Clone & Install

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

2. Configure Environment

cp .env.example .env

Edit .env and add your Anthropic API key:

ANTHROPIC_API_KEY=sk-ant-your-key-here

3. Ingest Data

# 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.py

All scripts are idempotent β€” safe to run multiple times.

4. Run

# 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 dev

Open http://localhost:3000 and try the example questions.

One-Command Setup

python scripts/setup.py  # Installs deps, ingests data, validates

The Three Domains

πŸŽ–οΈ Benefits & Entitlements

What 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:

  1. What BAH am I entitled to as a single E-4 at Fort Campbell?
  2. How many days of leave can I accrue per year as an O-3?
  3. What is my BAS rate as an enlisted Soldier?
  4. What housing allowance changes when I add a dependent?
  5. What regulation governs my entitlement to OHA overseas?

✈️ TDY Travel Planner

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:

  1. What is the per diem rate for TDY to Fort Liberty?
  2. How much lodging allowance do I get for TDY in Colorado Springs?
  3. What are the meal rates for travel to the Pentagon?
  4. Can I get reimbursed for a rental car on TDY to Fort Huachuca?
  5. What is the per diem for TDY to Joint Base Lewis-McChord?

πŸ“Š Federal Contract Intelligence

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:

  1. Find contracts for autonomous systems at Aberdeen Proving Ground
  2. What are the largest defense AI contracts?
  3. Find hypersonics research contracts in Alabama
  4. Show me logistics and supply chain contracts at Fort Liberty
  5. Who are the top contractors for cybersecurity?

Project Structure

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

Tech Stack

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)

Testing

python -m pytest tests/ -v

Tests cover ontology loading, entity extraction, query expansion, vector search, structured data lookups, and API response models.


Datasets & Sources

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

Team

RAG-Tag Force Β· SCSP Hackathon 2026 Β· GenAI.mil Track

About

Ontology-enhanced RAG for military benefits navigation | SCSP Hackathon 2026

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages