Skip to content

feat: add native ONNX all-MiniLM embedder - #366

Merged
o8-run-agent[bot] merged 2 commits into
mainfrom
feat/onnx-native-embed
Mar 25, 2026
Merged

o8-run-agent[bot] merged 2 commits into
mainfrom
feat/onnx-native-embed

Conversation

@hurttlocker

Copy link
Copy Markdown
Owner

Closes #360
Closes #361

What changed

  • adds onnx/all-minilm-l6-v2 as a native embed provider in the Cortex embed pipeline
  • auto-downloads the local ONNX model and tokenizer into ~/.cortex/models/embed/all-minilm-l6-v2/
  • adds embedder auto-resolution in this order: explicit config, Ollama with an embed model, local ONNX, ONNX auto-download fallback
  • wires the resolved embedder into cortex embed, search, ask, answer, the background embed worker, cortex embed --status, and cortex doctor
  • adds local embedder status reporting, source reporting, model-path reporting, and stored-vs-resolved dimension mismatch reporting
  • adds the benchmark note at docs/research/onnx-embedder-benchmark-2026-03-24.md

Why this change exists

Cortex already had native ONNX runtime support for reranking, but embeddings were still the last external dependency. This change makes semantic memory work with zero Ollama process and zero API keys on a fresh machine while still respecting an explicit configured provider when one exists.

Touched surfaces

  • internal/embed
  • cmd/cortex
  • docs/research/onnx-embedder-benchmark-2026-03-24.md

Tests run

  • go test ./...

Verification and benchmark notes

  • cortex embed --status now reports the resolved provider, source, model path, status, and dimension compatibility
  • cortex doctor --json now reports the resolved embedder and surfaces config/store dimension mismatches
  • full ONNX live-DB re-embed result from the benchmark note:
    • 5694 memories in 69199 ms
    • about 82.3 emb/s
  • the bounded live-DB Ollama sample observed 18 embeddings in 180s, which projects to about 15.8h; that is documented explicitly as an extrapolation, not a completed full pass
  • direct ONNX vs Ollama all-MiniLM parity on representative live-memory excerpts showed average query-vector cosine 0.991, average candidate-vector cosine 0.986, and identical top-1 retrieval on 5/5 sampled queries

Risk

  • the live benchmark also surfaced a pre-existing config mismatch: the current config pointed at ollama/nomic-embed-text while the stored live corpus is 384d; the new doctor/status reporting makes that visible, but users with stale explicit configs may need to re-embed
  • the ONNX benchmark is a completed full pass; the Ollama benchmark is an honest bounded-sample extrapolation because the full live-DB pass was too slow to finish in the benchmark window

Docs / release-note impact

  • docs updated in the same PR with the benchmark note
  • product behavior changed: yes
  • benchmark / eval interpretation changed: yes

@o8-run-agent
o8-run-agent Bot merged commit 762b736 into main Mar 25, 2026
@hurttlocker
hurttlocker deleted the feat/onnx-native-embed branch March 25, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: auto-detect embedder — ship all-minilm default, respect existing feat: Local ONNX embedder — ship all-MiniLM or nomic without Ollama

1 participant