explaingit

masatoagi/ncd-memory

Analysis updated 2026-05-18

0RustAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

A Rust library that gives AI agents persistent, searchable memory using compression-based text similarity instead of an embedding model.

Mindmap

mindmap
  root((ncd-memory))
    What it does
      Stores agent memory
      Compression-based search
      No embedding model
    Tech stack
      Rust
      SQLite
      Lean 4
    Use cases
      AI agent memory
      Semantic search
    Audience
      AI developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add persistent memory to an AI agent without running a separate embedding model

USE CASE 2

Search past conversation history using compression-based semantic similarity

USE CASE 3

Inject user profile preferences and track separate sessions in agent prompts

What is it built with?

RustSQLiteLean 4

How does it compare?

masatoagi/ncd-memory404-agent/codes-minerbakome-hub/bakome-crypto-quant-engine
Stars000
LanguageRustRustRust
Setup difficultymoderatemoderateeasy
Complexity3/53/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Core logic is formally verified against a Lean 4 specification, with documented gaps.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

ncd-memory is a Rust library that gives AI agents a persistent external memory store, a way to remember and search through past conversations or notes, without needing a separate AI embedding model to do it. Most memory systems for AI agents rely on embedding models: neural networks that convert text into numeric vectors so that similar sentences end up near each other in a mathematical space. ncd-memory takes a different approach. It uses GZIP compression to measure how similar two pieces of text are. The idea comes from information theory: if two texts compress together much more efficiently than separately, they share structure and are probably semantically related. This measure is called Normalised Compression Distance (NCD), and it works with standard compression software, no trained model required. In practice, a developer adds ncd-memory as a dependency, opens a memory database, logs conversation turns, and calls a retrieve function with a query string to get back the most relevant past entries. The retrieval works in two stages: first a fast keyword search, then a GZIP-based semantic search for anything the keyword pass might miss. The library also supports user profile preferences that can be injected into prompts, and session tracking so memories from different conversations stay organised. An unusual feature is that the library's core logic is formally specified in Lean 4, a proof-assistant language used in mathematics research. Parts of the Rust implementation are verified to match the abstract specification, with the gaps documented openly. Built in Rust, stored in SQLite, licensed MIT.

Copy-paste prompts

Prompt 1
Help me add ncd-memory as a dependency to give my Rust AI agent persistent memory
Prompt 2
Explain how Normalised Compression Distance is used for semantic search in ncd-memory
Prompt 3
Show me how to log conversation turns and retrieve relevant past entries with ncd-memory

Frequently asked questions

What is ncd-memory?

A Rust library that gives AI agents persistent, searchable memory using compression-based text similarity instead of an embedding model.

What language is ncd-memory written in?

Mainly Rust. The stack also includes Rust, SQLite, Lean 4.

What license does ncd-memory use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is ncd-memory to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is ncd-memory for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.