divakantpandey's picture
Link the published preprint DOI
858e600 verified
|
Raw History Blame Contribute Delete
4.05 kB
---
language:
- en
- code
license: apache-2.0
library_name: sentence-transformers
pipeline_tag: sentence-similarity
base_model: Alibaba-NLP/gte-modernbert-base
tags:
- sentence-transformers
- feature-extraction
- code-search
- negative-result
---
# code-embed-v3-150m-ft-behaviour
Research artefact for the paper *Does Execution-Verified Near-Miss Training Teach Code Embeddings to Prefer Working Code? A Negative Result* (preprint, [doi:10.5281/zenodo.24402953](https://doi.org/10.5281/zenodo.24402953)). This is the **near-miss pilot**: GTE-ModernBERT-base fine-tuned on a replay mix plus 11% execution-verified near-miss pairs (CodeContests mutants and rewrites checked in a sandbox, SWE-smith bug/fix twins).
**This is not a better code embedder than its base.** It is released so the paper's comparison can be
reproduced. For code search, use the base model,
[Alibaba-NLP/gte-modernbert-base](https://huggingface.co/Alibaba-NLP/gte-modernbert-base).
The replay-only control trained on the same replay rows without the near-miss data is [code-embed-v3-150m-ft-control](https://huggingface.co/divakantpandey/code-embed-v3-150m-ft-control).
## Results
| Model (same machine, float32, 8,192 tokens) | exec@1 | beats_paired | CoQuIR pairwise | MTEB(Code, v1) | AppsRetrieval |
|---|---|---|---|---|---|
| [gte-modernbert-base](https://huggingface.co/Alibaba-NLP/gte-modernbert-base) (base) | 0.0927 | 0.0990 | 0.5528 | 71.78 | 57.67 |
| [replay-only control](https://huggingface.co/divakantpandey/code-embed-v3-150m-ft-control) | 0.0852 | 0.0905 | 0.5588 | 69.75 | 53.89 |
| [near-miss pilot](https://huggingface.co/divakantpandey/code-embed-v3-150m-ft-behaviour) | 0.0990 | 0.1054 | 0.5527 | 66.02 | 18.87 |
Pilot vs control, paired over queries: exec@1 +0.014 (McNemar p = 0.21), beats_paired +0.015 (p = 0.18),
CoQuIR pairwise -0.006 (bootstrap p = 0.043). MTEB(Code) was scored in float16 for both fine-tunes.
The near-miss data gives a small, non-significant gain on ExecRetrieval and alone causes the AppsRetrieval
collapse. Fine-tuning on the replay mix by itself costs about 2 points of MTEB(Code).
## Training
- Base: `Alibaba-NLP/gte-modernbert-base`, CLS pooling, normalised, 768 dimensions (Matryoshka at 512, 256, 128, 64)
- Data: 240,054 rows (11.0% near-miss), 14,995 steps, batch 16, one epoch, one source per batch
- Loss: cached multiple-negatives ranking, temperature 0.015, Matryoshka; learning rate 2e-5; 512 training tokens
- Float32 master weights; single seed
- Training data is decontaminated against MTEB(Code, v1), CoIR, CoREB(v1), ExecRetrieval and CoQuIR
Recipe, research log and experiment drivers: https://github.com/divakantpandey/code-embed-v3
Training data: [code-embed-v3-data](https://huggingface.co/datasets/divakantpandey/code-embed-v3-data) (replay rows) and [code-embed-v3-synth](https://huggingface.co/datasets/divakantpandey/code-embed-v3-synth) (near-miss rows). Per-query evaluation outputs, paired tests and run logs: [code-embed-v3-src](https://huggingface.co/divakantpandey/code-embed-v3-src).
## Usage
```python
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("divakantpandey/code-embed-v3-150m-ft-behaviour")
q = model.encode(["reverse a linked list"], prompt_name="nl2code")
d = model.encode(["def reverse(head): ..."])
print(model.similarity(q, d))
```
Queries take a task prompt (`nl2code`, `code2code`, `code2nl`, `text2sql`, ...; see
`config_sentence_transformers.json`); documents take none. The paper's numbers compare embeddings in float32.
## Limitations
One training seed per model; ExecRetrieval's 939 queries cannot resolve one-point differences; only one base
model was studied.
## Citation
```bibtex
@misc{pandey2026nearmiss,
title = {Does Execution-Verified Near-Miss Training Teach Code Embeddings to Prefer Working Code? A Negative Result},
author = {Pandey, Divakant},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.24402953},
url = {https://doi.org/10.5281/zenodo.24402953}
}
```