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55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
---
dataset_info:
- config_name: documents
  features:
  - name: document_id
    dtype: int64
  - name: document
    dtype: string
  splits:
  - name: CodeEditSearch_c
    num_bytes: 2022886
    num_examples: 4217
  - name: CodeEditSearch_cpp
    num_bytes: 924692
    num_examples: 1691
  - name: CodeEditSearch_go
    num_bytes: 1573139
    num_examples: 2870
  - name: CodeEditSearch_java
    num_bytes: 7768990
    num_examples: 9488
  - name: CodeEditSearch_javascript
    num_bytes: 29411833
    num_examples: 46509
  - name: CodeEditSearch_php
    num_bytes: 10413481
    num_examples: 16429
  - name: CodeEditSearch_python
    num_bytes: 22801658
    num_examples: 36641
  - name: CodeEditSearch_ruby
    num_bytes: 30676155
    num_examples: 55352
  - name: CodeEditSearch_rust
    num_bytes: 273155
    num_examples: 525
  - name: CodeEditSearch_scala
    num_bytes: 1175992
    num_examples: 1943
  - name: CodeEditSearch_shell
    num_bytes: 10414614
    num_examples: 21888
  - name: CodeEditSearch_swift
    num_bytes: 1289457
    num_examples: 1851
  - name: CodeEditSearch_typescript
    num_bytes: 2278991
    num_examples: 3332
  download_size: 56331863
  dataset_size: 121025043
- config_name: queries
  features:
  - name: query_id
    dtype: int64
  - name: query
    dtype: string
  splits:
  - name: CodeEditSearch_c
    num_bytes: 448349
    num_examples: 3806
  - name: CodeEditSearch_cpp
    num_bytes: 194794
    num_examples: 1748
  - name: CodeEditSearch_go
    num_bytes: 239010
    num_examples: 2805
  - name: CodeEditSearch_java
    num_bytes: 652433
    num_examples: 8320
  - name: CodeEditSearch_javascript
    num_bytes: 2712096
    num_examples: 36475
  - name: CodeEditSearch_php
    num_bytes: 1051554
    num_examples: 13993
  - name: CodeEditSearch_python
    num_bytes: 2299822
    num_examples: 28581
  - name: CodeEditSearch_ruby
    num_bytes: 3737516
    num_examples: 42719
  - name: CodeEditSearch_rust
    num_bytes: 41485
    num_examples: 532
  - name: CodeEditSearch_scala
    num_bytes: 146745
    num_examples: 1962
  - name: CodeEditSearch_shell
    num_bytes: 1521467
    num_examples: 18008
  - name: CodeEditSearch_swift
    num_bytes: 133337
    num_examples: 1869
  - name: CodeEditSearch_typescript
    num_bytes: 218320
    num_examples: 3216
  download_size: 8848681
  dataset_size: 13396928
- config_name: scores
  features:
  - name: query_id
    dtype: int64
  - name: document_ids
    list: int64
  - name: scores
    list: float64
  - name: rerank_scores
    list: float64
  splits:
  - name: CodeEditSearch_c
    num_bytes: 1080904
    num_examples: 3806
  - name: CodeEditSearch_cpp
    num_bytes: 496432
    num_examples: 1748
  - name: CodeEditSearch_go
    num_bytes: 796620
    num_examples: 2805
  - name: CodeEditSearch_java
    num_bytes: 2362880
    num_examples: 8320
  - name: CodeEditSearch_javascript
    num_bytes: 10358900
    num_examples: 36475
  - name: CodeEditSearch_php
    num_bytes: 3974012
    num_examples: 13993
  - name: CodeEditSearch_python
    num_bytes: 8117004
    num_examples: 28581
  - name: CodeEditSearch_ruby
    num_bytes: 12132196
    num_examples: 42719
  - name: CodeEditSearch_rust
    num_bytes: 151088
    num_examples: 532
  - name: CodeEditSearch_scala
    num_bytes: 557208
    num_examples: 1962
  - name: CodeEditSearch_shell
    num_bytes: 5114272
    num_examples: 18008
  - name: CodeEditSearch_swift
    num_bytes: 530796
    num_examples: 1869
  - name: CodeEditSearch_typescript
    num_bytes: 913344
    num_examples: 3216
  download_size: 45294106
  dataset_size: 46585656
configs:
- config_name: documents
  data_files:
  - split: CodeEditSearch_c
    path: documents/CodeEditSearch_c-*
  - split: CodeEditSearch_cpp
    path: documents/CodeEditSearch_cpp-*
  - split: CodeEditSearch_go
    path: documents/CodeEditSearch_go-*
  - split: CodeEditSearch_java
    path: documents/CodeEditSearch_java-*
  - split: CodeEditSearch_javascript
    path: documents/CodeEditSearch_javascript-*
  - split: CodeEditSearch_php
    path: documents/CodeEditSearch_php-*
  - split: CodeEditSearch_python
    path: documents/CodeEditSearch_python-*
  - split: CodeEditSearch_ruby
    path: documents/CodeEditSearch_ruby-*
  - split: CodeEditSearch_rust
    path: documents/CodeEditSearch_rust-*
  - split: CodeEditSearch_scala
    path: documents/CodeEditSearch_scala-*
  - split: CodeEditSearch_shell
    path: documents/CodeEditSearch_shell-*
  - split: CodeEditSearch_swift
    path: documents/CodeEditSearch_swift-*
  - split: CodeEditSearch_typescript
    path: documents/CodeEditSearch_typescript-*
- config_name: queries
  data_files:
  - split: CodeEditSearch_c
    path: queries/CodeEditSearch_c-*
  - split: CodeEditSearch_cpp
    path: queries/CodeEditSearch_cpp-*
  - split: CodeEditSearch_go
    path: queries/CodeEditSearch_go-*
  - split: CodeEditSearch_java
    path: queries/CodeEditSearch_java-*
  - split: CodeEditSearch_javascript
    path: queries/CodeEditSearch_javascript-*
  - split: CodeEditSearch_php
    path: queries/CodeEditSearch_php-*
  - split: CodeEditSearch_python
    path: queries/CodeEditSearch_python-*
  - split: CodeEditSearch_ruby
    path: queries/CodeEditSearch_ruby-*
  - split: CodeEditSearch_rust
    path: queries/CodeEditSearch_rust-*
  - split: CodeEditSearch_scala
    path: queries/CodeEditSearch_scala-*
  - split: CodeEditSearch_shell
    path: queries/CodeEditSearch_shell-*
  - split: CodeEditSearch_swift
    path: queries/CodeEditSearch_swift-*
  - split: CodeEditSearch_typescript
    path: queries/CodeEditSearch_typescript-*
- config_name: scores
  data_files:
  - split: CodeEditSearch_c
    path: scores/CodeEditSearch_c-*
  - split: CodeEditSearch_cpp
    path: scores/CodeEditSearch_cpp-*
  - split: CodeEditSearch_go
    path: scores/CodeEditSearch_go-*
  - split: CodeEditSearch_java
    path: scores/CodeEditSearch_java-*
  - split: CodeEditSearch_javascript
    path: scores/CodeEditSearch_javascript-*
  - split: CodeEditSearch_php
    path: scores/CodeEditSearch_php-*
  - split: CodeEditSearch_python
    path: scores/CodeEditSearch_python-*
  - split: CodeEditSearch_ruby
    path: scores/CodeEditSearch_ruby-*
  - split: CodeEditSearch_rust
    path: scores/CodeEditSearch_rust-*
  - split: CodeEditSearch_scala
    path: scores/CodeEditSearch_scala-*
  - split: CodeEditSearch_shell
    path: scores/CodeEditSearch_shell-*
  - split: CodeEditSearch_swift
    path: scores/CodeEditSearch_swift-*
  - split: CodeEditSearch_typescript
    path: scores/CodeEditSearch_typescript-*
---


## Overview 

This dataset is composed of high quality code-edit retrieval data with mined hard negatives annotated with bi-encoder and cross-encoder scores. It can be used to train a strong code retrieval model by itself but is better used after a large-scale contrastive pre-training, for example using the **[CoRNStack](https://huggingface.co/datasets/lightonai/cornstack)** dataset.
The negatives were mined following the NV-Retriever setup: the closest documents to each query are mined as negatives, and false negatives are filtered out if their bi-encoder similarity is higher than a percentage of the query-positive similarity score.
This dataset is a ready-to-train filtered version of the CodeEditSearch splits of [embeddings-fine-tuning-multilingual-unfiltered](https://huggingface.co/datasets/lightonai/embeddings-fine-tuning-multilingual-unfiltered): we keep the 10 hardest negatives per sample after NV-Retriever filtering with a threshold of 0.95, and remove the samples with less than 10 valid negatives as they may contain weakly annotated pairs.
The data originates from [CodeEditSearchTrain](https://huggingface.co/datasets/lightonai/CodeEditSearchTrain), from which we keep 13 of the 47 covered programming languages. Each sample contains the query, the positive and 10 mined hard negatives. The model used for mining is [gte-modernbert-base](https://huggingface.co/Alibaba-NLP/gte-modernbert-base), and all the samples were annotated with the cross-encoder [mxbai-rerank-large-v2](https://huggingface.co/mixedbread-ai/mxbai-rerank-large-v2), enabling knowledge distillation training on top of contrastive learning.

For more information, please read our [multilingual models blog post](https://huggingface.co/blog/lightonai/mdenseon-mlateon), our [English models blog post](https://huggingface.co/blog/lightonai/denseon-lateon) and our [paper](https://arxiv.org/abs/2607.27178).

## How to use

The negatives are already mined and filtered, so using the data as contrastive data in either [sentence-transformers](https://www.sbert.net) or [PyLate](https://lightonai.github.io/pylate/) only requires joining the three subsets into the `(query, positive, negative_0, negative_1, ..., negative_n)` format. The cross-encoder `rerank_scores` of the kept documents are carried along in the same order as the columns, so they can be used as teacher scores by a knowledge distillation loss (a KL-divergence between the student and teacher relevance distributions, for instance) on top of the contrastive loss:

<details>
<summary>
  Python code to cast to contrastive format
</summary>


```python
import datasets


class KDToContrastive:
    """Maps the scores table of a split to the contrastive knowledge distillation format.

    Parameters
    ----------
    queries
        Queries subset of the split.
    documents
        Documents subset of the split.
    num_negatives
        Number of hard negatives to keep per query, out of the 10 stored ones.
    """

    def __init__(
        self,
        queries: datasets.Dataset,
        documents: datasets.Dataset,
        num_negatives: int = 10,
    ) -> None:
        self.queries = dict(zip(queries["query_id"], queries["query"]))
        self.documents = dict(zip(documents["document_id"], documents["document"]))
        self.num_negatives = num_negatives

    def map_to_query_positive_negatives(self, example) -> dict:
        # document_ids, scores and rerank_scores are all ordered [positive, negative_0, ..., negative_9]
        document_ids = example["document_ids"][: self.num_negatives + 1]
        return {
            "query": self.queries[example["query_id"]],
            "positive": self.documents[document_ids[0]],
            "teacher_scores": example["rerank_scores"][: self.num_negatives + 1],
            **{
                f"negative_{negative}": self.documents[document_id]
                for negative, document_id in enumerate(document_ids[1:])
            },
        }


def load_train_datasets(num_negatives: int = 10) -> datasets.DatasetDict:
    """Load every split as a (query, positive, negatives, teacher_scores) dataset."""
    repo = "lightonai/embeddings-fine-tuning-filtered-code-edit"
    splits = [
        "CodeEditSearch_c", "CodeEditSearch_cpp", "CodeEditSearch_go", "CodeEditSearch_java",
        "CodeEditSearch_javascript", "CodeEditSearch_php", "CodeEditSearch_python",
        "CodeEditSearch_ruby", "CodeEditSearch_rust", "CodeEditSearch_scala",
        "CodeEditSearch_shell", "CodeEditSearch_swift", "CodeEditSearch_typescript",
    ]

    train_dataset = datasets.DatasetDict()
    for split in splits:
        # data_files restricts the download to the split being processed, hence skipping the checks on the other splits
        load = lambda config: datasets.load_dataset(
            repo,
            name=config,
            data_files=f"{config}/{split}-*",
            split="train",
            verification_mode="no_checks",
        )
        scores = load("scores")
        processor = KDToContrastive(
            queries=load("queries"), documents=load("documents"), num_negatives=num_negatives
        )
        train_dataset[split] = scores.map(
            processor.map_to_query_positive_negatives,
            remove_columns=scores.column_names,
            desc=f"Creating the contrastive dataset ({split})",
        )
    return train_dataset


train_dataset = load_train_datasets()
print(train_dataset)
```
</details>


## Dataset structure

The dataset is composed of the 13 per-programming-language splits of CodeEditSearch (C, C++, Go, Java, JavaScript, PHP, Python, Ruby, Rust, Scala, Shell, Swift, TypeScript), defined by the `splits` parameters.
Each split contains 3 `subsets`, one containing the queries, one containing the documents and one joining tables also containing the corresponding pairwise query-documents scores.

### Documents

| Column        | Type   | Description                                                  |
|---------------|--------|--------------------------------------------------------------|
| `document_id` | int64  | Unique identifier of the document within the split.          |
| `document`    | string | Raw text of the document/code snippet.                       |

| Split | Rows |
|------------|-------:|
| CodeEditSearch_c | 4.2k |
| CodeEditSearch_cpp | 1.7k |
| CodeEditSearch_go | 2.9k |
| CodeEditSearch_java | 9.5k |
| CodeEditSearch_javascript | 46.5k |
| CodeEditSearch_php | 16.4k |
| CodeEditSearch_python | 36.6k |
| CodeEditSearch_ruby | 55.4k |
| CodeEditSearch_rust | 525 |
| CodeEditSearch_scala | 1.9k |
| CodeEditSearch_shell | 21.9k |
| CodeEditSearch_swift | 1.9k |
| CodeEditSearch_typescript | 3.3k |
| **Total**  | **203k** |

### Queries

| Column     | Type   | Description                                          |
|------------|--------|------------------------------------------------------|
| `query_id` | int64  | Unique identifier of the query within the split.     |
| `query`    | string | Raw text of the query.                               |


| Split | Rows |
|------------|-------:|
| CodeEditSearch_c | 3.8k |
| CodeEditSearch_cpp | 1.7k |
| CodeEditSearch_go | 2.8k |
| CodeEditSearch_java | 8.3k |
| CodeEditSearch_javascript | 36.5k |
| CodeEditSearch_php | 14k |
| CodeEditSearch_python | 28.6k |
| CodeEditSearch_ruby | 42.7k |
| CodeEditSearch_rust | 532 |
| CodeEditSearch_scala | 2.0k |
| CodeEditSearch_shell | 18k |
| CodeEditSearch_swift | 1.9k |
| CodeEditSearch_typescript | 3.2k |
| **Total**  | **164k** |

### Scores


| Column          | Type        | Description                                                                                                                                                              |
|-----------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `query_id`      | int64       | Identifier joining back to the corresponding row in `queries`.                                                                                                           |
| `document_ids`  | list[int64] | List of document IDs (joining back to `documents`). The first element is the positive document, followed by the 10 hardest negatives kept after NV-Retriever filtering. |
| `scores`        | list[float] | Bi-encoder relevance scores for each document w.r.t the query, in the same order as `document_ids`. Can be used for knowledge distillation.                              |
| `rerank_scores` | list[float] | Cross-encoder scores from [mxbai-rerank-large-v2](https://huggingface.co/mixedbread-ai/mxbai-rerank-large-v2) for each document w.r.t the query, in the same order as `document_ids`. Can be used for knowledge distillation. |

| Split | Rows |
|------------|-------:|
| CodeEditSearch_c | 3.8k |
| CodeEditSearch_cpp | 1.7k |
| CodeEditSearch_go | 2.8k |
| CodeEditSearch_java | 8.3k |
| CodeEditSearch_javascript | 36.5k |
| CodeEditSearch_php | 14k |
| CodeEditSearch_python | 28.6k |
| CodeEditSearch_ruby | 42.7k |
| CodeEditSearch_rust | 532 |
| CodeEditSearch_scala | 2.0k |
| CodeEditSearch_shell | 18k |
| CodeEditSearch_swift | 1.9k |
| CodeEditSearch_typescript | 3.2k |
| **Total**  | **164k** |

### Token length distributions

Token counts are computed with the [mmBERT-base](https://huggingface.co/jhu-clsp/mmBERT-base) tokenizer. For readability, each histogram is truncated after the last bin containing at least 5 samples; the statistics reported in the boxes (including the maximum) are computed on the full data.

![Per-split token length distributions of the queries](https://huggingface.co/datasets/lightonai/embeddings-fine-tuning-filtered-code-edit/resolve/main/figures/code-edit_queries.png#hf-light-mode-only)
![Per-split token length distributions of the queries](https://huggingface.co/datasets/lightonai/embeddings-fine-tuning-filtered-code-edit/resolve/main/figures/code-edit_queries_dark.png#hf-dark-mode-only)

![Per-split token length distributions of the documents](https://huggingface.co/datasets/lightonai/embeddings-fine-tuning-filtered-code-edit/resolve/main/figures/code-edit_documents.png#hf-light-mode-only)
![Per-split token length distributions of the documents](https://huggingface.co/datasets/lightonai/embeddings-fine-tuning-filtered-code-edit/resolve/main/figures/code-edit_documents_dark.png#hf-dark-mode-only)

## Citation
If you are using this dataset, please consider citing our work
```bibtex
@misc{sourty2026denseonlateonfullyopen,
  title         = {DenseOn with the LateOn: Fully Open Dense and Late-Interaction Models for Multilingual, Long-Context, and Code Search},
  author        = {Raphaël Sourty and Antoine Chaffin and Paulo Roberto Moura Junior and Amélie Chatelain},
  year          = {2026},
  eprint        = {2607.27178},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CL},
  url           = {https://arxiv.org/abs/2607.27178},
}```