---
title: "Best embedding model for code 2026: 9 models for code search"
canonical: "https://xerj.org/compare/best-embedding-model-for-code-2026"
updated: "2026-11-22"
---

# Best embedding model for code in 2026: 9 models compared

SHORT ANSWER · UPDATED 2026-11-22
What is the best embedding model for code search and code RAG in 2026?
**Key number:** For open weights with a commercial licence, Qwen3-Embedding is the strongest all round pick and nomic-embed-code is the strongest code only pick. voyage-code-4 is the hosted option built for coding agents.
Licences, parameter counts and 30 day downloads checked on Hugging Face on 22 Nov 2026. Scores copied from each model card.

**TL;DR** There is no single leaderboard every code model reports on, so read the scores per row. [Qwen3-Embedding](https://huggingface.co/Qwen/Qwen3-Embedding-8B) covers code and 100+ languages under Apache 2.0, from 0.6B to 8B. [nomic-embed-code](https://huggingface.co/nomic-ai/nomic-embed-code) (7B, Apache 2.0) reports 81.7 on CodeSearchNet Python. For a small local model, EmbeddingGemma (300M) and jina-embeddings-v2-base-code (161M) run on a laptop. The Jina code and SFR code models score well but are licensed for non commercial use only.

## Agent prompt

```text
Read https://xerj.org/compare/best-embedding-model-for-code-2026.md. Ask me about my languages, repo size, hardware and licence rules, then pick one code embedding model and show me how to index my repo with it.
```

## Pick one in ten seconds

- Best open weights all round, commercial use: **Qwen3-Embedding** (0.6B for speed, 8B for quality).
- Best code only open model: **nomic-embed-code**.
- Hosted, no GPU: **voyage-code-4** or **voyage-code-3**.
- Laptop or CPU: **EmbeddingGemma-300m** or **jina-embeddings-v2-base-code**.
- Research or internal non commercial use: **jina-code-embeddings** or **SFR-Embedding-Code**.

## When to choose Qwen3-Embedding

Choose Qwen3-Embedding when you want one model family for code, docs and many human languages. The card lists 100+ languages including programming languages, 32K context, and output size you can shrink. The 0.6B model is the most downloaded code capable model here at 7.25M in 30 days. In Qwen's own run on the MTEB Code retrieval subset it scores 75.41.

## When to choose nomic-embed-code

Choose nomic-embed-code when retrieval quality on code matters most and you have a GPU. Its card reports CodeSearchNet scores of 81.7 for Python, 80.5 for Java and 93.8 for Go, ahead of Voyage Code 3 on Python (80.8) and OpenAI Embed 3 Large (70.8). It is 7B parameters with 3,584 dimension vectors, so storage per chunk is high.

## When to choose Voyage code models

Choose voyage-code-4 or voyage-code-3 when you prefer an API. Both take 32,000 tokens and return 1,024 dimensions by default, with 256, 512 and 2,048 as options. The docs describe voyage-code-4 as tuned for code retrieval and coding agent use cases.

## When to choose a small local model

Choose EmbeddingGemma-300m for a strong small model: Google reports 68.76 on MTEB Code v1 at 768 dimensions, with 2K context. Accept the Gemma terms on Hugging Face first. Choose jina-embeddings-v2-base-code (161M, Apache 2.0, 8,192 tokens) when you need a permissive licence and long chunks on CPU.

## When to choose Jina code or SFR code models

Both families publish strong CoIR scores: 73.94 for jina-code-embeddings-0.5b in Jina's table and 67.4 for SFR-Embedding-Code 2B in Salesforce's. Both are CC BY NC 4.0, so they suit research and evaluation. Check the licence before production use.

## Do you need embeddings for code search at all?

Often the fastest win is exact search first. Identifiers, error strings and file paths match lexically, and embeddings help with "where do we retry failed payments" style questions. XERJ is a new way for AI to search for data: it gives coding agents lexical search over your repo by default and lets you add vectors when you need them. See [XERJ vs a vector database](https://xerj.org/compare/xerj-vs-vector-database).

## How we checked

Parameter counts, licences and 30 day downloads come from the Hugging Face API on 22 Nov 2026. Dimensions and context come from model cards, Google AI docs and Voyage docs; two context values are read from the model config and marked. Scores are quoted from the card that published them; we did not rerun them.

## Read next

- [Qwen3-Embedding vs EmbeddingGemma vs BGE-M3](https://xerj.org/compare/qwen3-embedding-vs-embeddinggemma-vs-bge-m3)
- [Best reranker models 2026](https://xerj.org/compare/best-reranker-models-2026)
- [Turbopuffer alternatives 2026](https://xerj.org/compare/turbopuffer-alternatives-2026)
- [XERJ vs a vector database](https://xerj.org/compare/xerj-vs-vector-database)
- [All comparisons](https://xerj.org/compare/)

## FAQ

### What is the best embedding model for code in 2026?

For open weights you can use commercially, Qwen3-Embedding is the best all round choice and nomic-embed-code is the best code only choice, with 81.7 on CodeSearchNet Python in its card. For an API, Voyage offers voyage-code-4 and voyage-code-3.

### What is the best small embedding model for code?

EmbeddingGemma-300m reports 68.76 on MTEB Code v1 with 768 dimensions. jina-embeddings-v2-base-code has 161M parameters, an Apache 2.0 licence and 8,192 tokens of context.

### Which code embedding models allow commercial use?

Qwen3-Embedding, nomic-embed-code and jina-embeddings-v2-base-code are Apache 2.0. EmbeddingGemma uses the Gemma terms. jina-code-embeddings and SFR-Embedding-Code are CC BY NC 4.0, which is non commercial.

### How many dimensions should code embeddings have?

Start at 768 or 1,024. Models with flexible size, such as Qwen3-Embedding, EmbeddingGemma, Voyage and jina-code-embeddings, let you go smaller to save storage and test the quality drop on your own queries.

### Can I run a code embedding model in Ollama?

Yes for Qwen3-Embedding and EmbeddingGemma, which are in the official Ollama library as qwen3-embedding and embeddinggemma on 22 Nov 2026. nomic-embed-code is not listed there, so run it with sentence-transformers.

## Evidence

- Qwen3-Embedding card and Qwen3-Reranker evaluation table: [Qwen3-Embedding-8B](https://huggingface.co/Qwen/Qwen3-Embedding-8B), [Qwen3-Reranker-8B](https://huggingface.co/Qwen/Qwen3-Reranker-8B)
- nomic-embed-code card, CodeSearchNet table: [huggingface.co/nomic-ai/nomic-embed-code](https://huggingface.co/nomic-ai/nomic-embed-code)
- Voyage embedding models: [docs.voyageai.com/docs/embeddings](https://docs.voyageai.com/docs/embeddings)
- EmbeddingGemma model card: [ai.google.dev](https://ai.google.dev/gemma/docs/embeddinggemma/model_card)
- jina-embeddings-v2-base-code card: [huggingface.co](https://huggingface.co/jinaai/jina-embeddings-v2-base-code)
- jina-code-embeddings-1.5b card and jina-reranker-v3 CoIR table: [jina-code-embeddings-1.5b](https://huggingface.co/jinaai/jina-code-embeddings-1.5b), [jina-reranker-v3](https://huggingface.co/jinaai/jina-reranker-v3)
- SFR-Embedding-Code card, CoIR table: [huggingface.co](https://huggingface.co/Salesforce/SFR-Embedding-Code-2B_R)
- Ollama library: [qwen3-embedding](https://ollama.com/library/qwen3-embedding), [embeddinggemma](https://ollama.com/library/embeddinggemma)
- Hugging Face API, licences, parameters and 30 day downloads, 22 Nov 2026.
