File size: 14,847 Bytes
386c4d0 6b97519 3f647aa 6b97519 3f647aa 6b97519 3f647aa 6b97519 3f647aa 6b97519 3f647aa 6b97519 3f647aa 6b97519 3f647aa 6b97519 3f647aa 1db80b5 52dd077 1db80b5 52dd077 1db80b5 52dd077 1db80b5 52dd077 1db80b5 52dd077 1db80b5 52dd077 1db80b5 52dd077 1db80b5 52dd077 0e2b983 d9e5e62 0e2b983 d9e5e62 0e2b983 d9e5e62 0e2b983 d9e5e62 0e2b983 d9e5e62 0e2b983 d9e5e62 0e2b983 d9e5e62 0e2b983 d9e5e62 a2aeb39 0f5a8fb a2aeb39 0f5a8fb a2aeb39 0f5a8fb a2aeb39 0f5a8fb a2aeb39 0f5a8fb a2aeb39 0f5a8fb 1b267e9 a2aeb39 1b267e9 a2aeb39 1b267e9 d7dfe44 386c4d0 bbc16c5 386c4d0 bbc16c5 386c4d0 bbc16c5 386c4d0 bbc16c5 386c4d0 bbc16c5 386c4d0 bbc16c5 386c4d0 bbc16c5 386c4d0 bbc16c5 d7dfe44 e2e9f3e d7dfe44 e2e9f3e d7dfe44 e2e9f3e d7dfe44 e2e9f3e d7dfe44 e2e9f3e d7dfe44 e2e9f3e d7dfe44 e2e9f3e d7dfe44 e2e9f3e 385af25 fafb9f6 385af25 fafb9f6 385af25 fafb9f6 385af25 fafb9f6 385af25 fafb9f6 385af25 fafb9f6 385af25 fafb9f6 385af25 fafb9f6 3005797 6498f93 3005797 6498f93 3005797 6498f93 3005797 6498f93 3005797 6498f93 3005797 6498f93 3005797 6498f93 3005797 6498f93 d6fd95e c199590 d6fd95e c199590 d6fd95e c199590 d6fd95e c199590 d6fd95e c199590 d6fd95e c199590 d6fd95e c199590 d6fd95e c199590 c880c86 9d9831f c880c86 9d9831f c880c86 9d9831f c880c86 9d9831f c880c86 9d9831f c880c86 9d9831f c880c86 9d9831f c880c86 9d9831f 77dffb8 d7c7c73 77dffb8 d7c7c73 77dffb8 d7c7c73 77dffb8 d7c7c73 77dffb8 d7c7c73 77dffb8 d7c7c73 77dffb8 d7c7c73 77dffb8 d7c7c73 5f12f18 b6f878a 5f12f18 b6f878a 5f12f18 b6f878a 5f12f18 b6f878a 5f12f18 b6f878a 5f12f18 b6f878a 5f12f18 b6f878a 5f12f18 b6f878a e95ad84 5d56483 e95ad84 5d56483 e95ad84 5d56483 e95ad84 5d56483 e95ad84 5d56483 e95ad84 5d56483 e95ad84 5d56483 e95ad84 5d56483 454e691 99aede9 454e691 99aede9 454e691 99aede9 454e691 99aede9 454e691 99aede9 454e691 99aede9 454e691 99aede9 454e691 99aede9 81cd535 0fc6ba1 81cd535 0fc6ba1 81cd535 0fc6ba1 81cd535 0fc6ba1 81cd535 0fc6ba1 81cd535 0fc6ba1 81cd535 0fc6ba1 81cd535 0fc6ba1 386c4d0 6b97519 1db80b5 0e2b983 a2aeb39 386c4d0 d7dfe44 385af25 3005797 d6fd95e c880c86 77dffb8 5f12f18 e95ad84 454e691 81cd535 386c4d0 b5648b9 24c03c5 b5648b9 eeec5ca b5648b9 8d2edf0 b5648b9 eeec5ca b5648b9 fdb670b b5648b9 |
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 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
---
dataset_info:
- config_name: C
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 1100442974
num_examples: 5848375
download_size: 571816053
dataset_size: 1100442974
- config_name: CSharp
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 2392066248
num_examples: 11425016
download_size: 1232015539
dataset_size: 2392066248
- config_name: Cpp
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 3167426435
num_examples: 16246746
download_size: 1632803797
dataset_size: 3167426435
- config_name: Go
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
- name: detected_licenses_right
large_list: large_string
- name: license_type_right
dtype: large_string
splits:
- name: train
num_bytes: 433053889
num_examples: 1917163
download_size: 179388495
dataset_size: 433053889
- config_name: Java
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 10292427437
num_examples: 44990158
download_size: 5291667797
dataset_size: 10292427437
- config_name: JavaScript
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 2654326008
num_examples: 13253431
download_size: 1287066511
dataset_size: 2654326008
- config_name: Markdown
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 4268378053
num_examples: 20687077
download_size: 2058772192
dataset_size: 4268378053
- config_name: PHP
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 1985843762
num_examples: 9914497
download_size: 983498806
dataset_size: 1985843762
- config_name: Python
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 4947575770
num_examples: 25286019
download_size: 2500795086
dataset_size: 4947575770
- config_name: Ruby
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 592832039
num_examples: 2976874
download_size: 284535771
dataset_size: 592832039
- config_name: Rust
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 227434676
num_examples: 1135379
download_size: 103158397
dataset_size: 227434676
- config_name: SQL
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 505669712
num_examples: 2504412
download_size: 261176608
dataset_size: 505669712
- config_name: Shell
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 811611733
num_examples: 4133547
download_size: 394872047
dataset_size: 811611733
- config_name: Swift
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 529873695
num_examples: 2454309
download_size: 257883733
dataset_size: 529873695
- config_name: TypeScript
features:
- name: blob_id
dtype: large_string
- name: language
dtype: large_string
- name: repo_name
dtype: large_string
- name: path
dtype: large_string
- name: src_encoding
dtype: large_string
- name: length_bytes
dtype: int64
- name: score
dtype: float64
- name: int_score
dtype: int64
- name: detected_licenses
large_list: large_string
- name: license_type
dtype: large_string
splits:
- name: train
num_bytes: 904736029
num_examples: 4290356
download_size: 425942502
dataset_size: 904736029
configs:
- config_name: C
data_files:
- split: train
path: C/train-*
- config_name: CSharp
data_files:
- split: train
path: CSharp/train-*
- config_name: Cpp
data_files:
- split: train
path: Cpp/train-*
- config_name: Go
data_files:
- split: train
path: Go/train-*
- config_name: Java
data_files:
- split: train
path: Java/train-*
- config_name: JavaScript
data_files:
- split: train
path: JavaScript/train-*
- config_name: Markdown
data_files:
- split: train
path: Markdown/train-*
- config_name: PHP
data_files:
- split: train
path: PHP/train-*
- config_name: Python
data_files:
- split: train
path: Python/train-*
- config_name: Ruby
data_files:
- split: train
path: Ruby/train-*
- config_name: Rust
data_files:
- split: train
path: Rust/train-*
- config_name: SQL
data_files:
- split: train
path: SQL/train-*
- config_name: Shell
data_files:
- split: train
path: Shell/train-*
- config_name: Swift
data_files:
- split: train
path: Swift/train-*
- config_name: TypeScript
data_files:
- split: train
path: TypeScript/train-*
---
# 💻 Stack-Edu

Stack-Edu is a 125B token dataset of educational code filtered from [The Stack v2](https://huggingface.co/datasets/bigcode/the-stack-v2), precisely the curated training corpus of [StarCoder2](https://arxiv.org/abs/2402.19173) models denoted StarCoder2Data. It is intended for Language Models training.
This dataset was curated using a classifier-based filtering strategy, inspired by [📚 FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu), to retain only the highest-quality educational programming content.
Stack-Edu shows consistent improvement over StarCoder2data on all the programming languages on MultiPL-E benchmark.
<img src="https://cdn-uploads.huggingface.co/production/uploads/61c141342aac764ce1654e43/GWnPgD0diMu0I8buK6mvG.png" width="600"/>
## Downloading the data
This dataset only contains the SWHIDs to download the code files and not the content of the files itself. The contents can be downloaded from Software Heritage's S3 bucket to ensure data compliance.
Please refer to [the-stack-v2](https://huggingface.co/datasets/bigcode/the-stack-v2-train-full-ids) for the data license.
When running on a 16-core AWS `us-east-1` instance, this script takes ~6 hours to download the files:
```python
import boto3
import gzip
from datasets import load_dataset
from botocore.exceptions import ClientError
num_proc = 16
s3 = boto3.client('s3')
bucket_name = "softwareheritage"
def download_contents(blob_id):
key = f"content/{blob_id}"
try:
obj = s3.get_object(Bucket=bucket_name, Key=key)
with gzip.GzipFile(fileobj=obj['Body']) as fin:
content = fin.read().decode("utf-8", errors="ignore")
return {"text": content, "download_success": True}
except ClientError as e:
if e.response['Error']['Code'] == 'NoSuchKey':
print(f"File not found: {key}")
return {"text": "", "download_success": False}
else:
raise
# For Python
ds = load_dataset("HuggingFaceTB/stack-edu", "Python", split="train", num_proc=num_proc)
ds = ds.map(download_contents, input_columns="blob_id", num_proc=num_proc)
# Filter out failed downloads
ds = ds.filter(lambda x: x['download_success'])
# Optionally, print the first example to verify the data
print(ds[0])
```
## Details
The table below shows the number of tokens in each programming language using [SmolLM2](https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct) tokenizer.
| Language | Stack-Edu (B tokens) |
|------------|----------------------|
| Python | 21.8 |
| Cpp | 16.0 |
| Markdown | 14.0 |
| C | 11.1 |
| JavaScript | 11.1 |
| Java | 42.1 |
| SQL | 9.62 |
| PHP | 9.07 |
| C-Sharp | 8.87 |
| TypeScript | 3.03 |
| Shell | 3.13 |
| Swift | 1.83 |
| Go | 1.80 |
| Rust | 1.75 |
| Ruby | 1.61 |
## Dataset curation
To build Stack-Edu, we:
- Selected 15 largest programming languages from StarCoder2Data
- Trained 15 language-specific classifiers, using [StarEncoder](https://huggingface.co/bigcode/starencoder) model on synthetic annotations generated by Llama3-70B-Instruct. The classifiers for each language are available in this [collection](https://huggingface.co/collections/HuggingFaceTB/the-ultimate-collection-of-code-classifiers-67b5aa3eb8994a4b71453005).
- Applied a filtering threshold of 3 (out of 5) to retain highly educational content, except for Java, which performed best at threshold 2.
## Citation Information
```
@misc{allal2025smollm2smolgoesbig,
title={SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model},
author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Gabriel Martín Blázquez and Guilherme Penedo and Lewis Tunstall and Andrés Marafioti and Hynek Kydlíček and Agustín Piqueres Lajarín and Vaibhav Srivastav and Joshua Lochner and Caleb Fahlgren and Xuan-Son Nguyen and Clémentine Fourrier and Ben Burtenshaw and Hugo Larcher and Haojun Zhao and Cyril Zakka and Mathieu Morlon and Colin Raffel and Leandro von Werra and Thomas Wolf},
year={2025},
eprint={2502.02737},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2502.02737},
}
```
|