--- 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.