Skip to content

research: small CPU-only code embeddings + adoptable optimizations from peer tools (embed tier roadmap) #544

Description

@ajianaz

Goal

Pick the next embedding tier for Brain Mode (between today's hashing 256d ≈15-20 CoIR and the planned 154 MB ONNX jina-v2-base-code ≈57 in #500), and harvest optimization ideas from peer tools. CPU-only is a hard requirement (cora is BYOK/local-first).

Candidate: EmbeddingGemma-300m (Q4, ONNX)

  • ~300M params, runs in-browser/on-device, QAT-quantized for edge
  • Code retrieval strength: arXiv 2509.20354 reports large gains on CosQA and AppsRetrieval vs same-size models
  • License: Gemma terms (usable, not Apache) — flag vs our Apache-2.0 stance
  • Caveats: HF thread reports weak out-of-box results without proper prompt/task prefixes

Alternatives

  • jina-embeddings-v2-base-code (154 MB q8, Apache-2.0, ~57 CoIR est) — the feat(brain): ONNX runtime integration with Jina v2 base code embeddings #500 plan, proven license
  • nomic-embed-text v1.5 (137M, Apache-2.0) — general text, weaker on code
  • codet5p-110m (BSD-3) — code-specific, seq 512, no ONNX
  • Vendor upgrade path: nomic-embed-code 7B / jina-code-0.5b — too big or NC-licensed

What peers actually use

  • codebase-memory-mcp (40.9k★): bundles nomic-embed-code 768d int8 into the binary; local CPU inference; hybrid FTS5-BM25 + vectors + graph + 11-signal ranking; MinHash/LSH clone detection; Louvain communities; team-shared zstd graph artifact; Linux kernel 28M LOC in ~3 min
  • graphify: knowledge-graph MCP; embeddings roadmap = OpenAI API or nomic-embed-text via Ollama (local)
  • Tabby: default embedding = Nomic-Embed-Text (local)
  • Continue.dev: recommends nomic-embed-text via Ollama; voyage-code-3 if cloud OK
  • aider / code-review-graph: NO embeddings — pure tree-sitter repo/structural maps

⇒ Industry local default is Nomic-family on CPU; nobody ships a small code-specific transformer locally — a gap EmbeddingGemma-300m or jina-v2-code would fill for cora.

Adoptable optimizations for cora

  1. int8/f16 storage of embeddings (pairs with vecq backend, feat(brain): vecq as opt-in vector backend for v0.15.0 (replace usearch long-term) #542)
  2. Fused multi-signal ranking notes (we already do RRF; compare against their 11-signal scorer)
  3. MinHash+LSH near-clone detection as a cheap cora extra
  4. Team-shared compressed index artifact (graph.db.zst pattern) for onboarding
  5. Louvain community detection on our call graph for cora arch
  6. Background git-watcher incremental re-index (we have cora index --watch; consider auto-trigger)

Recommendation

  1. Short term: keep hashing (tier 0) + nomic static (tier 1)
  2. v0.15/0.16: ship jina-v2-base-code ONNX q8 (tier 2, feat(brain): ONNX runtime integration with Jina v2 base code embeddings #500) — Apache-clean, known quality
  3. Evaluate EmbeddingGemma-300m QAT Q4 as tier 2 alternative: smaller than jina-q8? (~170 MB q4) — license + prompt-prefix caveats
  4. vecq store (feat(brain): vecq as opt-in vector backend for v0.15.0 (replace usearch long-term) #542) composes with any of these

Sources: arXiv 2509.20354 · codebase-memory-mcp README · graphify#1 · tabby docs · ollama nomic-embed-text

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions