Skip to main content

Verified AI memory — retrieval that doesn't hallucinate.

Project description

Mnemonics

Your memory doesn't hallucinate.

Mnemonics is a local-first AI memory layer that stores, retrieves, and verifies what it returns. Built on sentence embeddings + HNSW vector search, with optional halluguard verification to flag results that drift from the indexed corpus.

Why

Every RAG pipeline has the same silent failure mode: the retriever returns plausible-looking chunks, the LLM fills in the gaps, and nobody notices the fabrication until it matters. Mnemonics surfaces that problem at retrieval time, not after.

Install

pip install mnemonics
# with verification support:
pip install "mnemonics[verify]"

Quick start

# Store something
mnemonics ingest "The Eiffel Tower is 330 meters tall and located in Paris."

# Retrieve with hallucination check
mnemonics retrieve "how tall is the Eiffel Tower"
# trust_score: 1.0  flagged: 0
#   [0.912] The Eiffel Tower is 330 meters tall and located in Paris.

Python API

from mnemonics.store import Store
from mnemonics.ingest import ingest
from mnemonics.retrieve import retrieve

store = Store("~/.mnemonics")

ingest(["Paris is the capital of France.", "Rome is the capital of Italy."], store)

result = retrieve("what is the capital of France", store, top_k=3, verify=True)
for r in result["results"]:
    flag = " FLAGGED" if r["flagged"] else ""
    print(f"[{r['score']:.3f}]{flag} {r['text']}")

print(f"trust_score: {result['trust_score']}")

REST server

mnemonics serve --port 7810
Method Path Body
POST /ingest {"texts": [...], "ns": "default"}
POST /retrieve {"query": "...", "top_k": 5, "verify": true}
GET /health
GET /namespaces
GET /count?ns=default
DELETE /memory/<id>

MCP (Claude Code / Cursor / Metis)

mnemonics mcp

Add to your MCP config:

{
  "mcpServers": {
    "mnemonics": {
      "command": "mnemonics",
      "args": ["mcp"]
    }
  }
}

Tools exposed: mnemonics_ingest, mnemonics_retrieve, mnemonics_forget

Namespaces

Isolate memories by project, user, or any key:

mnemonics ingest "project notes..." --ns work
mnemonics retrieve "deadlines" --ns work

Architecture

texts -> chunk (200w / 40w overlap) -> embed (all-MiniLM-L6-v2)
      -> hnswlib cosine index (per namespace)
      -> SQLite metadata store

retrieve -> embed query -> knn search -> halluguard verify -> ranked results

Storage layout under ~/.mnemonics:

memories.db        SQLite (text, meta, timestamps)
index_default.bin  hnswlib index for "default" namespace
index_<ns>.bin     one index per namespace

Verification

When verify=True, retrieved chunks are sent to a local halluguard daemon (port 7801) which cross-checks each result against the full retrieved corpus. Results that diverge get flagged and the aggregate trust_score drops.

pip install "mnemonics[verify]"
halluguard serve &
mnemonics retrieve "your query"  # auto-verifies

Verification is best-effort: if the daemon is not running, retrieval proceeds normally with trust_score: 1.0.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mnemonics-0.1.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mnemonics-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file mnemonics-0.1.0.tar.gz.

File metadata

  • Download URL: mnemonics-0.1.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for mnemonics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c9a4a6215e956d465b180eb1f18761269a5f099c5d11dd98df25923118ca4957
MD5 478009757aac05f0e7584233182dbb06
BLAKE2b-256 6b99c11588eafdab96785906c7d0cedfbc78dc7bcfc2d96c1896f4e09137ede4

See more details on using hashes here.

File details

Details for the file mnemonics-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mnemonics-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for mnemonics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af2f5a7b8390b889ed8d609ae7af3c005db5d1608b94c007c8966821d0e8e254
MD5 81cc13a35a58e732ffad379608737810
BLAKE2b-256 6f4c8c34eeebfdec18142b2da6576a1917f92d6af5a206184949baac6fd8d7fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page