MCPcopy Create free account
hub / github.com/MarchLiu/hypatia

github.com/MarchLiu/hypatia @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
470 symbols 1,248 edges 40 files ⚖ MIT 106 documented · 23% ● updated 16d agov4.2.2 · 2026-10-31★ 2382 open issues

Browse by type

⨍ Functions 397◇ Types & classes 73
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Hypatia

"We can wander through the stacks of the Library of Alexandria, imagining the scrolls and the knowledge they contain. Its destruction is a warning: all we have is transient."——Alberto Manguel

AI-oriented memory management system. Stores structured knowledge as a graph of Knowledge entries (nodes) and Statement triples (edges), queried via a custom JSON Search Expression (JSE) language. Uses SQLite + FTS5 + usearch by default, with an optional complete PostgreSQL + pgvector backend and configurable embedding models (local ONNX or remote API). See PostgreSQL configuration and migration.

Features

  • Knowledge Graph -- Knowledge entries (named info points with tags) and Statement triples (subject-predicate-object with temporal ranges)
  • JSE Query Engine -- JSON-based query language compiling to parameterized SQL + FTS5, supporting $and, $or, $not, $eq, $ne, $gt, $lt, $contains, $like, $content, $search, $quote, $triple, $k-hop
  • Configurable Storage -- SQLite + FTS5 + usearch, or PostgreSQL + JSONB + full-text search + pgvector, selected per shelf
  • Configurable Vector Search -- Local ONNX models (BGE-M3 default) or remote API (OpenAI-compatible) for semantic similarity search using cosine distance
  • Synonyms -- Per-entry synonym lists for knowledge, per-position (subject/predicate/object) synonyms for statements, indexed in FTS
  • Shelf System -- Named, connectable, exportable data directories for isolation
  • CLI + REPL -- Full command-line interface with interactive mode (rustyline)
  • Agent Integration -- Bundled agent skills for Claude Code, Codex and OpenCode, installed with hypatia skill install (see Agent Skills)
  • Cross-Platform -- Prebuilt binaries on GitHub Releases with a one-line install script; scripts/build.sh cross-compiles other targets

Quick Start

Hypatia works with zero downloads and zero configuration: full-text search, graph traversal and JSE queries are available as soon as the binary is installed. Semantic search is optional and can be enabled later.

1. Install

On macOS (Apple Silicon) or Linux (x86_64 with AVX2, or aarch64; glibc 2.35 or newer and OpenSSL 3), install the prebuilt binary into ~/.local/bin:

curl -fsSL https://raw.githubusercontent.com/MarchLiu/hypatia/main/scripts/install.sh | sh

It verifies the download when the release publishes a checksum (releases from now on do), and checks that the binary runs before replacing an installed one. HYPATIA_VERSION picks a release tag and HYPATIA_INSTALL_DIR another directory. Windows x64 binaries are on GitHub Releases.

Or build from source (Intel Macs, musl-based Linux and x86_64 CPUs without AVX2 have no prebuilt ONNX Runtime either; build it yourself and point ORT_LIB_PATH at it, see ort's linking guide):

cargo build --release

2. Store and query knowledge

hypatia init sets up the default shelf at ~/.hypatia/default and shows what works on it (any other command creates that shelf too; hypatia init <dir> -n <name> sets up another one).

hypatia init

# Create knowledge
hypatia knowledge-create "Rust" -d "systems programming language" -t "language,compiled"

# Create a relationship
hypatia statement-create "Rust" "is_a" "systems language"

# Full-text search
hypatia search "programming language"

# Structured query (JSE)
hypatia query '["$knowledge", ["$eq", "name", "Rust"]]'
hypatia query '["$statement", ["$triple", "Rust", "$*", "$*"]]'
hypatia query '["$knowledge", ["$search", "database migration"]]'

# Interactive REPL
hypatia repl

3. Optional: enable semantic search

similar needs an embedding model. Either configure a remote OpenAI-compatible API, or install BGE-M3 (about 2.3 GB) for the default shelf:

hypatia model install BAAI/bge-m3        # resumes if interrupted; -s <shelf> for another shelf
hypatia backfill                         # optional: embed everything written so far, at once
hypatia similar "programming language"   # semantic search

Nothing written before enabling semantic search is lost: existing entries get their vectors automatically, newest first, a batch at a time as you keep using hypatia. backfill embeds them all at once.

Embedding Models

Hypatia supports multiple embedding backends, configured via shelf.toml in the shelf directory (e.g., ~/.hypatia/default/shelf.toml).

Default: BAAI/bge-m3 (Local ONNX)

hypatia model install BAAI/bge-m3 downloads the ONNX export into ~/.hypatia/models/BAAI/bge-m3/ (large files verified against the Hub's sha256) and names it in the shelf's shelf.toml (-s <shelf>, default default). Running it again fetches only files that changed upstream; if any did, re-embed the shelves that already use the model (hypatia backfill --reembed). A shelf that already holds vectors of another model, or uses a remote API, is left unchanged, with instructions to switch. Set HF_ENDPOINT to use a mirror, and HF_TOKEN for gated repositories.

Model files placed directly in the shelf directory are picked up without any configuration too:

hf download BAAI/bge-m3 --local-dir /tmp/bge-m3
cp /tmp/bge-m3/onnx/model.onnx ~/.hypatia/default/embedding_model.onnx
cp /tmp/bge-m3/onnx/model.onnx_data ~/.hypatia/default/model.onnx_data
cp /tmp/bge-m3/onnx/tokenizer.json ~/.hypatia/default/tokenizer.json
  • Dimensions: 1024
  • Max sequence length: 8192
  • Multilingual (100+ languages including Chinese and English)

Switching to Other Local Models

Create or edit ~/.hypatia/default/shelf.toml:

[embedding]
provider = "local"
dimensions = 1536
max_seq_length = 8192

Alibaba-NLP/gte-Qwen2-1.5B-instruct

hf download Alibaba-NLP/gte-Qwen2-1.5B-instruct --local-dir /tmp/gte-qwen2
# Export ONNX first (requires optimum-cli or transformers)
# Then place files in shelf directory
  • Dimensions: 1536
  • Max sequence length: 8192
  • Strong multilingual performance

google/embedding-gemma-300M (EmbeddingGemma)

hf download google/embedding-gemma-300M --local-dir /tmp/embedding-gemma
# Export ONNX and place files
  • Dimensions: 768
  • Max sequence length: 8192
  • Lightweight, fast inference

jinaai/jina-embeddings-v5-text-small

hypatia model install jinaai/jina-embeddings-v5-text-small-text-matching

shelf.toml:

[embedding]
provider = "local"
dimensions = 1024
max_seq_length = 32768
pooling = "last_token"
  • Dimensions: 1024
  • Max sequence length: 32768
  • 677M params, last-token pooling

jinaai/jina-embeddings-v5-text-nano

hypatia model install jinaai/jina-embeddings-v5-text-nano-text-matching

shelf.toml:

[embedding]
provider = "local"
dimensions = 768
max_seq_length = 8192
pooling = "last_token"
  • Dimensions: 768
  • Max sequence length: 8192
  • 239M params, last-token pooling, fastest inference

Remote API (OpenAI-Compatible)

For cloud-based embeddings without local model files:

[embedding]
provider = "remote"
api_url = "https://api.openai.com/v1/embeddings"
api_key_env = "OPENAI_API_KEY"
api_model = "text-embedding-3-small"
dimensions = 1536

Works with any OpenAI-compatible API: - OpenAI (text-embedding-3-small, text-embedding-3-large) - Azure OpenAI - Local servers (Ollama, LM Studio, vLLM) - Other providers (Voyage AI, Cohere, Jina, Gitee AI)

Ollama Example

[embedding]
provider = "remote"
api_url = "http://localhost:11434/v1/embeddings"
api_key_env = "OLLAMA_API_KEY"
api_model = "qwen3-embedding:8b"
dimensions = 1024
# Set a dummy key (Ollama doesn't require auth)
export OLLAMA_API_KEY="ollama"

Set the API key as an environment variable:

export OPENAI_API_KEY="sk-..."

Storage Backend

By default Hypatia uses SQLite + FTS5 + usearch. To use PostgreSQL + pgvector instead, build with --features postgres-backend and add [storage] to shelf.toml:

[storage]
backend = "pgvector"

[storage.postgres]
url_env = "HYPATIA_POSTGRES_URL"
schema = "hypatia_team_memory"

[storage.vector]
index = "hnsw"
metric = "cosine"

See docs/pgvector-backend.md for details on migration, TLS, HNSW dimension limits, and shared archives.

Embedding Configuration Reference

Field Default Description
provider "local" "local" for ONNX, "remote" for HTTP API
dimensions 1024 Embedding vector dimensions
max_seq_length 8192 Max tokenizer sequence length (local only)
pooling "mean" Pooling strategy: "mean", "cls", or "last_token" (local only)
model_path embedding_model.onnx ONNX model path, relative to shelf dir (local only)
tokenizer_path tokenizer.json Tokenizer path, relative to shelf dir (local only)
api_url OpenAI URL API endpoint URL (remote only)
api_key_env OPENAI_API_KEY Environment variable name for API key (remote only)
api_model text-embedding-3-small Model name sent to API (remote only)
skip_tags [] Tags whose entries stay out of the vector index. A session-log layer written under, say, ["message", "session"] is stored and full-text searchable as always, but costs no embedding and never crowds out the knowledge distilled from it. Each entry carries the answer it was written with, so a change here applies to entries written after it; hypatia backfill settles the ones already stored, dropping the vectors the new rule forbids and embedding the entries it now allows. An entry can ask for less indexing than its shelf (--no-embed), never more. Statements carry no tags, so skip_tags reaches knowledge entries only; a statement opts out per write
defer true Embed writes later, in batches. A local model embeds a batch of the newest entries before each semantic search. A remote API embeds once 128 entries are waiting, or when a command runs on the shelf a minute after the oldest was written: usually one request, and never more than 30 s, even when entries the server rejects have to be singled out. false embeds every write as it is saved; with a remote API the write then waits on the network

shelf.toml is parsed strictly, so a binary older than a field refuses to open the shelf rather than ignoring it. Write skip_tags and defer only when you want them, and upgrade every binary that shares the shelf first.

CLI Reference

Command Description
hypatia init [<path>] [-n <name>] Set up a shelf (the default one, or the directory given) and show what works on it
hypatia connect <path> [-n <name>] Connect to a shelf directory; a directory is connected under one name only
hypatia disconnect <name> Disconnect from a shelf; also removes a registered shelf that failed to open
hypatia list List connected shelves
hypatia knowledge-create <name> [-d <data>] [-t <tags>] [--synonyms <csv>] [--figures <refs>] [--no-embed] Create a knowledge entry; --no-embed keeps it out of the vector index
hypatia knowledge-get <name> Get a knowledge entry
hypatia knowledge-update <name> [-d <data>] [-t <tags>] [--synonyms <csv>] [--figures <refs>] [--scopes <scopes>] [--no-embed\|--embed] Update a knowledge entry; omitted fields are kept, an empty value clears one
hypatia knowledge-delete <name> Delete a knowledge entry
hypatia statement-create <subj> <pred> <obj> [-d <data>] [--synonyms <json>] [--no-embed] Create a triple; exits 0 without changes if it already exists
hypatia statement-delete <subj> <pred> <obj> Delete a triple
hypatia search <query> [-c <catalog>] [--limit N] Full-text search
hypatia similar <query> [--limit N] [--tags <csv>] [--exclude-tags <csv>] [--where <jse>] Vector similarity search; the filters narrow the entries before they are ranked
hypatia backfill [--reembed] [-s <shelf>] Generate embeddings for entries missing vectors (or regenerate all)
hypatia backfill --status [-s <shelf>] Report pending entries and why embedding may be stuck, as JSON
hypatia model install <org/name> [-s <shelf>] [--revision <rev>] Download an ONNX embedding model from Hugging Face and use it on a shelf
hypatia model list / model show <name> / model register <name> <path> List, inspect or register local models
`hypatia import

[-s ] [--reembed]| Import an exported snapshot into an empty shelf | |hypatia archive-store [-n ] [-s ]| Store a file in archives with auto-metadata | |hypatia archive-get [-o ] [-s ]| Get an archive file path or copy it | |hypatia archive-list [-s ]| List all archive files | |hypatia scope list [--count|--json] [-s ]| List the scopes in use;--countadds how many entries carry each,--jsonemits exact values | |hypatia scope exists [-s ]| Exit 0 if the scope is in use, 1 if not;""is the global scope | |hypatia tag list [--count|--json] [-s ]| List the tags in use;--countadds how many entries carry each,--jsonemits exact values | |hypatia tag exists [-s ]| Exit 0 if the tag is in use, 1 if not | |hypatia query ''| Execute a JSE query | |hypatia export | Export a shelf | |hypatia skill install --agent [--dir

] [--skill ] [--force]| Install the bundled agent skills (hosts:claude,codex,opencode) | |hypatia skill status --agent [--dir ]| Show whether installed skills match the bundled ones | |hypatia mcp` | Serve the knowledge graph to an agent over MCP

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 233
Method 164
Class 57
Enum 13
Interface 3

Languages

Rust96%
Python4%

Modules by API surface

src/storage/duckdb_store.rs48 symbols
src/embedding/config.rs41 symbols
src/engine/evaluator.rs36 symbols
src/storage/shelf_manager.rs31 symbols
src/model/content.rs27 symbols
tests/bench_data.rs24 symbols
src/lab.rs22 symbols
src/storage/sqlite_store.rs21 symbols
src/embedding/provider.rs21 symbols
tests/longmemeval.rs18 symbols
src/engine/operators.rs18 symbols
src/storage/shelf_registry.rs16 symbols

For agents

$ claude mcp add hypatia \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page