Feature Extraction
sentence-transformers
ONNX
Safetensors
modernbert
code-search
code-embedding
retrieval
dense
text-embeddings-inference
Instructions to use Shuu12121/NightOwl-CodeEmbedding with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Shuu12121/NightOwl-CodeEmbedding with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Shuu12121/NightOwl-CodeEmbedding") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -19,42 +19,40 @@ datasets:
|
|
| 19 |
|
| 20 |
# NightOwl-CodeEmbedding 🦉
|
| 21 |
|
| 22 |
-
`NightOwl-CodeEmbedding` is a compact 768-dimensional dense embedding model
|
| 23 |
-
|
| 24 |
-
answering.
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
ModernBERT-based code model. It uses CLS pooling with cosine similarity and
|
| 29 |
does **not** require `query:` / `passage:` style prefixes.
|
| 30 |
|
| 31 |
## Highlights
|
| 32 |
|
| 33 |
* Compact (150.8M parameters) yet competitive on CoIR-style code retrieval benchmarks
|
| 34 |
-
*
|
| 35 |
-
leaderboard
|
| 36 |
-
**top-scoring single-vector model under 300M parameters** among scored
|
| 37 |
-
|
| 38 |
-
[Leaderboard Standing](#leaderboard-standing))
|
| 39 |
-
*
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
* Trained with hard negatives mined by `Qwen/Qwen3-Embedding-0.6B`
|
| 44 |
(15 hard negatives per anchor)
|
| 45 |
-
* Decontaminated against CodeSearchNet test splits and the
|
| 46 |
CodeEditSearchRetrieval benchmark (see [Data Decontamination](#data-decontamination))
|
| 47 |
-
* Drop-in compatible with `sentence-transformers`
|
| 48 |
|
| 49 |
## Supported Languages
|
| 50 |
|
| 51 |
-
The training data covers the six CodeSearchNet languages plus two additional
|
| 52 |
-
languages:
|
| 53 |
-
|
| 54 |
* Go, Java, JavaScript, PHP, Python, Ruby (CodeSearchNet languages)
|
| 55 |
* **Rust, TypeScript** (additional)
|
| 56 |
|
| 57 |
-
Performance on languages outside this set is
|
| 58 |
|
| 59 |
## Usage
|
| 60 |
|
|
@@ -95,8 +93,7 @@ print(scores)
|
|
| 95 |
|
| 96 |
## MTEB Results
|
| 97 |
|
| 98 |
-
The model was evaluated with MTEB on code-related retrieval and technical QA
|
| 99 |
-
tasks.
|
| 100 |
|
| 101 |
Evaluation setup:
|
| 102 |
|
|
@@ -125,152 +122,91 @@ Multi-subset task scores are reported as macro averages.
|
|
| 125 |
| **Macro average, all 12 tasks** | | **0.70907** |
|
| 126 |
| **CoIR macro average, 10 tasks** | | **0.68684** |
|
| 127 |
|
| 128 |
-
¹ `CodeEditSearchRetrieval` does not provide a standard `test` split in MTEB,
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
[Data Decontamination](#data-decontamination) for details.
|
| 132 |
|
| 133 |
### Leaderboard Standing
|
| 134 |
|
| 135 |
On the public [MTEB(Code, v1)](https://huggingface.co/spaces/mteb/leaderboard)
|
| 136 |
-
leaderboard, the model's task-mean score (70.91, i.e. the 12-task macro average
|
| 137 |
-
|
| 138 |
|
| 139 |
-
* **#18 of 241 models overall**, ahead of many models
|
| 140 |
-
magnitude larger
|
| 141 |
* **#6 of 155 among sub-1B-parameter dense single-vector models** — and the
|
| 142 |
-
**smallest model in that top six**. The five models ranked above it
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
* **#1 among ranked dense single-vector models under 300M parameters**
|
| 146 |
-
leaderboard's small-model view)
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
>
|
| 152 |
-
>
|
| 153 |
-
> `
|
| 154 |
-
>
|
| 155 |
-
>
|
| 156 |
-
> the `
|
| 157 |
-
> out-of-domain, so a raw score comparison across rows with different
|
| 158 |
-
> zero-shot % is not apples-to-apples. The fairest direct comparisons are to
|
| 159 |
-
> other code-specialized models at similar zero-shot levels (e.g.
|
| 160 |
-
> `LateOn-Code` at 8%, the `F2LLM` / `C2LLM` families at 8–58%).
|
| 161 |
|
| 162 |
### Comparison with similar-sized models
|
| 163 |
|
| 164 |
-
The table below compares `NightOwl-CodeEmbedding` with other compact
|
| 165 |
-
|
| 166 |
-
for reference. Score is the leaderboard task mean (higher is
|
| 167 |
-
*Zero-shot* column is the share of tasks the model did not train on.
|
| 168 |
-
|
| 169 |
-
| Model | Params |
|
| 170 |
-
| ---------------------------------------------------- | ------: | --------
|
| 171 |
-
| **`NightOwl-CodeEmbedding`** (this model) | 150.8M |
|
| 172 |
-
| `codefuse-ai/F2LLM-v2-160M` | 159M |
|
| 173 |
-
| `google/embeddinggemma-300m` | 308M |
|
| 174 |
-
| `codefuse-ai/F2LLM-v2-80M` | 80M |
|
| 175 |
-
| `ibm-granite/granite-embedding-311m-multilingual-r2` | 312M |
|
| 176 |
-
|
|
| 177 |
-
| `
|
| 178 |
-
|
|
| 179 |
-
| `codefuse-ai/F2LLM-v2-
|
| 180 |
-
| `Qwen/Qwen3-Embedding-0.6B` | 596M | single-vector | 1,024 | 32,768 | 100% | 75.42 |
|
| 181 |
-
| `codefuse-ai/F2LLM-v2-14B` (#1 overall) | 13.99B | single-vector | 5,120 | 40,960 | 58% | 80.75 |
|
| 182 |
|
| 183 |
Takeaways:
|
| 184 |
|
| 185 |
-
* Among compact
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
larger, sitting in a different deployment cost regime entirely.
|
| 194 |
-
|
| 195 |
-
### Head-to-head vs LateOn-Code
|
| 196 |
-
|
| 197 |
-
`lightonai/LateOn-Code` is the only sub-0.5B model that outranks
|
| 198 |
-
`NightOwl-CodeEmbedding` once multi-vector models are included, so it is worth a
|
| 199 |
-
closer look. It is a **ColBERT-style late-interaction** model (built with PyLate
|
| 200 |
-
on ModernBERT-base): it stores **one 128-dimensional vector per token** and
|
| 201 |
-
scores with the MaxSim operator, rather than a single 768-d vector per text.
|
| 202 |
-
That buys accuracy at the cost of a larger index and a different retrieval path
|
| 203 |
-
(PyLate + a PLAID index), whereas `NightOwl` is a drop-in single-vector
|
| 204 |
-
`sentence-transformers` model.
|
| 205 |
-
|
| 206 |
-
Per-task NDCG@10 (×100) on MTEB(Code, v1); both models are code-specialized and
|
| 207 |
-
in-domain (8% zero-shot), so this is a like-for-like comparison. **Bold** marks
|
| 208 |
-
the higher score on each task.
|
| 209 |
-
|
| 210 |
-
| Task | NightOwl-CodeEmbedding | LateOn-Code (multi-vec) |
|
| 211 |
-
| -------------------------- | ---------------------: | ----------------------: |
|
| 212 |
-
| AppsRetrieval | 39.18 | **54.76** |
|
| 213 |
-
| COIRCodeSearchNetRetrieval | 84.26 | **86.57** |
|
| 214 |
-
| CodeEditSearchRetrieval | **74.81** | 64.99 |
|
| 215 |
-
| CodeFeedbackMT | 76.69 | **82.22** |
|
| 216 |
-
| CodeFeedbackST | 85.21 | **90.40** |
|
| 217 |
-
| CodeSearchNetCCRetrieval | **91.81** | 89.32 |
|
| 218 |
-
| CodeSearchNetRetrieval | 89.24 | **90.40** |
|
| 219 |
-
| CodeTransOceanContest | 75.95 | **87.44** |
|
| 220 |
-
| CodeTransOceanDL | 36.06 | **41.00** |
|
| 221 |
-
| CosQA | 42.81 | **45.23** |
|
| 222 |
-
| StackOverflowQA | 86.61 | **93.43** |
|
| 223 |
-
| SyntheticText2SQL | **68.27** | 63.67 |
|
| 224 |
-
| **Average** | 70.91 | **74.12** |
|
| 225 |
-
|
| 226 |
-
`LateOn-Code` wins on average, driven mostly by AppsRetrieval and the
|
| 227 |
-
feedback/translation/QA tasks. However, `NightOwl-CodeEmbedding` wins on three
|
| 228 |
-
tasks that map directly to its design focus:
|
| 229 |
-
|
| 230 |
-
* **CodeEditSearchRetrieval** (+9.8): matching edit intents to code changes —
|
| 231 |
-
`NightOwl`'s dedicated code-edit training shows here.
|
| 232 |
-
* **CodeSearchNetCCRetrieval** (+2.5): code-to-code / similar-function retrieval.
|
| 233 |
-
* **SyntheticText2SQL** (+4.6): NL-to-SQL retrieval.
|
| 234 |
-
|
| 235 |
-
So for single-vector code-edit and code-to-code retrieval specifically,
|
| 236 |
-
`NightOwl` is competitive with or ahead of a higher-average multi-vector model,
|
| 237 |
-
while keeping a standard dense-vector index. (LateOn-Code scores sourced from
|
| 238 |
-
the model's
|
| 239 |
-
[MTEB(Code, v1) table](https://huggingface.co/lightonai/LateOn-Code).)
|
| 240 |
-
|
| 241 |
-
Because the benchmark suite consists of in-domain code retrieval tasks related
|
| 242 |
-
to the model's training distribution, these results should not be interpreted
|
| 243 |
-
as strictly zero-shot performance.
|
| 244 |
|
| 245 |
## Base Model: the NightOwl Backbone
|
| 246 |
|
| 247 |
`NightOwl-CodeEmbedding` is fine-tuned from
|
| 248 |
-
[`Shuu12121/NightOwl`](https://huggingface.co/Shuu12121/NightOwl), a
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
**
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
more genuinely distinct subwords, while still representing indentation faithfully
|
| 262 |
-
— which matters for whitespace-significant languages such as Python.
|
| 263 |
|
| 264 |
**Two-phase pre-training with line-level masking.** NightOwl is trained with
|
| 265 |
masked-language modeling (`mlm_probability = 0.3`) in two phases:
|
| 266 |
|
| 267 |
* *Phase 1 — mixed pre-training:* standard random-token MLM over code, natural
|
| 268 |
-
language, and technical documentation (
|
| 269 |
-
* *Phase 2 — code-only continuation:* **line-level MLM**, where entire
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
|
| 275 |
Backbone architecture (base):
|
| 276 |
|
|
@@ -278,119 +214,108 @@ Backbone architecture (base):
|
|
| 278 |
| ------------------------------ | ----------------------------------------------------- |
|
| 279 |
| Architecture | ModernBERT (alternating local/global attention, RoPE) |
|
| 280 |
| Parameters | ≈150M |
|
| 281 |
-
| `hidden_size` / layers / heads | 768 / 19 / 12
|
| 282 |
-
| Vocabulary | 50,368 (custom code BPE)
|
| 283 |
| Max sequence length | 1,024 (Phase 1) → 2,048 (Phase 2) |
|
| 284 |
|
| 285 |
Pre-training data mixes `bigcode/starcoder2data-extras` (Kaggle notebooks,
|
| 286 |
-
StackOverflow threads, GitHub issues, technical documentation, …) with
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
|
| 291 |
As a raw backbone — before any embedding fine-tuning — NightOwl reaches **0.8436
|
| 292 |
average MRR** on MTEB `CodeSearchNetRetrieval` under a fixed SentenceTransformer
|
| 293 |
-
fine-tuning protocol, ahead of CodeBERT-base (0.7944), GraphCodeBERT-base
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
|
| 298 |
## Training
|
| 299 |
|
| 300 |
-
The model was trained with `CachedMultipleNegativesRankingLoss` using
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
| Property | Value
|
| 304 |
-
| -------------------------- | ------------------------------------
|
| 305 |
-
| Training samples | 2,534,400
|
| 306 |
-
| Positives per anchor | 1
|
| 307 |
-
| Negatives per anchor | 15
|
| 308 |
-
| Loss | `CachedMultipleNegativesRankingLoss`
|
| 309 |
-
| Objective | Bidirectional retrieval training
|
| 310 |
-
| Hard-negative mining model | `Qwen/Qwen3-Embedding-0.6B`
|
| 311 |
-
| Epochs | 1
|
| 312 |
-
| Learning rate | 6e-5
|
| 313 |
-
| Batch size | 1024
|
| 314 |
|
| 315 |
### Training Data
|
| 316 |
|
| 317 |
The training data is a mixture of:
|
| 318 |
|
| 319 |
-
1. **Public code-retrieval datasets** covering the following CoIR task
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
This setup is intended to improve discrimination between code snippets,
|
| 339 |
-
programming questions, edit examples, and technically similar retrieval
|
| 340 |
-
candidates.
|
| 341 |
|
| 342 |
### Data Decontamination
|
| 343 |
|
| 344 |
-
To reduce benchmark contamination, the following overlaps were removed from
|
| 345 |
-
|
| 346 |
|
| 347 |
-
* Overlaps between the custom code
|
| 348 |
-
|
| 349 |
* Overlaps between the `commitpackft`-derived code-edit data and the
|
| 350 |
**CodeEditSearchRetrieval** benchmark evaluation data
|
| 351 |
|
| 352 |
-
For `CodeEditSearchRetrieval`, note that MTEB labels the evaluation split
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
performance
|
| 358 |
-
strictly zero-shot performance.
|
| 359 |
|
| 360 |
## Intended Use
|
| 361 |
|
| 362 |
-
This model is intended for code-related retrieval tasks such as:
|
| 363 |
-
|
| 364 |
* Natural language to code search
|
| 365 |
-
* Code-to-code retrieval and similar
|
| 366 |
* Code-edit retrieval (matching edit intents to code changes)
|
| 367 |
* Retrieval over programming Q&A and technical questions
|
| 368 |
* Local semantic code search systems
|
| 369 |
* RAG systems over codebases and developer documentation
|
| 370 |
|
| 371 |
Example use cases include indexing functions, snippets, programming solutions,
|
| 372 |
-
StackOverflow-style answers, code
|
| 373 |
-
examples.
|
| 374 |
|
| 375 |
## Limitations
|
| 376 |
|
| 377 |
-
*
|
| 378 |
-
|
| 379 |
-
* Inputs longer than 1,024 tokens are truncated
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
* MTEB(Code, v1) is largely in-domain for this model (8% zero-shot). On code
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
* Performance may vary by programming language, query style, and the
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
retrieval path — though, as the [head-to-head](#head-to-head-vs-lateon-code)
|
| 392 |
-
shows, single-vector `NightOwl` still leads on code-edit and code-to-code
|
| 393 |
-
retrieval.
|
| 394 |
|
| 395 |
## Recommended Indexing Settings
|
| 396 |
|
|
@@ -402,14 +327,14 @@ embeddings = model.encode(texts, normalize_embeddings=True)
|
|
| 402 |
|
| 403 |
With normalized embeddings, dot product is equivalent to cosine similarity.
|
| 404 |
|
| 405 |
-
For codebase search, indexing function-level or class-level chunks
|
| 406 |
-
|
| 407 |
-
|
| 408 |
|
| 409 |
## Citation
|
| 410 |
|
| 411 |
-
If you use this model, please cite it together with the base model and
|
| 412 |
-
|
| 413 |
|
| 414 |
```bibtex
|
| 415 |
@misc{nightowl_codeembedding,
|
|
|
|
| 19 |
|
| 20 |
# NightOwl-CodeEmbedding 🦉
|
| 21 |
|
| 22 |
+
`NightOwl-CodeEmbedding` is a compact, 768-dimensional dense embedding model built for
|
| 23 |
+
code retrieval, code-edit retrieval, and technical question answering.
|
|
|
|
| 24 |
|
| 25 |
+
It is fine-tuned from [`Shuu12121/NightOwl`](https://huggingface.co/Shuu12121/NightOwl),
|
| 26 |
+
a ModernBERT-based code encoder. The model uses CLS pooling with cosine similarity and
|
|
|
|
| 27 |
does **not** require `query:` / `passage:` style prefixes.
|
| 28 |
|
| 29 |
## Highlights
|
| 30 |
|
| 31 |
* Compact (150.8M parameters) yet competitive on CoIR-style code retrieval benchmarks
|
| 32 |
+
* Ranks **18th out of 241 models overall** on the
|
| 33 |
+
[MTEB(Code, v1)](https://huggingface.co/spaces/mteb/leaderboard) leaderboard, and is
|
| 34 |
+
the **top-scoring dense single-vector model under 300M parameters** among scored
|
| 35 |
+
entries — ahead of many models an order of magnitude larger
|
| 36 |
+
(see [Leaderboard Standing](#leaderboard-standing))
|
| 37 |
+
* Standard single-vector retrieval: one 768-d vector per document and plain
|
| 38 |
+
dot-product / cosine search, so it drops straight into any existing vector-database
|
| 39 |
+
stack
|
| 40 |
+
* Covers **eight programming languages**: the six CodeSearchNet languages plus Rust
|
| 41 |
+
and TypeScript
|
| 42 |
+
* Handles a broad range of retrieval scenarios: NL-to-code search, code-to-code
|
| 43 |
+
retrieval, **code-edit retrieval**, and technical QA
|
| 44 |
* Trained with hard negatives mined by `Qwen/Qwen3-Embedding-0.6B`
|
| 45 |
(15 hard negatives per anchor)
|
| 46 |
+
* Decontaminated against the CodeSearchNet test splits and the
|
| 47 |
CodeEditSearchRetrieval benchmark (see [Data Decontamination](#data-decontamination))
|
| 48 |
+
* Drop-in compatible with `sentence-transformers`; Apache-2.0 licensed
|
| 49 |
|
| 50 |
## Supported Languages
|
| 51 |
|
|
|
|
|
|
|
|
|
|
| 52 |
* Go, Java, JavaScript, PHP, Python, Ruby (CodeSearchNet languages)
|
| 53 |
* **Rust, TypeScript** (additional)
|
| 54 |
|
| 55 |
+
Performance on languages outside this set is untested and may vary.
|
| 56 |
|
| 57 |
## Usage
|
| 58 |
|
|
|
|
| 93 |
|
| 94 |
## MTEB Results
|
| 95 |
|
| 96 |
+
The model was evaluated with MTEB on code-related retrieval and technical QA tasks.
|
|
|
|
| 97 |
|
| 98 |
Evaluation setup:
|
| 99 |
|
|
|
|
| 122 |
| **Macro average, all 12 tasks** | | **0.70907** |
|
| 123 |
| **CoIR macro average, 10 tasks** | | **0.68684** |
|
| 124 |
|
| 125 |
+
¹ `CodeEditSearchRetrieval` does not provide a standard `test` split in MTEB, so the
|
| 126 |
+
official `train` split is used for evaluation. These examples were **not** used for
|
| 127 |
+
fine-tuning. See [Data Decontamination](#data-decontamination).
|
|
|
|
| 128 |
|
| 129 |
### Leaderboard Standing
|
| 130 |
|
| 131 |
On the public [MTEB(Code, v1)](https://huggingface.co/spaces/mteb/leaderboard)
|
| 132 |
+
leaderboard, the model's task-mean score (70.91, i.e. the 12-task macro average above
|
| 133 |
+
×100) places it as follows:
|
| 134 |
|
| 135 |
+
* **#18 of 241 models overall**, ahead of many models an order of magnitude larger
|
|
|
|
| 136 |
* **#6 of 155 among sub-1B-parameter dense single-vector models** — and the
|
| 137 |
+
**smallest model in that top six**. The five models ranked above it
|
| 138 |
+
(`F2LLM-v2-0.6B/330M`, `pplx-embed-v1-0.6b`, `C2LLM-0.5B`, `Qwen3-Embedding-0.6B`)
|
| 139 |
+
are all roughly 0.33–0.6B parameters, i.e. 2–4× larger.
|
| 140 |
+
* **#1 among ranked dense single-vector models under 300M parameters**
|
| 141 |
+
(the leaderboard's small-model view)
|
| 142 |
+
|
| 143 |
+
> **Reading the numbers fairly.** MTEB(Code, v1) reports a *zero-shot %* for each
|
| 144 |
+
> model — the fraction of leaderboard tasks the model was *not* trained on.
|
| 145 |
+
> `NightOwl-CodeEmbedding` is **8%** zero-shot: it was trained on most of these task
|
| 146 |
+
> families, so its score reflects strong **in-domain** retrieval rather than zero-shot
|
| 147 |
+
> transfer. Models marked **100%** (e.g. `embeddinggemma-300m`, the
|
| 148 |
+
> `granite-embedding` r2 family, `Qwen3-Embedding`) are evaluated fully out-of-domain,
|
| 149 |
+
> so raw score comparisons across rows with different zero-shot % are not
|
| 150 |
+
> apples-to-apples. The fairest direct comparisons are to other code-specialized
|
| 151 |
+
> models at similar zero-shot levels (e.g. the `F2LLM` / `C2LLM` families at 8–58%).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
### Comparison with similar-sized models
|
| 154 |
|
| 155 |
+
The table below compares `NightOwl-CodeEmbedding` with other compact **dense
|
| 156 |
+
single-vector (bi-encoder)** models on MTEB(Code, v1), with a size ladder of larger
|
| 157 |
+
single-vector models for reference. Score is the leaderboard task mean (higher is
|
| 158 |
+
better); the *Zero-shot* column is the share of tasks the model did not train on.
|
| 159 |
+
|
| 160 |
+
| Model | Params | Emb. dim | Max tokens | Zero-shot | MTEB(Code, v1) ↑ |
|
| 161 |
+
| ---------------------------------------------------- | ------: | -------- | ---------: | --------: | ---------------: |
|
| 162 |
+
| **`NightOwl-CodeEmbedding`** (this model) | 150.8M | 768 | 1,024 | 8% | **70.91** |
|
| 163 |
+
| `codefuse-ai/F2LLM-v2-160M` | 159M | 640 | 40,960 | 58% | 70.38 |
|
| 164 |
+
| `google/embeddinggemma-300m` | 308M | 768 | 2,048 | 100% | 68.76 |
|
| 165 |
+
| `codefuse-ai/F2LLM-v2-80M` | 80M | 320 | 40,960 | 58% | 67.97 |
|
| 166 |
+
| `ibm-granite/granite-embedding-311m-multilingual-r2` | 312M | 768 | 8,192 | 100% | 63.84 |
|
| 167 |
+
| _Larger single-vector reference (size ladder)_ | | | | | |
|
| 168 |
+
| `codefuse-ai/F2LLM-v2-0.6B` (#1 sub-1B) | 596M | 1,024 | 40,960 | 58% | 77.41 |
|
| 169 |
+
| `Qwen/Qwen3-Embedding-0.6B` | 596M | 1,024 | 32,768 | 100% | 75.42 |
|
| 170 |
+
| `codefuse-ai/F2LLM-v2-14B` (#1 overall) | 13.99B | 5,120 | 40,960 | 58% | 80.75 |
|
|
|
|
|
|
|
| 171 |
|
| 172 |
Takeaways:
|
| 173 |
|
| 174 |
+
* Among compact single-vector dense models, `NightOwl-CodeEmbedding` is the strongest
|
| 175 |
+
entry in the leaderboard's small-model view while also being one of the smallest,
|
| 176 |
+
edging out `F2LLM-v2-160M` and clearly ahead of `embeddinggemma-300m`.
|
| 177 |
+
* The sub-1B leaders (`F2LLM-v2-0.6B`, `Qwen3-Embedding-0.6B`) score ~4–6.5 points
|
| 178 |
+
higher but are ~4× the parameter count with larger embedding dimensions, which
|
| 179 |
+
directly increases index size and inference cost.
|
| 180 |
+
* The 14B model at the top of the overall board is ~10 points higher but ~93× larger —
|
| 181 |
+
a different deployment cost regime entirely.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
## Base Model: the NightOwl Backbone
|
| 184 |
|
| 185 |
`NightOwl-CodeEmbedding` is fine-tuned from
|
| 186 |
+
[`Shuu12121/NightOwl`](https://huggingface.co/Shuu12121/NightOwl), a ModernBERT-style
|
| 187 |
+
code encoder that was **pre-trained from scratch** — tokenizer included — rather than
|
| 188 |
+
adapted from a general-purpose checkpoint. The whole stack, from tokenization to the
|
| 189 |
+
pre-training objective, is designed around code.
|
| 190 |
+
|
| 191 |
+
**Code-aware tokenizer.** NightOwl uses a custom 50,368-token BPE tokenizer in which
|
| 192 |
+
whitespace is tokenized **independently** of adjacent words, so indentation gets its
|
| 193 |
+
own tokens instead of being merged into "leading-whitespace + word" pieces. In code,
|
| 194 |
+
the same identifier recurs at many indentation depths; folding whitespace into those
|
| 195 |
+
pieces would waste large parts of the vocabulary on near-duplicate "indent + token"
|
| 196 |
+
variants. Keeping whitespace separate lets the fixed vocabulary budget cover more
|
| 197 |
+
genuinely distinct subwords while still representing indentation faithfully — which
|
| 198 |
+
matters for whitespace-significant languages such as Python.
|
|
|
|
|
|
|
| 199 |
|
| 200 |
**Two-phase pre-training with line-level masking.** NightOwl is trained with
|
| 201 |
masked-language modeling (`mlm_probability = 0.3`) in two phases:
|
| 202 |
|
| 203 |
* *Phase 1 — mixed pre-training:* standard random-token MLM over code, natural
|
| 204 |
+
language, and technical documentation (producing `NightOwl-Pre`).
|
| 205 |
+
* *Phase 2 — code-only continuation:* **line-level MLM**, where entire source-code
|
| 206 |
+
lines are masked instead of random tokens. This aligns the pre-training objective
|
| 207 |
+
with code search and retrieval, where the unit of meaning is closer to a line or
|
| 208 |
+
statement than an isolated token. The recommended `NightOwl` checkpoint is this
|
| 209 |
+
Phase-2 result.
|
| 210 |
|
| 211 |
Backbone architecture (base):
|
| 212 |
|
|
|
|
| 214 |
| ------------------------------ | ----------------------------------------------------- |
|
| 215 |
| Architecture | ModernBERT (alternating local/global attention, RoPE) |
|
| 216 |
| Parameters | ≈150M |
|
| 217 |
+
| `hidden_size` / layers / heads | 768 / 19 / 12 |
|
| 218 |
+
| Vocabulary | 50,368 (custom code BPE) |
|
| 219 |
| Max sequence length | 1,024 (Phase 1) → 2,048 (Phase 2) |
|
| 220 |
|
| 221 |
Pre-training data mixes `bigcode/starcoder2data-extras` (Kaggle notebooks,
|
| 222 |
+
StackOverflow threads, GitHub issues, technical documentation, …) with whole-file
|
| 223 |
+
source from `Shuu12121/github-file-programs-dataset` across the eight supported
|
| 224 |
+
languages. Long examples are split into chunks so all tokens are used rather than
|
| 225 |
+
truncated.
|
| 226 |
|
| 227 |
As a raw backbone — before any embedding fine-tuning — NightOwl reaches **0.8436
|
| 228 |
average MRR** on MTEB `CodeSearchNetRetrieval` under a fixed SentenceTransformer
|
| 229 |
+
fine-tuning protocol, ahead of CodeBERT-base (0.7944), GraphCodeBERT-base (0.8325),
|
| 230 |
+
UniXCoder-base (0.8003), and ModernBERT-base (0.8182) evaluated the same way.
|
| 231 |
+
`NightOwl-CodeEmbedding` builds the retrieval model described in this card on top of
|
| 232 |
+
that backbone.
|
| 233 |
|
| 234 |
## Training
|
| 235 |
|
| 236 |
+
The model was trained with `CachedMultipleNegativesRankingLoss` using bidirectional
|
| 237 |
+
query-to-document and document-to-query objectives.
|
| 238 |
+
|
| 239 |
+
| Property | Value |
|
| 240 |
+
| -------------------------- | ------------------------------------ |
|
| 241 |
+
| Training samples | 2,534,400 |
|
| 242 |
+
| Positives per anchor | 1 |
|
| 243 |
+
| Negatives per anchor | 15 |
|
| 244 |
+
| Loss | `CachedMultipleNegativesRankingLoss` |
|
| 245 |
+
| Objective | Bidirectional retrieval training |
|
| 246 |
+
| Hard-negative mining model | `Qwen/Qwen3-Embedding-0.6B` |
|
| 247 |
+
| Epochs | 1 |
|
| 248 |
+
| Learning rate | 6e-5 |
|
| 249 |
+
| Batch size | 1024 |
|
| 250 |
|
| 251 |
### Training Data
|
| 252 |
|
| 253 |
The training data is a mixture of:
|
| 254 |
|
| 255 |
+
1. **Public code-retrieval datasets** covering the following CoIR task families:
|
| 256 |
+
AppsRetrieval, COIRCodeSearchNetRetrieval, CodeFeedbackMT, CodeFeedbackST,
|
| 257 |
+
CodeSearchNetCCRetrieval, CodeSearchNetRetrieval, CodeTransOceanContest,
|
| 258 |
+
CodeTransOceanDL, CosQA, StackOverflowQA, and SyntheticText2SQL.
|
| 259 |
+
2. **Custom code–comment pair data**: code snippets paired with natural-language
|
| 260 |
+
description comments across the eight supported languages.
|
| 261 |
+
3. **Code-edit data** derived from `commitpackft`, pairing edit intents with code
|
| 262 |
+
changes.
|
| 263 |
+
|
| 264 |
+
All datasets were constructed as hard-negative retrieval datasets: for each anchor,
|
| 265 |
+
one positive and fifteen hard negatives. Hard negatives were mined with
|
| 266 |
+
[`Qwen/Qwen3-Embedding-0.6B`](https://huggingface.co/Qwen/Qwen3-Embedding-0.6B), which
|
| 267 |
+
retrieves semantically similar but non-matching candidates — considerably harder than
|
| 268 |
+
random negatives. The mining model is used only during dataset construction and is not
|
| 269 |
+
required at inference time.
|
| 270 |
+
|
| 271 |
+
This setup is intended to sharpen discrimination between code snippets, programming
|
| 272 |
+
questions, edit examples, and technically similar retrieval candidates.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
|
| 274 |
### Data Decontamination
|
| 275 |
|
| 276 |
+
To reduce benchmark contamination, the following overlaps were removed from the
|
| 277 |
+
training data **before** training:
|
| 278 |
|
| 279 |
+
* Overlaps between the custom code–comment pair data and the **CodeSearchNet test
|
| 280 |
+
split**
|
| 281 |
* Overlaps between the `commitpackft`-derived code-edit data and the
|
| 282 |
**CodeEditSearchRetrieval** benchmark evaluation data
|
| 283 |
|
| 284 |
+
For `CodeEditSearchRetrieval`, note that MTEB labels the evaluation split `train`.
|
| 285 |
+
This is just the official split name for the task; the evaluated examples were not
|
| 286 |
+
included in this model's fine-tuning data. The reported score should therefore be read
|
| 287 |
+
as **in-domain generalization on held-out benchmark examples** — not training-set
|
| 288 |
+
performance, though, given the in-domain training distribution, not strictly zero-shot
|
| 289 |
+
performance either.
|
|
|
|
| 290 |
|
| 291 |
## Intended Use
|
| 292 |
|
|
|
|
|
|
|
| 293 |
* Natural language to code search
|
| 294 |
+
* Code-to-code retrieval and similar-function search
|
| 295 |
* Code-edit retrieval (matching edit intents to code changes)
|
| 296 |
* Retrieval over programming Q&A and technical questions
|
| 297 |
* Local semantic code search systems
|
| 298 |
* RAG systems over codebases and developer documentation
|
| 299 |
|
| 300 |
Example use cases include indexing functions, snippets, programming solutions,
|
| 301 |
+
StackOverflow-style answers, code-review examples, and edit-related code examples.
|
|
|
|
| 302 |
|
| 303 |
## Limitations
|
| 304 |
|
| 305 |
+
* Specialized for code-related retrieval; may underperform general-purpose text
|
| 306 |
+
embedding models on unrelated natural-language tasks.
|
| 307 |
+
* Inputs longer than 1,024 tokens are truncated — a shorter context window than some
|
| 308 |
+
competitors (e.g. the 8K+ token `F2LLM` and `granite` models), so very long files
|
| 309 |
+
must be chunked.
|
| 310 |
+
* MTEB(Code, v1) is largely in-domain for this model (8% zero-shot). On code domains,
|
| 311 |
+
query styles, or languages far from the training distribution, expect lower
|
| 312 |
+
performance than the leaderboard numbers suggest.
|
| 313 |
+
* Performance may vary by programming language, query style, and the granularity of
|
| 314 |
+
indexed code chunks; languages outside the eight supported ones are untested.
|
| 315 |
+
* The model produces dense single-vector embeddings. For applications that need very
|
| 316 |
+
fine-grained token-level matching, other retrieval approaches — such as
|
| 317 |
+
late-interaction (multi-vector) models or cross-encoder rerankers — may be worth
|
| 318 |
+
considering, with different trade-offs in index size and retrieval infrastructure.
|
|
|
|
|
|
|
|
|
|
| 319 |
|
| 320 |
## Recommended Indexing Settings
|
| 321 |
|
|
|
|
| 327 |
|
| 328 |
With normalized embeddings, dot product is equivalent to cosine similarity.
|
| 329 |
|
| 330 |
+
For codebase search, indexing function-level or class-level chunks usually works best.
|
| 331 |
+
Very long files may exceed the 1,024-token context limit and should be split into
|
| 332 |
+
smaller semantic chunks.
|
| 333 |
|
| 334 |
## Citation
|
| 335 |
|
| 336 |
+
If you use this model, please cite it together with the base model and Sentence
|
| 337 |
+
Transformers.
|
| 338 |
|
| 339 |
```bibtex
|
| 340 |
@misc{nightowl_codeembedding,
|