Run this model with HF Jobs

Run f4roukb/denserepr-code-48M-EN-v1 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/f4roukb/denserepr-code-48M-EN-v1. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/f4roukb/denserepr-code-48M-EN-v1 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

denserepr-code-48M-EN-v1

A small dense embedding model for code retrieval: 48M parameters, one 384-d vector per text, cosine similarity, 8,192-token context. It scores 68.86 mean nDCG@10 on CoIR (10 tasks): +4.0 over denserepr-code-48M-pretrain-EN-v1, the model it was trained from, and +15.4 over ibm-granite/granite-embedding-small-english-r2, the original base. On the 7 public tasks of RTEB(Code) it scores 57.76.

It is denserepr-code-48M-pretrain-EN-v1 fine-tuned on 4.4M code retrieval samples, with mined hard negatives and listwise distillation from google/embeddinggemma-2.

At the time of publication (2026-11-23), it is on the Pareto frontier of MTEB CoIR (mean nDCG@10 vs. parameters), across all model types: dense, multi-vector and sparse. It scores higher than every model on the leaderboard with fewer than 149M parameters (3Γ— its size), including F2LLM-v2-80M (80.1M, 68.38, dense) and LateOn-Code-edge (17M, 64.96, multi-vector). The smallest models that score higher are gte-modernbert-base and LateOn-Code, at 149M. The comparison uses the reported results of the models with all 10 tasks, from the MTEB results repository as of 2026-11-22. This model's own scores are measured locally.

It is also on the Pareto frontier of the public RTEB(Code) tasks (see below).

Usage

from sentence_transformers import SentenceTransformer

model = SentenceTransformer("f4roukb/denserepr-code-48M-EN-v1")

queries = ["read a csv file into a list of dicts"]
docs = [
    "def load(path):\n    import csv\n    with open(path) as f:\n        return list(csv.DictReader(f))",
    "def save(rows, path):\n    import json\n    with open(path, 'w') as f:\n        json.dump(rows, f)",
]
q = model.encode(queries)
d = model.encode(docs)
print(model.similarity(q, d))  # the first document scores higher

No prompts or instructions: queries and documents are encoded the same way.

parameters 47,662,464
embedding 384-d, CLS pooling, cosine similarity
max sequence length 8,192 tokens
architecture ModernBERT (from granite-embedding-small-english-r2)
weights fp32 safetensors
precision mixed bf16 / fp32: fp32 weights, run with bf16 autocast

Results: CoIR (MTEB)

nDCG@10 Γ—100 at 8,192 tokens, measured with mteb. All three models are measured the same way.

task granite-small-r2 (base) pretrain-EN-v1 this model
AppsRetrieval 13.48 30.75 48.69
CodeFeedbackMT 52.20 81.19 87.71
CodeFeedbackST 76.84 81.26 83.40
CodeSearchNetCCRetrieval 48.42 75.97 84.17
CodeTransOceanContest 77.63 80.00 81.30
CodeTransOceanDL 33.63 34.84 35.19
CosQA 35.40 33.84 31.87
COIRCodeSearchNetRetrieval 60.42 79.90 81.06
StackOverflowQA 90.04 90.97 92.14
SyntheticText2SQL 46.44 59.69 63.04
mean 53.45 64.84 68.86

Results: RTEB(Code) (MTEB)

nDCG@10 Γ—100 at 8,192 tokens on the 7 public tasks of RTEB(Code, beta); its 2 private tasks are run only by the MTEB maintainers, so this mean differs from the leaderboard's. AppsRetrieval is the same task as in CoIR.

task this model
AppsRetrieval 48.69
DS1000Retrieval 55.01
HumanEvalRetrieval 84.98
MBPPRetrieval 83.54
WikiSQLRetrieval 98.01
FreshStackRetrieval 30.08
SWEbenchCodeRetrieval 4.01
mean 57.76

It is also on the Pareto frontier of these tasks among the models that report them (MTEB results repository, 2026-12-02): the smallest model scoring higher is embeddinggemma-300m (308M, 65.36), or, without SWEbench, which few models report, jina-embeddings-v5-text-nano (212M, 71.35 vs. 66.72). Its successor, denserepr-code-48M-EN-v1.1-matryoshka, scores 59.26 at the same size.

Training

Two stages:

  1. Pretraining (denserepr-code-48M-pretrain-EN-v1): continued contrastive pretraining of granite-embedding-small-english-r2 on ~23M code pairs.
  2. Fine-tuning (this model): contrastive training with mined hard negatives, plus distillation from embeddinggemma-2, on code retrieval data.

Data (fine-tuning stage)

About 4.4M samples, deduplicated and decontaminated against the CoIR test sets:

source content samples share
codefuse-ai/F2LLM-v2 OCGI (instruction β†’ Python), ProCQA (programming question β†’ answer), xCodeEval (problem β†’ solution) 1,588,911 36.6%
CoIR-Retrieval train splits CodeSearchNet, CodeSearchNet-CCR, CodeFeedback-ST/MT, synthetic Text2SQL, StackOverflow-QA, CodeTransOcean 2,172,926 50.0%
seeklhy/SynSQL-2.5M question β†’ SQL (300K subset) 299,996 6.9%
microsoft/rStar-Coder problem β†’ solution 157,710 3.6%
thinkerhui/CoSQA_Plus web query β†’ Python 37,866 0.9%
deepmind/code_contests, IBM Project CodeNet, BAAI/TACO, open-r1/codeforces problem β†’ solution 90,344 2.1%

The pretraining stage's data is described in the pretrain-EN-v1 card.

Limitations

  • English queries; code mostly in Python, Go, Java, PHP, JavaScript, Ruby, C++ and SQL.

License and attribution

Apache-2.0. This model is a modified version of ibm-granite/granite-embedding-small-english-r2 (Apache-2.0, Β© IBM): its weights were changed by the training described above. It is not an IBM model. The distillation teacher, google/embeddinggemma-2, is Apache-2.0; this is not a Google model.

Training data and licenses: cornstack (Apache-2.0), F2LLM-v2 (Apache-2.0; its OCGI and xCodeEval parts are CC-BY-4.0; ProCQA comes from StackOverflow), SynSQL-2.5M (Apache-2.0), rStar-Coder (CC-BY-4.0), CoSQA+ (CC-BY-4.0), code_contests (CC-BY-4.0), Project CodeNet (CDLA-Permissive-2.0), TACO (Apache-2.0), open-r1/codeforces (CC-BY-4.0), and the CoIR train splits, whose upstream sources are APPS (MIT), CodeSearchNet, Code-Feedback (Apache-2.0), gretelai synthetic text-to-SQL (Apache-2.0), CodeTransOcean and StackOverflow (CC-BY-SA). Thanks to their authors.

Citation

@misc{denserepr2026v1,
  title  = {denserepr-code-48M-EN-v1: a small dense embedding model for code retrieval},
  author = {Farouk B.},
  year   = {2026},
  url    = {https://huggingface.co/f4roukb/denserepr-code-48M-EN-v1}
}
Downloads last month
102
Safetensors
Model size
47.7M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for f4roukb/denserepr-code-48M-EN-v1

Datasets used to train f4roukb/denserepr-code-48M-EN-v1

Space using f4roukb/denserepr-code-48M-EN-v1 1