local-embedding

A guide for running text-embedding models on your own computer with ONNX Runtime, a tool that runs machine-learning models locally.

In plain words
What is it for?
Use it when configuring offline, local embedding; it covers building the binary, choosing a model, and setting the model before first startup.
Why use it?
It lets Memoria create searchable text representations without sending text to an outside API or requiring an API key, but requires building the software and downloading a model.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/matrixorigin/memoria/local-embedding
Any agent
npx skills add matrixorigin/memoria --skill local-embedding
Clone the repo
git clone --depth 1 https://github.com/matrixorigin/memoria

Made for: Claude Code, Codex.

Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 508 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00034 $0.00508
Opus 5 $0.00017 $0.00254
Sonnet 5 $0.00007 $0.00102
Haiku 4.5 $0.00003 $0.00051

Measured 2d ago against content hash f963c2bfa1e3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

local-embedding scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

sudo cp memoria/target/release/memoria /usr/local/bin/
skills/local-embedding/SKILL.md · 65 lines

What it actually says

Build from Source

Pre-built binaries do NOT include local embedding.

cd Memoria
make build-local
sudo cp memoria/target/release/memoria /usr/local/bin/

Binary is ~50-80MB (bundles ONNX Runtime). Expected.

Configure

memoria init --tool kiro    # No --embedding-* flags needed

Leave EMBEDDING_* env vars empty in mcp.json → local embedding is the default.

How It Works

  1. First query → model downloads to ~/.cache/fastembed/ (~30MB default)
  2. Model loads via ONNX Runtime (~3-5s)
  3. Subsequent queries are fast (in-process)

Models

Model Dim Size Notes
all-MiniLM-L6-v2 384 ~30MB Default. Fast, English
BAAI/bge-m3 1024 ~1.2GB Best quality, multilingual

Change model in mcp.json env block:

{ "EMBEDDING_MODEL": "BAAI/bge-m3", "EMBEDDING_DIM": "1024" }

⚠️ Choose BEFORE first startup. Dimension is locked into schema.

When to Use

Local Remote (OpenAI/SiliconFlow)
Privacy ✅ Offline ⚠️ Text sent to API
Cost Free API key
First query ~3-5s Fast
Build From source Pre-built works
Offline

Recommendation: Use remote unless you need offline/strict privacy.

Troubleshooting

Problem Fix
"compiled without local-embedding" Build from source: make build-local
Model download fails Set HF_ENDPOINT for mirror, or manually download to ~/.cache/fastembed/
High memory Default ~100MB. bge-m3 ~1-2GB. Choose based on available RAM
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 65 lines · 34 tokens per session scan B f963c2bfa1e3

Subscribe to this mod's changes

local-embedding is a skill published in the GitHub repository matrixorigin/memoria (592 stars, last pushed 6d ago), licensed Apache-2.0. It adds 34 tokens to every session and 508 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.