| --- |
| 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: 87647 |
| - config_name: go-v1-pair-2M |
| features: |
| - name: query |
| dtype: string |
| - name: pos |
| dtype: string |
| splits: |
| - name: train |
| num_examples: 1541111 |
| - 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: 81657 |
| - config_name: java-v1-pair-2M |
| features: |
| - name: query |
| dtype: string |
| - name: pos |
| dtype: string |
| splits: |
| - name: train |
| num_examples: 1491655 |
| - 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: 79684 |
| - config_name: javascript-v1-pair-2M |
| features: |
| - name: query |
| dtype: string |
| - name: pos |
| dtype: string |
| splits: |
| - name: train |
| num_examples: 1310965 |
| - 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: 75632 |
| - config_name: php-v1-pair-2M |
| features: |
| - name: query |
| dtype: string |
| - name: pos |
| dtype: string |
| splits: |
| - name: train |
| num_examples: 1343442 |
| - 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: 97147 |
| - config_name: python-v1-pair-2M |
| features: |
| - name: query |
| dtype: string |
| - name: pos |
| dtype: string |
| splits: |
| - name: train |
| num_examples: 1807480 |
| - 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: 68382 |
| - config_name: ruby-v1-pair-2M |
| features: |
| - name: query |
| dtype: string |
| - name: pos |
| dtype: string |
| splits: |
| - name: train |
| num_examples: 1175219 |
| 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 |
|
|
| 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 |
|
|
| ## 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 is also applied per subset: if `query` is duplicated, 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) |
|
|
| | Subset (config name) | split | num_examples | |
| | --- | --- | ---: | |
| | `go-v1-pair-2M` | `train` | 1,541,111 | |
| | `go-v1-hard-negatives-100k` | `train` | 87,647 | |
| | `java-v1-pair-2M` | `train` | 1,491,655 | |
| | `java-v1-hard-negatives-100k` | `train` | 81,657 | |
| | `javascript-v1-pair-2M` | `train` | 1,310,965 | |
| | `javascript-v1-hard-negatives-100k` | `train` | 79,684 | |
| | `php-v1-pair-2M` | `train` | 1,343,442 | |
| | `php-v1-hard-negatives-100k` | `train` | 75,632 | |
| | `python-v1-pair-2M` | `train` | 1,807,480 | |
| | `python-v1-hard-negatives-100k` | `train` | 97,147 | |
| | `ruby-v1-pair-2M` | `train` | 1,175,219 | |
| | `ruby-v1-hard-negatives-100k` | `train` | 68,382 | |
| |
| Total rows: |
| - Pair: 8,669,872 |
| - Hard-negatives: 490,149 |
| - Overall: 9,160,021 |
| |
| ## Filter Impact (Query Dedup Stage) |
| |
| The table below shows only the query-dedup impact on top of the previous rule-based filter. |
| |
| | Subset | before | after | removed | removed_ratio | |
| | --- | ---: | ---: | ---: | ---: | |
| | `go-v1-pair-2M` | 1,992,985 | 1,541,111 | 451,874 | 22.67% | |
| | `go-v1-hard-negatives-100k` | 99,663 | 87,647 | 12,016 | 12.06% | |
| | `java-v1-pair-2M` | 1,752,593 | 1,491,655 | 260,938 | 14.89% | |
| | `java-v1-hard-negatives-100k` | 87,504 | 81,657 | 5,847 | 6.68% | |
| | `javascript-v1-pair-2M` | 1,960,276 | 1,310,965 | 649,311 | 33.12% | |
| | `javascript-v1-hard-negatives-100k` | 98,025 | 79,684 | 18,341 | 18.71% | |
| | `php-v1-pair-2M` | 1,710,537 | 1,343,442 | 367,095 | 21.46% | |
| | `php-v1-hard-negatives-100k` | 85,460 | 75,632 | 9,828 | 11.50% | |
| | `python-v1-pair-2M` | 1,990,051 | 1,807,480 | 182,571 | 9.17% | |
| | `python-v1-hard-negatives-100k` | 99,535 | 97,147 | 2,388 | 2.40% | |
| | `ruby-v1-pair-2M` | 1,583,047 | 1,175,219 | 407,828 | 25.76% | |
| | `ruby-v1-hard-negatives-100k` | 79,040 | 68,382 | 10,658 | 13.48% | |
|
|
| ## 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 validity constraint |
| For hard-negative configs, at least one valid negative must remain after normalization (`min_negs = 1`). |
|
|
| 4. Query-level deduplication |
| Within each subset split, rows are grouped by exact `query` 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. |
|
|