Home / Docs / SPARQL & Ontology-Augmented RAG

Ontology engineering · Retrieval

SPARQL & Ontology-Augmented RAG (OAG)

Vector search finds similar paragraphs; an ontology traverses verified relationships, enforces units and permissions, and binds every generated claim back to its source record.

When plain vector RAG breaks down

Chunk-only RAG fails on multi-hop questions ("Which assets share a supplier with a failed inspection in the last 90 days?"), numeric comparisons across mismatched units, and permission boundaries where documents must be filtered by role before generation.

Ontology-Augmented Generation (OAG) pairs dense/BM25 document retrieval with deterministic SPARQL 1.1 graph traversal so the LLM receives a structured, provenance-tagged context packet rather than disconnected text fragments.

Example: Provenance-linked SPARQL query

PREFIX ta:   <https://thompsonaxiomata.com/ns/ops#>
PREFIX prov: <http://www.w3.org/ns/prov#>

SELECT ?asset ?workOrder ?signer ?sensorRun
WHERE {
  ?asset a ta:MaintainableAsset ;
         ta:hasWorkOrder ?workOrder ;
         ta:verifiedBy ?inspection .
  ?inspection ta:signer ?signer ;
              ta:sensorRun ?sensorRun ;
              ta:shaclConforms true .
}
ORDER BY ?asset

Four-step grounded retrieval loop

  1. Entity & intent grounding

    Map question terms to canonical ontology IRIs (using SKOS altLabels or portal taggers) before querying.

  2. Hybrid fetch (Graph + Text)

    Execute parameterized SPARQL templates for exact relations alongside filtered hybrid search + reranking over linked source documents.

  3. Structured synthesis

    Generate the answer with explicit inline IRI and passage citations—never ungrounded free-text summaries.

  4. Claim-by-claim verification

    Check each generated claim against its cited source record and fail or flag unsupported assertions before delivery.

Test it yourself: Query a synthetic BFO production graph in the SPARQL Playground ↗, inspect claim-level verification in the Grounding Checker ↗, or read Hybrid RAG & Reranking and Fine-Tuning vs. RAG vs. Knowledge Graphs.