Grounded Retrieval Over a Controlled Corpus — Fully Offline

Retrieve the most relevant passage for a question from a controlled document corpus by semantic similarity, so an answer is grounded in a citable in-enclave source — local inference, no external AI, no egress.

All recipes· government· 5 minutesbeginnersql
Instance: localhost:8080

Opens your running SynapCores (Grounded Retrieval Over a Controlled Corpus — Fully Offline will be staged for a preview — nothing runs until you click Run). No instance yet? Install free in ~30s.

Share

Objective

Grounded retrieval — find the passage a question is actually about — is the foundation of a trustworthy answer. In a sovereign or air-gapped deployment it must run with local inference and no egress. This recipe does exactly that: semantic retrieval over a controlled corpus, entirely inside the boundary.

Step 1: A controlled corpus with embeddings

DROP TABLE IF EXISTS enclave_docs;

CREATE TABLE enclave_docs (
    doc_id  TEXT PRIMARY KEY,
    title   TEXT,
    passage TEXT,
    emb     VECTOR(384)
);

INSERT INTO enclave_docs VALUES
 ('D-118','Logistics SOP',
  'Resupply convoys stage at the forward node and depart at first light under escort.',
  EMBED('Resupply convoys stage at the forward node and depart at first light under escort.')),
 ('D-204','Comms plan',
  'Primary channel is the encrypted satellite link; fall back to HF on scheduled windows.',
  EMBED('Primary channel is the encrypted satellite link; fall back to HF on scheduled windows.'));

Step 2: Retrieve the passage that grounds a question

SELECT doc_id,
       title,
       COSINE_SIMILARITY(
         emb,
         EMBED('What is the fallback communications method if the satellite link fails?')
       ) AS sim
FROM   enclave_docs
ORDER  BY sim DESC
LIMIT  1;

Result — the comms question retrieves the comms plan as its grounding source:

doc_id title sim
D-204 Comms plan 0.41

Why it matters

The retrieved passage is the citation that keeps a generated answer honest — and it is produced by local inference with nothing leaving the boundary. Combine it with entity link analysis, and record what the agent produced on a tamper-evident ledger. For the full self-hosted agent backend (memory + RAG + graph + audit), see the coding-agent backend.

Tags

governmentdefensesovereignair-gappedragretrievalvectorembeddingsgroundingofflineself-hosted

Run this on your own machine

Install SynapCores Community Edition free, paste the SQL or Cypher above into the bundled web UI, and watch it run.

Download Free CE