simple-python-synth / README.md
aemack's picture
final card
967c124 verified
|
Raw History Blame Contribute Delete
3.57 kB
metadata
license: apache-2.0
language:
  - en
tags:
  - code
  - python
  - synthetic
size_categories:
  - 10M<n<100M
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*.parquet
      - split: validation
        path: data/val-*.parquet

simple-python-synth

Synthetic, short, simple Python files, generated as an open stand-in for the "especially simple and repetitive idioms" component of the training data in Weight-sparse transformers have interpretable circuits (Gao et al., 2025, arXiv 2511.13653, appendix A.6). That component (10B tokens, written by GPT-4-base) was not released; this dataset imitates it with open models.

Size

Lengths are in the tinypython_2k tokenizer (see below).

split rows tokens
train (98 files) 38,967,435 6.63B
validation (2 files) 195,892 33.2M

By generator: Qwen2.5-Coder-7B 13.7M rows / 2.25B tokens, Qwen2.5-Coder-1.5B 25.4M rows / 4.41B tokens. By prompt style: pe 3.21B, mix 1.76B, tp 1.69B tokens. Mean length ~170 tokens.

Shuffle before training: the files are not shuffled. Each file holds samples from one or a few generator processes, so consecutive files alternate between the two models.

Generated in ~9 hours on 8x H200 (4 GPUs per model).

How it was made

  • Generators: base (not instruct) code models, Qwen/Qwen2.5-Coder-7B (FP8 weights) and Qwen/Qwen2.5-Coder-1.5B; the model column says which. Sampling: temperature 1.0, top-p 0.95, at most 768 generator tokens.
  • Prompts: few-shot in the generator's repository format: several short files, each <|file_sep|>name.py followed by the code, then <|file_sep|>new_name.py and the model writes that file; generation stops at the next file separator. Exemplars come from a pool of 3.9M short, simple files: 2.79M real files from Avelina/python-edu-cleaned and 1.11M functions from BertilBraun/TinyPython (description added as a docstring), all passing the filter below. The style column gives the prompt mix: pe (3-6 real files), tp (8-12 TinyPython functions), mix (both); name is the file name the model was asked to write (taken from another pool file).
  • Filter (every sample): parses as Python 3; 40-1024 tokens of the tinypython_2k tokenizer; at most 100 lines of at most 120 characters; block nesting at most 4; imports only from a small stdlib set; no literal with more than 24 elements; non-docstring string literals under 45% of the characters; under 1% non-ASCII; no heavy line repetition or extreme compressibility; at least 3 statements. Samples cut off by the length limit are dropped.
  • Dedup: exact, on the code with comments and blank lines removed (hash column); samples identical to a pool exemplar are dropped.
  • Split: ~0.5% of samples, chosen by hash, are in validation.

ntok is the length in the tinypython_2k tokenizer from openai/circuit_sparsity (circuit_sparsity/tiktoken_ext/tinypython.py; vocabulary files at https://openaipublic.blob.core.windows.net/circuit-sparsity/tinypython/).

Caveats

  • Not the paper's data: much weaker generators than GPT-4-base, and the exemplars steer the style toward beginner / exercise code.
  • The 1.5B samples are less coherent (docstrings that do not match the code, odd logic); filter on model if that matters.
  • Files are not executed; only parsed.