Skip to content

SynapCores / Recipe

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

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

Install free with one command, then open Grounded Retrieval Over a Controlled Corpus — Fully Offline in your instance. It's staged for a preview — nothing runs until you click Run. New to SynapCores? The quickstart covers install to first query.

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 data 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 grounded — 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