File size: 11,154 Bytes
a4fc840
 
46250da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a4fc840
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46250da
 
 
 
 
 
 
 
a4fc840
 
 
 
 
 
 
 
396eb23
50f1009
b0cb9d0
 
396eb23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50f1009
396eb23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c763282
396eb23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50f1009
396eb23
 
 
 
 
50f1009
 
 
 
 
 
 
 
 
 
 
 
 
 
396eb23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c763282
396eb23
 
 
 
 
 
 
50f1009
396eb23
50f1009
396eb23
 
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
---
dataset_info:
- config_name: codeparrot_github-code-chemistry-python-default
  features:
  - name: text
    dtype: string
  - name: repo_name
    dtype: string
  - name: path
    dtype: string
  - name: language
    dtype: string
  - name: license
    dtype: string
  - name: size
    dtype: int32
  - name: keyword
    sequence: string
  - name: text_hash
    dtype: string
  splits:
  - name: train
    num_bytes: 3645895510
    num_examples: 186878
  - name: test
    num_bytes: 208905795
    num_examples: 10383
  - name: val
    num_bytes: 200466630
    num_examples: 10382
  download_size: 1469927226
  dataset_size: 4055267935
- config_name: starcoder-chemistry-default
  features:
  - name: text
    dtype: string
  - name: repo_path
    dtype: string
  - name: keyword
    sequence: string
  - name: text_hash
    dtype: string
  splits:
  - name: train
    num_bytes: 34245426723
    num_examples: 1853757
  - name: test
    num_bytes: 1869671691
    num_examples: 102987
  - name: val
    num_bytes: 1949124399
    num_examples: 102987
  download_size: 14166968855
  dataset_size: 38064222813
configs:
- config_name: codeparrot_github-code-chemistry-python-default
  data_files:
  - split: train
    path: codeparrot_github-code-chemistry-python-default/train-*
  - split: test
    path: codeparrot_github-code-chemistry-python-default/test-*
  - split: val
    path: codeparrot_github-code-chemistry-python-default/val-*
- config_name: starcoder-chemistry-default
  data_files:
  - split: train
    path: starcoder-chemistry-default/train-*
  - split: test
    path: starcoder-chemistry-default/test-*
  - split: val
    path: starcoder-chemistry-default/val-*
license:
- agpl-3.0
tags:
- chemistry
- scientific-code
- simulation-code
- computational-chemistry
- materials-science
annotations_creators:
- expert-generated
language_creators:
- expert-generated
language:
- en
multilinguality:
- monolingual
size_categories:
- 1M<n<10M
source_datasets:
- bigcode/the-stack
- codeparrot/github-code
task_categories:
- text-generation
task_ids:
- language-modeling
pretty_name: ChemPile-Code
dataset_version: 1.0.0
dataset_release_date: '2025-05-18'
dataset_citation: "@article{mirza2025chempile0,\n  title   = {ChemPile: A 250GB Diverse
  and Curated Dataset for Chemical Foundation Models},\n  author  = {Adrian Mirza
  and Nawaf Alampara and Martiño Ríos-García and others},\n  year    = {2025},\n \
  \ journal = {arXiv preprint arXiv:2505.12534}\n}"
---
# ChemPile-Code

<div align="center">

![ChemPile Logo](CHEMPILE_LOGO.png)
  
[![Dataset](https://img.shields.io/badge/🤗%20Hugging%20Face-Dataset-yellow)](https://huggingface.co/datasets/jablonkagroup/chempile-code)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Paper](https://img.shields.io/badge/📄-Paper-red)](https://arxiv.org/abs/2505.12534)
[![Website](https://img.shields.io/badge/🌐-Website-green)](https://chempile.lamalab.org/)

*A comprehensive collection of filtered scientific code from chemistry, biology, and materials science*

</div>

## 📋 Dataset Summary

ChemPile-Code includes filtered code from popular datasets such as the Stack and GitHub-code. It is designed to provide a rich source of scientific coding from fields such as chemistry, biology, and materials science. The dataset is part of the ChemPile project, and aims to create a comprehensive collection of chemistry code for training language models. The filtering process is keyword-based, focusing on packages and libraries relevant to chemistry, biology, and materials science. Those keywords include simulation packages such as LAMMPS, GROMACS, and OpenMM, as well as libraries like RDKit, ASE, and MDTraj, or plotting programmes like VMD or PyMOL. To avoid duplicates, exact hash matching was used to filter out identical code snippets.

### 📊 Dataset Statistics

| Subset | Tokens | Documents | Description |
|--------|--------|-----------|-------------|
| CodeParrot GitHub-Code Chemistry Python | 1.8B | 208K | Python code from GitHub repositories |
| StarCoder Chemistry | 16.1B | 2.06M | Python code from the Stack dataset |
| **Total** | **~17.9B** | **~2.27M** | Scientific code snippets |

## 🗂️ Dataset Configurations

The dataset includes different subsets available as Hugging Face configurations:

- `codeparrot_github-code-chemistry-python-default`
- `starcoder-chemistry-default`

## 📜 License

All content is released under the **AGPL-3.0** license, which allows for:
- ✅ Free use and distribution
- ✅ Commercial use
- ✅ Modification and derivatives
- ⚠️ Attribution required

However, the dataset combines code under different licenses. The config `codeparrot_github-code-chemistry-python-default` is designed such that is possible to filter the dataset based on the license. Therefore, this config has code under the next licenses:

- MIT
- GPL-3.0
- BSD-3-Clause
- GPL-2.0
- Apache-2.0
- LGPL-2.1
- AGPL-2.0
- AGPL-3.0
- LGPL-3.0
- MPL-2.0
- BSD-2-Clause

## 📖 Dataset Details

### 📚 CodeParrot

**Source**: CodeParrot is a subset of GitHub code, that we specifically filtered for chemistry-related content

**Coverage**: Python code from the GitHub Code dataset

**Extraction Method**: Keyword-based filtering focusing on chemistry, biology, and materials science packages and libraries

**Fields**:
- `text`: The code snippet
- `repo_name`: The name of the repository where the code snippet was found
- `path`: The path to the file within the repository
- `language`: The programming language of the code snippet
- `license`: The license of the repository
- `size`: The size of the code snippet in bytes
- `keyword`: A list of keywords that were used to filter the code snippet
- `text_hash`: A hash of the code snippet to avoid duplicates

**Statistics**: 208K code snippets with a total of over 1.8B tokens

### ⚗️ StarCoder

**Source**: StarCoder is a subset of the Stack dataset, that we specifically filtered for chemistry-related content

**Coverage**: Python code from the Stack dataset

**Extraction Method**: Keyword-based filtering with exact hash matching to avoid duplicates

**Fields**:
- `text`: The code snippet
- `repo_name`: The name of the repository where the code snippet was found
- `keyword`: A list of keywords that were used to filter the code snippet
- `text_hash`: A hash of the code snippet to avoid duplicates

**Statistics**: 2.06M code snippets with a total of over 16.1B tokens

## 🚀 Quick Start

```python
from datasets import load_dataset, get_dataset_config_names

# Print available configs for the dataset
configs = get_dataset_config_names("jablonkagroup/chempile-code")
print(f"Available configs: {configs}")
# Available configs: ['codeparrot_github-code-chemistry-python-default', 'starcoder-chemistry-default']

dataset = load_dataset("jablonkagroup/chempile-code", name=configs[0])
# Loading config: codeparrot_github-code-chemistry-python-default

print(dataset)
# DatasetDict({
    # train: Dataset({
        # features: ['text', 'repo_name', 'path', 'language', 'license', 'size', 'keyword', 'text_hash'],
        # num_rows: 186878
    # })
    # test: Dataset({
        # features: ['text', 'repo_name', 'path', 'language', 'license', 'size', 'keyword', 'text_hash'],
        # num_rows: 10383
    # })
    # val: Dataset({
        # features: ['text', 'repo_name', 'path', 'language', 'license', 'size', 'keyword', 'text_hash'],
        # num_rows: 10382
    # })
# })

split_name = list(dataset.keys())[0]
sample = dataset[split_name][0]
print(sample)
# {
#     'text': 'import moogli
except Exception as e:...
#     'repo_name': 'BhallaLab/moose', 
#     'path': 'moose-examples/paper-2015/Fig2_elecModels/Fig2C.py', 
#     'language': 'Python', 
#     'license': 'gpl-3.0', 
#     'size': 14223, 
#     'keyword': ['MOOSE', 'NEURON'], 
#     'text_hash': '5eb6a5a439a675762a02c12cdff996e6a0d98f6ee874773cba2951727562aac5'
# }
```

## 🎯 Use Cases

- **🤖 Code Generation**: Training models for scientific code generation and completion
- **🔬 Scientific Computing**: Building systems for computational chemistry and materials science
- **🔍 Code Search**: Advanced scientific code repository search and analysis
- **📝 Documentation**: Automated code documentation and analysis for scientific software
- **🧠 Domain Adaptation**: Adapting models to scientific computing paradigms and libraries

## ⚠️ Limitations & Considerations

- **Language**: Primarily Python code (monolingual dataset)
- **Scope**: Focused on scientific computing; may include domain-specific jargon and advanced concepts
- **Quality**: Variable quality across sources; some code may be incomplete or contain errors
- **Bias**: Reflects biases present in open-source scientific software development
- **License**: Mixed licenses from source repositories - check individual `license` field
- **Duplicates**: Hash-based deduplication applied but some semantic duplicates may remain

## 🛠️ Data Processing Pipeline

1. **Collection**: Automated extraction from GitHub-code and Stack datasets
2. **Filtering**: Keyword-based filtering for chemistry, biology, and materials science relevance
3. **Deduplication**: Exact hash matching to remove identical code snippets
4. **Quality Control**: Automated filtering and validation
5. **Standardization**: Consistent formatting and metadata extraction
6. **Validation**: Train/validation/test splits and quality checks
    
## 🏗️ ChemPile Collection

This dataset is part of the **ChemPile** collection, a comprehensive open dataset containing over 75 billion tokens of curated chemical data for training and evaluating general-purpose models in the chemical sciences. 

### Collection Overview
- **📊 Scale**: 75+ billion tokens across multiple modalities
- **🧬 Modalities**: Structured representations (SMILES, SELFIES, IUPAC, InChI), scientific text, executable code, and molecular images
- **🎯 Design**: Integrates foundational educational knowledge with specialized scientific literature
- **🔬 Curation**: Extensive expert curation and validation
- **📈 Benchmarking**: Standardized train/validation/test splits for robust evaluation
- **🌐 Availability**: Openly released via Hugging Face

## 📄 Citation

If you use this dataset in your research, please cite:

```bibtex
@article{mirza2025chempile0,
  title   = {ChemPile: A 250GB Diverse and Curated Dataset for Chemical Foundation Models},
  author  = {Adrian Mirza and Nawaf Alampara and Martiño Ríos-García and others},
  year    = {2025},
  journal = {arXiv preprint arXiv:2505.12534}
}
```

## 👥 Contact & Support

- **Paper**: [arXiv:2505.12534](https://arxiv.org/abs/2505.12534)
- **Website**: [ChemPile Project](https://chempile.lamalab.org/)
- **Dataset**: [Hugging Face](https://huggingface.co/datasets/jablonkagroup/chempile-code)
- **Issues**: Please report data issues or questions via the Hugging Face dataset page

---

<div align="center">

![LamaLab logo](png-file.png)

<i>Advancing the evaluation of AI systems in chemistry and materials science</i>

</div>