Datasets:

Modalities:
Text
Formats:
parquet
ArXiv:
License:
File size: 9,193 Bytes
df96913
7166a27
 
 
 
 
 
 
 
 
 
 
407e4f1
7166a27
 
 
 
 
 
 
 
17592f6
7166a27
 
 
 
 
 
 
 
 
 
35eea53
7166a27
 
 
 
 
 
 
 
96d5fd0
7166a27
 
 
 
 
 
 
 
 
 
2573e59
7166a27
 
 
 
 
 
 
 
f65ed00
7166a27
 
 
 
 
 
 
 
 
 
55700cd
7166a27
 
 
 
 
 
 
 
3077d4b
7166a27
 
 
 
 
 
 
 
 
 
38bf715
7166a27
 
 
 
 
 
 
 
fb34c24
7166a27
 
 
 
 
 
 
 
 
 
7a46fa9
7166a27
 
 
 
 
 
 
 
334ef2c
df96913
6a07ded
 
 
 
df96913
 
 
 
ea1ed6a
 
 
 
f7e432b
 
 
 
76c7189
 
 
 
6ec9964
 
 
 
d54686c
 
 
 
38816d4
 
 
 
118d4a2
 
 
 
f0743af
 
 
 
9742143
 
 
 
e1d3bb2
 
 
 
54840da
df96913
5b866df
1b1e352
19bec9a
 
514b94c
1b1e352
 
 
 
 
19bec9a
 
 
514b94c
1b1e352
0240b16
1b1e352
91570b3
 
1b1e352
514b94c
1b1e352
514b94c
1b1e352
 
 
514b94c
 
 
1b1e352
91570b3
1b1e352
c5ce71e
 
91570b3
c5ce71e
514b94c
 
91570b3
 
 
 
 
 
 
 
 
 
 
 
0240b16
 
91570b3
 
 
0240b16
91570b3
0240b16
91570b3
0240b16
 
 
91570b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b1e352
514b94c
1b1e352
 
 
 
5b866df
 
1b1e352
 
 
 
 
 
 
 
 
514b94c
1b1e352
 
 
5b866df
514b94c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0240b16
 
 
514b94c
9c9c366
 
514b94c
0240b16
 
 
 
 
91570b3
 
 
 
 
514b94c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
---
dataset_info:
- config_name: go-v1-hard-negatives-100k
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  - name: negs
    list: string
  splits:
  - name: train
    num_examples: 87536
- config_name: go-v1-pair-2M
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  splits:
  - name: train
    num_examples: 1532319
- config_name: java-v1-hard-negatives-100k
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  - name: negs
    list: string
  splits:
  - name: train
    num_examples: 80906
- config_name: java-v1-pair-2M
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  splits:
  - name: train
    num_examples: 1456651
- config_name: javascript-v1-hard-negatives-100k
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  - name: negs
    list: string
  splits:
  - name: train
    num_examples: 79484
- config_name: javascript-v1-pair-2M
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  splits:
  - name: train
    num_examples: 1298745
- config_name: php-v1-hard-negatives-100k
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  - name: negs
    list: string
  splits:
  - name: train
    num_examples: 74945
- config_name: php-v1-pair-2M
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  splits:
  - name: train
    num_examples: 1311302
- config_name: python-v1-hard-negatives-100k
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  - name: negs
    list: string
  splits:
  - name: train
    num_examples: 96670
- config_name: python-v1-pair-2M
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  splits:
  - name: train
    num_examples: 1779891
- config_name: ruby-v1-hard-negatives-100k
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  - name: negs
    list: string
  splits:
  - name: train
    num_examples: 67937
- config_name: ruby-v1-pair-2M
  features:
  - name: query
    dtype: string
  - name: pos
    dtype: string
  splits:
  - name: train
    num_examples: 1145414
configs:
- config_name: go-v1-hard-negatives-100k
  data_files:
  - split: train
    path: go-v1-hard-negatives-100k/train-*
- config_name: go-v1-pair-2M
  data_files:
  - split: train
    path: go-v1-pair-2M/train-*
- config_name: java-v1-hard-negatives-100k
  data_files:
  - split: train
    path: java-v1-hard-negatives-100k/train-*
- config_name: java-v1-pair-2M
  data_files:
  - split: train
    path: java-v1-pair-2M/train-*
- config_name: javascript-v1-hard-negatives-100k
  data_files:
  - split: train
    path: javascript-v1-hard-negatives-100k/train-*
- config_name: javascript-v1-pair-2M
  data_files:
  - split: train
    path: javascript-v1-pair-2M/train-*
- config_name: php-v1-hard-negatives-100k
  data_files:
  - split: train
    path: php-v1-hard-negatives-100k/train-*
- config_name: php-v1-pair-2M
  data_files:
  - split: train
    path: php-v1-pair-2M/train-*
- config_name: python-v1-hard-negatives-100k
  data_files:
  - split: train
    path: python-v1-hard-negatives-100k/train-*
- config_name: python-v1-pair-2M
  data_files:
  - split: train
    path: python-v1-pair-2M/train-*
- config_name: ruby-v1-hard-negatives-100k
  data_files:
  - split: train
    path: ruby-v1-hard-negatives-100k/train-*
- config_name: ruby-v1-pair-2M
  data_files:
  - split: train
    path: ruby-v1-pair-2M/train-*
license: apache-2.0
---
# cornstack-samples

🚧 This dataset is under active development and may change.

Filtered CoRNStack sample subsets for code retrieval training.

Source dataset and paper:
- CoRNStack collection: https://huggingface.co/collections/nomic-ai/cornstack
- CoRNStack paper: https://huggingface.co/papers/2412.01007

Note: the original CoRNStack collection is a much larger dataset family for code search training.
If you need large-scale data (not samples), please refer to the original CoRNStack collection above.

## What This Release Contains

This release keeps the original subset layout (6 languages x pair + hard-negatives) and applies deterministic rule-based filtering.

In this revision, query-level deduplication and positive-document (`pos`) deduplication are applied per subset.
For both rules, if duplicates exist, only the first row is kept.

## Config Layout And Schema

Each language is published as two configs with split `train`:
- `{lang}-v1-pair-2M`
- `{lang}-v1-hard-negatives-100k`

Schema:
- Pair configs: `query`, `pos`
- Hard-negative configs: `query`, `pos`, `negs` (list[string])

## Subsets And Row Counts (After Filter + Query Dedup + Pos Dedup)

Note: subset names keep the original `2M` / `100k` naming convention for compatibility, but
actual row counts vary by language and can be substantially lower after quality filtering and
deduplication.

| Subset (config name) | split | num_examples |
| --- | --- | ---: |
| `go-v1-pair-2M` | `train` | 1,532,319 |
| `go-v1-hard-negatives-100k` | `train` | 87,536 |
| `java-v1-pair-2M` | `train` | 1,456,651 |
| `java-v1-hard-negatives-100k` | `train` | 80,906 |
| `javascript-v1-pair-2M` | `train` | 1,298,745 |
| `javascript-v1-hard-negatives-100k` | `train` | 79,484 |
| `php-v1-pair-2M` | `train` | 1,311,302 |
| `php-v1-hard-negatives-100k` | `train` | 74,945 |
| `python-v1-pair-2M` | `train` | 1,779,891 |
| `python-v1-hard-negatives-100k` | `train` | 96,670 |
| `ruby-v1-pair-2M` | `train` | 1,145,414 |
| `ruby-v1-hard-negatives-100k` | `train` | 67,937 |

Total rows:
- Pair: 8,524,322
- Hard-negatives: 487,478
- Overall: 9,011,800

## Dedup Impact (Pos Dedup Stage)

The table below shows the `pos`-dedup impact on top of the previous filtered + query-deduped data.

| Subset | before | after | removed | removed_ratio |
| --- | ---: | ---: | ---: | ---: |
| `go-v1-pair-2M` | 1,541,111 | 1,532,319 | 8,792 | 0.57% |
| `go-v1-hard-negatives-100k` | 87,647 | 87,536 | 111 | 0.13% |
| `java-v1-pair-2M` | 1,491,655 | 1,456,651 | 35,004 | 2.35% |
| `java-v1-hard-negatives-100k` | 81,657 | 80,906 | 751 | 0.92% |
| `javascript-v1-pair-2M` | 1,310,965 | 1,298,745 | 12,220 | 0.93% |
| `javascript-v1-hard-negatives-100k` | 79,684 | 79,484 | 200 | 0.25% |
| `php-v1-pair-2M` | 1,343,442 | 1,311,302 | 32,140 | 2.39% |
| `php-v1-hard-negatives-100k` | 75,632 | 74,945 | 687 | 0.91% |
| `python-v1-pair-2M` | 1,807,480 | 1,779,891 | 27,589 | 1.53% |
| `python-v1-hard-negatives-100k` | 97,147 | 96,670 | 477 | 0.49% |
| `ruby-v1-pair-2M` | 1,175,219 | 1,145,414 | 29,805 | 2.54% |
| `ruby-v1-hard-negatives-100k` | 68,382 | 67,937 | 445 | 0.65% |

Stage totals:
- Pair removed by pos dedup: 145,550 (1.68%)
- Hard-negatives removed by pos dedup: 2,671 (0.54%)
- Overall removed by pos dedup: 148,221 (1.62%)

## Quick Usage

```python
from datasets import load_dataset

pair_ds = load_dataset("hotchpotch/cornstack-samples", "python-v1-pair-2M", split="train")
hard_ds = load_dataset("hotchpotch/cornstack-samples", "python-v1-hard-negatives-100k", split="train")

print(pair_ds.column_names, len(pair_ds))
print(hard_ds.column_names, len(hard_ds))
```

## License

This dataset follows CoRNStack and is released under **Apache-2.0**.

## Citation And Attribution

If you use this dataset, please cite and attribute CoRNStack:
- Paper: https://huggingface.co/papers/2412.01007
- Collection: https://huggingface.co/collections/nomic-ai/cornstack

## Noise Filtering Algorithm (Rule-based)

The following deterministic rules are applied before publishing this release.

1. Prefix-based noisy query removal
A row is dropped if `query` starts with any of the following prefixes:
- `TODO`
- `GET /`
- `POST /`
- `PUT /`
- `DELETE /`
- `Display a listing of the resource.`
- `Store a newly created resource in storage.`
- `Show the form for editing the specified resource.`
- `Update the specified resource in storage.`
- `Show the form for creating a new resource.`
- `Remove the specified resource from storage.`
- `Display the specified resource.`
- `Transform the resource into an array.`
- `Autogenerated method stub`
- `Auto generated`
- `this down() migration is autogenerated`
- `this up() migration is autogenerated`
- `"/ renamed from:"`
- `"/ access modifiers changed from:"`

2. Minimum positive-document length
A row is dropped if the positive side text is shorter than 30 characters.
- Pair configs: `pos` length >= 30 required
- Hard-negative configs: `pos` length >= 30 required

3. Hard-negative size constraint
For hard-negative configs in this release, each row keeps exactly seven negatives after normalization (`len(negs) = 7`, equivalent to `min_negs = 7`).

4. Query-level deduplication
Within each subset split, rows are grouped by exact `query` string.
- Keep the first occurrence
- Drop all later duplicates

5. Positive-document (`pos`) deduplication
Within each subset split, rows are grouped by exact `pos` string.
- Keep the first occurrence
- Drop all later duplicates

This filtering is purely rule-based (no model scoring), targeting high-noise templates and low-information positives while preserving broad retrieval coverage.