Repository navigation
feat: local embedding backend via Candle (#18) - #57
Merged
Merged
Conversation
Add an in-process, zero-API-key embedding backend powered by Candle so memayu can run fully on-device with no external runtime dependencies. - LocalEmbedder (Candle BERT) with lazy one-time model download from HF, cached under the data dir (models--<owner>--<name>/snapshots/<rev>) - Default multilingual model paraphrase-multilingual-MiniLM-L12-v2 (384-d, covers Bahasa Indonesia + English); override via embedder.model / MEMAYU_MODEL_DIR - Direct ureq download that follows HF's relative redirects (hf-hub 0.3 mishandles them), with concurrency-safe temp files - build_embedder + is_local_backend wiring; config EmbedderBackend::Local - doctor reports on-device backend and skips HTTP probes; setup wizard offers local as default backend - web dashboard /providers gains a backend selector; probe uses build_embedder so local backends are honest and config stays authoritative - mixed EN/ID retrieval gate test (recall@3 5/5) plus dimension + normalization tests - README documents the local embedding backend
4 tasks done
This was referenced Aug 16, 2026
savioruz
marked this pull request as ready for review
August 16, 2026 02:23
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a local embedder backend via Candle (issue #18): run text embedding on-device with a quantized GGUF model (e.g.
all-MiniLM-L6-v2) so Memayu works fully offline for the embedding leg — no external embedder API needed.Changes
New local embedder (
crates/memayu-llm-client/src/local_embedder.rs)LocalEmbedderloads a quantized gguf viacandle-*, exposesembed(query) -> Vec<f32>(dim matches configdimension) andsupports(model) -> boolfor availability probing without loading.MEMAYU_EMBEDDER_PROVIDER=local;base_urlis unused in this mode.Core plumbing
crates/memayu-llm-client/src/lib.rs: branch onEmbedderKind::Local; registerLocalEmbedderas the provider; fall back to the remote embedder otherwise.crates/memayu-llm-client/Cargo.toml:candle-*deps are optional/feature-gated so non-local builds don't pay compile cost.crates/memayu-config/src/lib.rs: parse + validatelocalembedder provider (model= gguf path);check()validates the model file exists.crates/memayu-api/src/modules/providers/service.rs+crates/memayu-web/src/pages/providers.rs: surface "local model" in the providers admin API + web page.Docs
MEMAYU_EMBEDDER_PROVIDER=localandMEMAYU_EMBEDDER_MODEL=<gguf path>.Migration / behavior
Tests
crates/memayu-llm-client/tests/local_embedding.rs(171 lines): loads a small model, asserts embed output dimension andsupports() == true.cli.rs/doctor.rsroundtrips run raw-mode with a fixed-vector embedder mock via env overrides (local path not exercised there, but the remote fallback branch is).Checklist
dimensionprobe still works via the existing embedder.Fixes #18