Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
aimem-core
Language / 语言 / 言語: English | 简体中文 | 日本語
aimem-core is AiMem's Rust core library.
It provides:
- Turso-backed storage
- multiprocess WAL coordination for file-backed stores (
.db-tshmsidecar) - project mining and conversation import
- hybrid keyword + vector retrieval
- memory layers / wake-up context generation
- knowledge graph support
- embedding profile guards
- multimodal content primitives
- Unicode/CJK/Kana-aware keyword fallback for Chinese and Japanese retrieval
- reproducible text and deterministic multimodal truth benchmarks in the repository
CLI lives in aimem-cli. MCP server lives in aimem-mcp.
0.5.0 upgrade: breaking changes
- New embedding model: local MiniLM
384d/ fastembed is replaced by EmbeddingGemma 2 ONNX Q8768d. Old vectors and remote Gemini vectors cannot share the new model's store. Stop writers, back up the old DB and its WAL sidecars, then re-embed original text into a separate database. Do not relabel stored profiles; there is no automatic vector conversion. - Rust 1.95+ is now required. First local use downloads about 314 MB of weights plus the tokenizer; subsequent runs can use the cache offline.
- Turso 0.8.3: downstream applications using Turso directly should align versions to avoid incompatible types or duplicate native symbols.
- Rust API: replace matches on
EmbedError::FastembedwithEmbedError::Local. Local provider/model/dimension constants have changed; useembed_queryfor manual retrieval queries.
Full release notes and migration instructions.
Current capabilities
Current aimem-core includes:
- async embedding flow
LocalEmbedder- runs
onnx-community/embeddinggemma-2-ONNXthrough ONNX Runtime using Q8 text weights and normalized768dvectors - downloads about 314 MB of weights plus the tokenizer to the Hugging Face cache on first use (
HF_HOME/HF_HUB_CACHEsupported); works offline once cached - embeds text only, preserving text extraction from multimodal inputs; truncates at 8,192 tokens
embed/embed_oneadd the document prefix;embed_queryadds the retrieval query prefix, whichSearcheruses automatically- opt-in
Gemini2Embedder - multimodal
ContentPart - embedding profile metadata:
- provider
- model
- dimension
- profile guards against mixed stores
Drawerhelper APIMemoryStack::file_text(...)MemoryStack::file_drawer_with_id(...)MemoryStack::file_drawers_with_ids(...)- Turso FTS + RRF-based hybrid search
- CJK/Japanese keyword fallback for no-embedding search
- reproducible EN/ZH/JA benchmark fixtures and result snapshots
- tighter extractor heuristics with multilingual regression tests
Install
[]
= { = "1", = ["full"] }
Recommended API surface
Prefer either:
use *;
or explicit root imports like:
use ;
Core concepts
- Store — one AiMem DB
- Wing — project or domain
- Room — topic inside a wing
- Drawer — one stored chunk
- ContentPart — multimodal part inside a drawer
- L0/L1/L2/L3 — identity, essential story, recall, deep search
Embedding modes
Local
LocalEmbedder- runs
onnx-community/embeddinggemma-2-ONNXthrough ONNX Runtime using Q8 text weights and normalized768dvectors - downloads about 314 MB of weights plus the tokenizer to the Hugging Face cache on first use (
HF_HOME/HF_HUB_CACHEsupported); works offline once cached - embeds text only, preserving text extraction from multimodal inputs; truncates at 8,192 tokens
embed/embed_oneadd the document prefix;embed_queryadds the retrieval query prefix, whichSearcheruses automatically- default recommendation
- embedding stays local
Remote
Gemini2Embedder- explicit opt-in
- only explicit text / data URI / raw bytes are sent
URI-only multimedia parts are not automatically read from disk and uploaded.
Store compatibility guard
aimem-core records embedding profile metadata and validates semantic writes and queries against:
- provider
- model
- dimension
Legacy MiniLM 384d vectors cannot be mixed with the new local 768d vectors. Local EmbeddingGemma 2 and remote Gemini also cannot share a store even though both produce 768d vectors. To migrate, rebuild a separate database from the original text; existing databases are never converted or deleted automatically.
Drawer helpers
use *;
let drawer = new
.with_source_file
.with_chunk_index;
Stable-ID filing through MemoryStack:
use Arc;
use *;
#
# async
When you already have a related set of stable-ID drawers (for example one attachment summary plus chunk drawers), batch them in one call:
use Arc;
use *;
#
# async
AiMem checks existing stable IDs before embedding, so retrying the same batch does not spend another remote embedding call on drawers that are already stored.
For multimodal drawers:
use *;
let drawer = multimodal;
Hybrid search example
use Arc;
use *;
async
Filing text directly
use Arc;
use *;
#
# async
Notes
AimemDb::open()bootstraps schema automatically.- File-backed
AimemDb::open()enables Turso multiprocess WAL coordination and may create.db-wal/.db-tshmsidecars beside the DB file. Miner::new(db, None)andConvoMiner::new(db, None)work fine for text-only filing.- drawers without embeddings still appear in keyword / fallback search.
AimemDb::embedding_profile()reports the current store profile.