id int64 0 537 | file_name stringlengths 4 38 | file_path stringlengths 16 123 | content stringlengths 126 1.72M | size int64 126 1.8M | language stringclasses 1
value | extension stringclasses 1
value | total_lines int64 4 74.3k | avg_line_length float64 6.01 89.8 | max_line_length int64 33 3.68k | alphanum_fraction float64 0.33 0.95 | repo_name stringclasses 95
values | repo_stars int64 0 50 | repo_forks int64 0 14 | repo_open_issues int64 0 34 | repo_license stringclasses 7
values | repo_extraction_date stringclasses 11
values | exact_duplicates_stackv1 bool 2
classes | exact_duplicates_stackv2 bool 2
classes | near_duplicates_stackv1 bool 2
classes | near_duplicates_stackv2 bool 2
classes |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | TSqlParserCore.g4 | christianhelle_sqlcequery/Source/TSqlParser/TSqlParserCore.g4 | /*
T-SQL (Transact-SQL, MSSQL) grammar.
The MIT License (MIT).
Copyright (c) 2017, Mark Adams (madams51703@gmail.com)
Copyright (c) 2015-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies.
Copyright (c) 2016, Scott Ure (scott@redstormsoftware.com).
Copyright (c) 2016, Rui Zhang (ruizhang.ccs@gmail.com).
Co... | 137,629 | ANTLR | .g4 | 3,822 | 29.89011 | 757 | 0.645182 | christianhelle/sqlcequery | 50 | 13 | 2 | GPL-3.0 | 9/19/2024, 2:48:21 PM (Europe/Amsterdam) | false | false | true | true |
1 | TSqlLexerCore.g4 | christianhelle_sqlcequery/Source/TSqlParser/TSqlLexerCore.g4 | /*
T-SQL (Transact-SQL, MSSQL) grammar.
The MIT License (MIT).
Copyright (c) 2017, Mark Adams (madams51703@gmail.com)
Copyright (c) 2015-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies.
Copyright (c) 2016, Scott Ure (scott@redstormsoftware.com).
Copyright (c) 2016, Rui Zhang (ruizhang.ccs@gmail.com).
Co... | 45,942 | ANTLR | .g4 | 904 | 49.738938 | 95 | 0.359941 | christianhelle/sqlcequery | 50 | 13 | 2 | GPL-3.0 | 9/19/2024, 2:48:21 PM (Europe/Amsterdam) | false | false | true | true |
2 | UnicodeClasses.g4 | xcporter_MetaView/src/main/antlr/UnicodeClasses.g4 | "/**\n * Kotlin lexical grammar in ANTLR4 notation (Unicode classes)\n *\n * Taken from http://www.a(...TRUNCATED) | 23,131 | ANTLR | .g4 | 1,641 | 12.096892 | 74 | 0.466369 | xcporter/MetaView | 24 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:48:29 PM (Europe/Amsterdam) | true | true | true | true |
3 | KotlinLexer.g4 | xcporter_MetaView/src/main/antlr/KotlinLexer.g4 | "/**\n * Kotlin lexical grammar in ANTLR4 notation\n */\n\nlexer grammar KotlinLexer;\n\nimport Unic(...TRUNCATED) | 12,067 | ANTLR | .g4 | 453 | 24.328918 | 98 | 0.679574 | xcporter/MetaView | 24 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:48:29 PM (Europe/Amsterdam) | true | true | true | true |
4 | KotlinParser.g4 | xcporter_MetaView/src/main/antlr/KotlinParser.g4 | "/**\n * Kotlin syntax grammar in ANTLR4 notation\n */\n\nparser grammar KotlinParser;\n\noptions { (...TRUNCATED) | 17,095 | ANTLR | .g4 | 741 | 18.82861 | 134 | 0.703154 | xcporter/MetaView | 24 | 1 | 2 | GPL-3.0 | 9/19/2024, 2:48:29 PM (Europe/Amsterdam) | true | true | true | true |
5 | plsql.g4 | datacamp_antlr-plsql/antlr_plsql/plsql.g4 | "/**\n * Oracle(c) PL/SQL 11g Parser\n *\n * Copyright (c) 2009-2011 Alexandre Porcelli <alexandre.p(...TRUNCATED) | 121,455 | ANTLR | .g4 | 3,969 | 26.480474 | 198 | 0.548978 | datacamp/antlr-plsql | 17 | 14 | 6 | AGPL-3.0 | 9/19/2024, 2:48:36 PM (Europe/Amsterdam) | false | false | true | true |
6 | Delphi.g4 | gotthardsen_Delphi-ANTRL4-Grammar/Delphi.g4 | "grammar Delphi;\n\n/*\n * Sonar Delphi Plugin\n * Copyright (C) 2010 SonarSource\n * dev@sonar.code(...TRUNCATED) | 42,720 | ANTLR | .g4 | 890 | 32.516854 | 204 | 0.367812 | gotthardsen/Delphi-ANTRL4-Grammar | 15 | 7 | 3 | LGPL-3.0 | 9/19/2024, 2:48:36 PM (Europe/Amsterdam) | false | true | false | true |
7 | MurphySDR-In3_Cu.g4 | MillePoels_MurPhySDR/hardware/gerber-files/MurphySDR-In3_Cu.g4 | "%TF.GenerationSoftware,KiCad,Pcbnew,8.0.1*%\n%TF.CreationDate,2024-04-14T19:48:42+02:00*%\n%TF.Proj(...TRUNCATED) | 368,403 | ANTLR | .g4 | 14,526 | 24.361627 | 65 | 0.91815 | MillePoels/MurPhySDR | 13 | 1 | 1 | GPL-3.0 | 9/19/2024, 2:48:36 PM (Europe/Amsterdam) | false | false | false | false |
8 | Java.g4 | le-moulin-studio_java-semantic-diff/src/main/antlr4/Java.g4 | "/*\n [The \"BSD licence\"]\n Copyright (c) 2013 Terence Parr, Sam Harwell\n All rights reserved.\n\(...TRUNCATED) | 20,992 | ANTLR | .g4 | 842 | 21.119952 | 107 | 0.623466 | le-moulin-studio/java-semantic-diff | 12 | 1 | 3 | AGPL-3.0 | 9/19/2024, 2:48:36 PM (Europe/Amsterdam) | true | true | true | true |
9 | UVLJava.g4 | Universal-Variability-Language_uvl-parser/uvl/UVLJava.g4 | "grammar UVLJava;\nimport UVLBase;\n@header {\npackage uvl;\n}\n@lexer::members {\n // A queue wher(...TRUNCATED) | 4,403 | ANTLR | .g4 | 126 | 29.52381 | 99 | 0.615258 | Universal-Variability-Language/uvl-parser | 10 | 8 | 8 | LGPL-3.0 | 9/19/2024, 2:48:36 PM (Europe/Amsterdam) | false | false | true | true |
The Heap Dataset
We develop The Heap, a new contamination-free multilingual code dataset comprising 57 languages, which facilitates LLM evaluation reproducibility. The reproduction packge can be found here.
Is your code in The Heap?
If you would like to have your data removed from the dataset, follow the instructions on GitHub.
Usage
Using the Datasets API, our dataset can be used as follows:
from datasets import load_dataset
dataset_name = 'redpajama'
language = 'Python'
ds = load_dataset(
"AISE-TUDelft/the-heap",
f"{language}",
split="train",
num_proc=16
)
ds = ds.filter(lambda x: not x[f'exact_duplicates_{dataset_name}'] and not x[f'near_duplicates_{dataset_name}'])
Collection
We collect up to 50,000 public repositories using the GitHub API, focusing on license type, star count, and creation date. Repositories with non-permissive licenses are prioritized to reduce contamination, as public code datasets we deduplicate against primarily focus on permissive or no-license repositories. We select repositories created before August 2024 in decreasing order of their star counts. To handle GitHub rate limits, we use timeouts and pagination during the scraping process.
Copyleft licenses included in the The Heap
| License | Family |
|---|---|
| CECILL-1.0, CECILL-1.1, CECILL-2.0, CECILL-2.1, CECILL-C, EPL-1.0, EPL-2.0, LGPL-2.1, LGPL-3.0, MS-RL, MPL-2.0 |
Weak Copyleft |
| GPL-2.0, GPL-3.0 | Strong Copyleft |
| AGPL-3.0, EUPL-1.1, EUPL-1.2, OSL-3.0 | Network Copyleft |
The features we extract for each repository are illustrated in the example below.
{
"id": 126178683,
"full_name": "halo-dev/halo",
"html_url": "https://github.com/halo-dev/halo",
"stargazers_count": 29115,
"forks_count": 8985,
"watchers_count": 29115,
"open_issues_count": 278,
"language": "Java",
"created_at": "2018-03-21T12:56:52Z",
"pushed_at": "2023-10-28T16:29:39Z",
"license": {
"key": "gpl-3.0",
"name": "GNU General Public License v3.0",
"spdx_id": "GPL-3.0",
"url": "https://api.github.com/licenses/gpl-3.0",
"node_id": "MDc6TGljZW5zZTk="
},
"retrieval_date": "10/30/2023, 3:24:57 PM (Europe/Amsterdam)"
}
Repository Fields
- id: unique id of the repo
- full_name: complete name of the repo
- html_url: URL to the repo
- stargazers_count: number of stars of the repo
- forks_count: number of forks of the repo
- watchers_count: number of watchers of the repo
- open_issues_count: number of open issues of the repo at the extraction time
- language: main language of the repo
- created_at: creation date of the repo
- pushed_at: date of the most recent push to the repo until the extraction date
- license: license type of the repo
- retrieval_date: date when the repo was scraped from GitHub
We start by retrieving repositories with more than 900 stars using two-month tumbling windows. If we hit the 1000 repository limit per window (for a personal GitHub account), we shorten the search space to a one-month window and restart the iteration. Otherwise, the window advances by two months. Once the entire timeframe (until August 2024) is covered, we reduce the star search space: between 900 and 100 stars, we decrease the interval by 50 (e.g. search between [900, 850]), between 100 and 10 stars, we decrease the interval by 10, and for the last 10 stars, we decrease by 1. Since most repositories fall within the 0-100 star range (e.g. Figure 1 showcases the distribution of repositories with up to 500 stars for Java), using the creation date and star count filters helps us avoid API limits and scrape more data by narrowing the search space. The creation date window can be reduced even further (week or day level), in order to extract more data. We remove any potential duplicated repositories obtained due to the pagination process. Lastly, we extract all the files corresponding to each language. We extend the programming languages extension list used for The Stack with 4 languages: EJS, Raku, Starlark, and WebAssembly.
Figure 1: Distribution of scraped repositories with at most 500 stars for Java
Cleaning
The next stage in our dataset pipeline is the cleaning procedure. We exclude any files larger than 10 MB and those with fewer than 10 words.
Deduplication
The final stage of our dataset pipeline is the deduplication process. We apply both exact and near deduplication against open code datasets listed in the table below.
Open code datasets used for deduplication
| Dataset | Source |
|---|---|
| The Stack V2 | All permissively licensed and unlicensed files collected in the Software Heritage archive. |
| The Stack | All permissively licensed repositories collected in the GHArchive and scraped from GitHub. |
| Red Pajama | Repositories from the GitHub dataset hosted by Google BigQuery licensed under MIT, BSD, or Apache licenses. |
| GitHub Code | Repositories from the GitHub dataset hosted by Google BigQuery. |
| CodeParrot | All Python files from the GitHub dataset hosted by Google BigQuery. |
Exact Deduplication
We remove exact duplicates within our dataset itself, and then we apply exact deduplication against the open datasets. For that, we use the sha256 function to generate hashes for each file. We choose this hash function because it provides a uniform distribution of hash values, minimizes collisions, and ensures even distribution across the hash space.
Near Deduplication
We apply the MinHashLSH algorithm using the datasketch1 library. To calculate the minhashes, we use the same hash function as above, but we extract the first 16 bytes to generate 128-bit hash values. This approach balances the need for a strong hash function with the efficiency of a shorter hash length.
Additionally, we use 128 file permutations for LSH, with weights of 0.4 for precision and 0.6 for recall. We generate 7-character shingles after lowercasing the file content and removing whitespace. We find that 7-shingles provide a reasonable trade-off between the number of shingles and the data processed, being small enough to keep the number of unique shingles manageable yet large enough to provide meaningful comparisons. It was shown that the number of shingles should be large enough to ensure a low probability of shingles appearing across documents, with k = 5 suggested for smaller documents such as emails. However, code files usually contain a larger dictionary of characters than emails, including arithmetic and comparison operators which are less frequent in emails. Thus, given the increased complexity and size of code files, we consider 7-shingles to be appropriate to capture sufficient context, ensuring uniqueness and reducing false positives, which smaller shingles such as k = 5 might fail to achieve. Furthermore, k = 9 was shown to be a safe choice for large research articles, however, for our needs, 7-shingles strike a balance between accuracy and computational efficiency, crucial for handling the extensive size of the datasets. This choice provides better computational efficiency by reducing the number of comparisons while maintaining a manageable shingle space. Lastly, we use a Jaccard similarity threshold of 0.7, which proved to be efficient for both SantaCoder and StarCoder models. A high threshold reduces false positives, leading to fewer unnecessary comparisons and lower computational overhead. Moreover, this standard threshold value has been shown to be robust for duplicate detection.
Instead of removing exact and near duplicates found against other open datasets, we add a boolean mask to our dataset. This approach enhances reproducibility by allowing researchers to filter the dataset for unique files, according to their specific requirements.
The final dataset structure is shown in the example below.
{
"id": 538,
"file_name": "Font.java",
"file_path": ".../lateralgm/resources/Font.java",
"content": "*/ package org.lateralgm.resources; import java.util.EnumMap; import org.lateralgm.main.Prefs; ...",
"size": 1,985,
"language": "Java",
"extension": ".java",
"total_lines": 3,835,
"avg_line_length": 29,834,
"max_line_length": 567,
"alphanum_fraction": 0,645,
"repo_name": "lwizchz/GameMaker-HTML5-Player",
"repo_stars": 22,
"repo_forks": 9,
"repo_open_issues": 0,
"repo_license": "GPL-3.0",
"repo_extraction_date": "9/19/2024, 2:48:21 PM (Europe/Amsterdam)"
"exact_duplicates_stackv1": False,
"exact_duplicates_stackv2": True,
"near_duplicates_stackv1": True,
"near_duplicates_stackv2": False,
....
}
Dataset Fields
- id: unique ID of the file
- file_name: name of the file extracted from its repo
- file_path: path to the file in its repo
- content: content of the file
- size: size of the file
- language: language of the file
- total_lines: number of total lines of the file
- avg_line_length: average line length of the file
- max_line_length: max line length of the file
- alphanum_fraction: alphanumeric fraction of the file
- extension: language extension of the file
- repo_name: complete name of the file's repo
- repo_stars: number of stars of the file's repo
- repo_forks: number of forks of the file's repo
- repo_open_issues: number of open issues of the file's repo at the extraction date
- repo_license: license of the file's repo
- repo_extraction_date: extraction date of file's repo
- exact_duplicates_pubdataset: boolean flag stating if there are any exact duplicate files found against another public dataset (The Stackv2, The Stack, RedPajama, GithubCode, CodeParrot)
- near_duplicates_pubdataset: boolean flag stating if there are any near duplicate files found against another public dataset (The Stackv2, The Stack, RedPajama, GithubCode, CodeParrot)
The distribution of the languages in The Heap is presented in the table below. The third column shows the number of files collected after filtering based on file size and word count. The last column indicates the number of files remaining after removing exact duplicates within the dataset, with exact and near duplicates compared to other datasets flagged among the remaining files.
Programming languages included in The Heap
| Language | Repositories | Raw Files | Unique Files |
|---|---|---|---|
| Ada | 676 | 41,367 | 34,068 |
| Agda | 142 | 5,483 | 3,021 |
| ANTLR | 101 | 564 | 538 |
| Apex | 253 | 17,833 | 7,561 |
| Assembly | 7,100 | 208,896 | 101,093 |
| C | 50,000 | 16,585,280 | 3,076,470 |
| C# | 50,000 | 5,906,716 | 3,257,456 |
| C++ | 50,000 | 14,891,856 | 4,469,823 |
| Clojure | 27,107 | 380,567 | 269,118 |
| Cobol | 341 | 2,242 | 1,172 |
| Common Lisp | 796 | 45,083 | 13,922 |
| Coq | 477 | 54,137 | 22,549 |
| Cuda | 1,191 | 26,948 | 12,418 |
| Crystal | 368 | 11,606 | 6,818 |
| D | 1,185 | 185,630 | 54,034 |
| Dart | 11,907 | 484,935 | 412,675 |
| EJS | 1,475 | 15,513 | 12,832 |
| Elixir | 2,371 | 643,856 | 102,874 |
| Emacs Lisp | 377 | 8,260 | 7,312 |
| Erlang | 1,240 | 55,932 | 27,322 |
| F# | 876 | 22,152 | 13,282 |
| Forth | 222 | 28,287 | 5,129 |
| Go | 50,000 | 8,506,379 | 2,328,529 |
| Groovy | 2,198 | 60,299 | 47,366 |
| Hack | 1,379 | 84,916 | 37,189 |
| Haskell | 8,023 | 122,788 | 106,583 |
| Java | 50,000 | 6,989,601 | 5,168,193 |
| JavaScript | 50,000 | 8,289,901 | 1,907,803 |
| Julia | 2,859 | 46,284 | 36,830 |
| Kotlin | 21,665 | 1,467,343 | 1,042,136 |
| Less | 433 | 17,276 | 7,308 |
| Lua | 42,241 | 4,605,230 | 905,120 |
| Mathematica | 1,528 | 164,498 | 21,208 |
| Matlab | 20,828 | 1,051,354 | 599,085 |
| NetLogo | 332 | 900 | 855 |
| NewLisp | 35 | 5,819 | 5,123 |
| Nix | 1,892 | 75,093 | 70,407 |
| Objective-C | 7,700 | 1,899,714 | 520,332 |
| OCaml | 1,961 | 121,890 | 60,863 |
| Pascal | 5,218 | 330,832 | 180,652 |
| Perl | 14,673 | 1,798,520 | 224,753 |
| PHP | 50,000 | 12,707,727 | 3,310,243 |
| Processing | 2,950 | 24,723 | 20,304 |
| Prolog | 1,071 | 38,995 | 17,570 |
| Python | 50,000 | 2,290,182 | 1,595,919 |
| R | 44,993 | 589,139 | 11,679 |
| Raku | 158 | 1384 | 689 |
| Ruby | 13,378 | 1,579,635 | 662,915 |
| Rust | 42,847 | 2,496,177 | 802,707 |
| Scala | 5,893 | 749,370 | 210,630 |
| Scheme | 1,878 | 106,620 | 50,222 |
| Scilab | 199 | 4,531 | 3,896 |
| SQL | 130 | 47,185 | 40,800 |
| Starlark | 146 | 524 | 487 |
| Swift | 13,924 | 633,819 | 434,849 |
| Vue | 14,858 | 457,605 | 321,502 |
| WebAssembly | 68 | 834 | 544 |
| Total | 733,663 | 96,945,943 | 32,666,778 |
- Downloads last month
- 148