Model reference · open weights

nomic-embed-code

Embeddings nomic-ai Embeddings 2 builds Open weights 384k dl/mo

nomic-embed-code is an open-weight embedding model from nomic-ai. nomic-embed-code-GGUF (GGUF) weighs 4.4 GB; the smallest configuration that runs it is RTX 3060 12 GB.

  • nomic-embed-code is a 7.1B parameter sentence-similarity model developed by nomic-ai for code retrieval tasks.
  • It supports a context length of 32768 tokens and is trained for Python, Java, Ruby, PHP, JavaScript, and Go.
  • The model is released under the apache-2.0 licence.

Summary of the nomic-ai/nomic-embed-code model card, 2026-10-01. The estimate below is for another build of the family.

What it is

Released bynomic-ai
Released2025-03-24
Parameters7.1B
VRAM4.4 GB for the weights

What it runs on

Memory and cards for nomic-embed-code-GGUF (GGUF)

4.4 GBweights, file size
1.1 GBruntime overhead
CardRunsMemory
RTX 3060 12 GBfits11.6 GB
RTX 4060 Ti 16 GBfits15.4 GB
RTX 3090 24 GBfits23.4 GB
RTX 4090 24 GBfits23.4 GB
RTX 5090 32 GBfits31.0 GB
L40S 48 GBfits44.0 GB
A100 80 GBfits78.2 GB
H100 80 GBfits78.1 GB
RTX PRO 6000 Blackwell 96 GBfits93.8 GB
DGX Spark (GB10) 128 GB unifiedfits107 GB
H200 141 GBfits138 GB
B200 180 GBfits176 GB

Builds

Sizes, precisions & builds

BuildParamsPrecisionWeightsSmallest setup
nomic-embed-code ↗ 7.1BFP32 14.1 GBRTX 4060 Ti 16 GB
nomic-embed-code-GGUF (above) ↗
15 builds: Q2_K 2.8 GB … F32 28.3 GB
—GGUF 4.4 GBRTX 3060 12 GB

From the model card

What nomic-ai says about nomic-embed-code

Read the model card

Blog | Technical Report | AWS SageMaker | Atlas Embedding and Unstructured Data Analytics Platform

nomic-embed-code is a state-of-the-art code embedding model that excels at code retrieval tasks:

  • High Performance: Outperforms Voyage Code 3 and OpenAI Embed 3 Large on CodeSearchNet
  • Multilingual Code Support: Trained for multiple programming languages (Python, Java, Ruby, PHP, JavaScript, Go)
  • Advanced Architecture: 7B parameter code embedding model
  • Fully Open-Source: Model weights, training data, and evaluation code released
ModelPythonJavaRubyPHPJavaScriptGo
Nomic Embed Code81.780.581.872.377.193.8
Voyage Code 380.880.584.671.779.293.2
OpenAI Embed 3 Large70.872.975.359.668.187.6
Nomic CodeRankEmbed-137M78.476.979.368.871.492.7
CodeSage Large v2 (1B)74.272.376.765.272.584.6
CodeSage Large (1B)70.870.271.961.369.583.7
Qodo Embed 1 7B59.961.668.448.557.081.4

Model Architecture

  • Total Parameters: 7B
  • Training Approach: Trained on the CoRNStack dataset with dual-consistency filtering and progressive hard negative mining
  • Supported Languages: Python, Java, Ruby, PHP, JavaScript, and Go

Usage Guide

Installation

You can install the necessary dependencies with:

pip install transformers sentence-transformers torch

Transformers

import torch
import torch.nn.functional as F
from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("nomic-ai/nomic-embed-code")
model = AutoModel.from_pretrained("nomic-ai/nomic-embed-code")

def last_token_pooling(hidden_states, attention_mask):
    sequence_lengths = attention_mask.sum(-1) - 1
    return hidden_states[torch.arange(hidden_states.shape[0]), sequence_lengths]

queries = ['Represent this query for searching relevant code: Calculate the n-th factorial']
codes = ['def fact(n):\n if n < 0:\n  raise ValueError\n return 1 if n == 0 else n * fact(n - 1)']
code_snippets = queries + codes

encoded_input = tokenizer(code_snippets, padding=True, truncation=True, return_tensors='pt')
model.eval()
with torch.no_grad():
    model_output = model(**encoded_input)[0]

embeddings = last_token_pooling(model_output, encoded_input['attention_mask'])
embeddings = F.normalize(embeddings, p=2, dim=1)
print(embeddings.shape)

similarity = F.cosine_similarity(embeddings[0], embeddings[1], dim=0)
print(similarity)

SentenceTransformers

from sentence_transformers import SentenceTransformer

queries = ['Calculate the n-th factorial']
code_snippets = ['def fact(n):\n if n < 0:\n  raise ValueError\n return 1 if n == 0 else n * fact(n - 1)']

model = SentenceTransformer("nomic-ai/nomic-embed-code")
query_emb = model.encode(queries, prompt_name="query")
code_emb = model.encode(code_snippets)

similarity = model.similarity(query_emb[0], code_emb[0])
print(similarity)

CoRNStack Dataset Curation

Starting with the deduplicated Stackv2, we create text-code pairs from function docstrings and respective code. We filtered out low-quality pairs where the docstring wasn't English, too short, or that contained URLs, HTML tags, or invalid characters. We additionally kept docstrings with text lengths of 256 tokens or longer to help the model learn long-range dependencies.

After the initial filtering, we used dual-consistency filtering to remove potentially noisy examples. We embed each docstring and code pair and compute the similarity between each docstring and every code example. We remove pairs from the dataset if the corresponding code example is not found in the top-2 most similar examples for a given docstring.

During training, we employ a novel curriculum-based hard negative mining strategy to ensure the model learns from challenging examples. We use a softmax-based sampling strategy to progressively sample hard negatives with increasing difficulty over time.

Join the Nomic Community

Citation

If you find the model, dataset, or training code useful, please cite our work:

@misc{suresh2025cornstackhighqualitycontrastivedata,
      title={CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking},
      author={Tarun Suresh and Revanth Gangi Reddy and Yifei Xu and Zach Nussbaum and Andriy Mulyar and Brandon Duderstadt and Heng Ji},
      year={2025},
      eprint={2412.01007},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2412.01007},
}

Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.

© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms