Skip to content

feat: Local ONNX embedder — ship all-MiniLM or nomic without Ollama #360

Closed

Description

@hurttlocker

Goal

Add onnx as a native embed provider in Cortex so we can ship a small embedding model (~80MB) inside Cortex IDE without requiring Ollama.

Context

  • Cortex already has ONNX runtime compiled in (used for reranker: bge-reranker-base, bge-reranker-v2-m3)
  • The embed pipeline currently only supports API providers: ollama, openai, deepseek, openrouter, custom
  • For Cortex IDE shipping, we need local embeddings with zero external dependencies
  • Current embed coverage: 338/5693 memories (5.94%) — most search is BM25

Task

  1. Add onnx as an embed provider in the embed pipeline
  2. Support onnx/all-minilm-l6-v2 (80MB, 384 dims) and onnx/nomic-embed-text (275MB, 768 dims)
  3. Auto-download model on first use (like rerank-setup does for reranker)
  4. cortex embed onnx/all-minilm-l6-v2 should just work

Comparison Needed

Run both models against the same fact corpus and compare:

  • Retrieval quality — does semantic search find facts that BM25 misses?
  • Speed — embeddings per second on typical hardware
  • Size tradeoff — 80MB (MiniLM, 384d) vs 275MB (nomic, 768d)
  • Accuracy — which produces better search results for agent memory (decisions, people, configs)?

Use cortex eval search fixture corpus if available, or create a benchmark with 50 known query→fact pairs.

Architecture

The ONNX infra is already in the binary:

  • OrtGetApiBase (ONNX Runtime C API)
  • ONNX_TYPE_TENSOR, ONNX_TYPE_MAP
  • Model path pattern: ~/.cortex/models/embed/<model>/model_int8.onnx
  • Tokenizer: ship tokenizer.json alongside the ONNX model (HuggingFace format)

Success Criteria

  • cortex embed onnx/all-minilm-l6-v2 --status shows model loaded, generating embeddings
  • cortex search "project deadline" --mode semantic returns results using ONNX embeddings
  • No Ollama, no API keys, no external dependencies
  • Comparison doc: MiniLM vs nomic quality/speed/size

Activity

  1. added
    enhancement
    on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions