Lean PyTorch tooling for pre-pre-training language models on synthetic upstream tasks.
Project description
pptrain
pptrain is a small PyTorch- and HuggingFace-native library for pre-pretraining language models. Pre-pretraining involves training on synthetic tasks before standard language pretraining, with recent work [1] showing gains beyond what additional natural-language pretraining alone achieves.
Use a paper-backed preset as the starting point, then override only the few values you actually need for a local run or experiment. Alternatively, define custom task families by extending a flexible task abstraction and plugging in your own model adapter.
Install
pip install pptrain
Built-in Task Families
nca: Synthetic cellular-automata rollouts. The built-in presets follow the paper's12x12,10-state,2x2-patch setup and separate web-text versus code complexity bands [1].dyck: Balanced-bracket sequences that emphasize nested structure. The built-in presets scale bracket-type count and sequence length together across thek=8/16/32/64variants [2].procedural: Short algorithmic text tasks such as reverse, sort, set, union, and delete. The built-in presets mirror the paper's single-task-by-length grid for identity/reverse/sort/set/union/delete programs [3].simpler_tasks: Compact symbolic tasks like copy, search, set operations, and related transformations. The built-in presets cover unary-core, binary, and single-task benchmark settings rather than only one mixed sampler [4].lime: Induction, deduction, and abduction tasks aimed at mathematical reasoning. The built-in presets span100k,1M, and mixed5Mbudgets, plus single-mode induct/deduct/abduct variants [5].summarization: Synthetic document-transduction tasks that teach compression and selection. The built-in presets combine STEP-style sentence/document transforms with nonsense-style copy/keyword tasks and anOurTasks-style subset [6].
Each family ships with paper-backed presets and can also serve as a template for your own additions.
Quick Start
from pptrain import PrePreTrainer, RunConfig, create_task
from pptrain.integrations import HFCausalLMAdapter, HFModelConfig
trainer = PrePreTrainer(
task=create_task("simpler_tasks", {"preset": "paper_binary_1m", "sequence_count": 256, "eval_sequence_count": 64, "max_length": 128}),
model_adapter=HFCausalLMAdapter(HFModelConfig(model_name_or_path="sshleifer/tiny-gpt2", config_overrides={"n_positions": 128})),
run_config=RunConfig(output_dir="runs/smoke", max_steps=20, per_device_train_batch_size=8, per_device_eval_batch_size=8, logging_steps=5, save_steps=20, eval_steps=20),
)
bundle = trainer.fit().load_transfer_bundle()
For a full runnable version of this example, go to docs/quickstart.md.
Examples
- Preset-first test configs
- Minimal Python examples
- Full quickstart example
- Notes on adding or extending a task family
Custom Task Families
To add a custom task family, define how tasks are sampled, executed, and serialized, then register presets around that family. pptrain handles the trainer path, tokenizer-spec plumbing, transfer-bundle export, and Hugging Face integration.
Most symbolic or transduction-style additions can start from SymbolicTaskFamily; lower-level simulators can implement Task directly. For non-Hugging-Face architectures, use CallableCausalLMAdapter when you want full control over model construction, or VocabSizeCausalLMAdapter when the upstream model only depends on the synthetic tokenizer vocab size. See docs/extending.md and examples/custom_adapter.py.
Transfer
For downstream pretraining on a compatible architecture, applying a transfer bundle is straightforward. When parameter names, tokenizer sizes, or embedding layouts differ, use an explicit transfer policy to control what is copied, reinitialized, or skipped.
from pptrain.transfer import ReinitializeEmbeddingTransferPolicy
target_model = trainer.model_adapter.load_downstream_model()
report = ReinitializeEmbeddingTransferPolicy().apply_bundle(bundle, target_model)
print(report.loaded_parameter_count)
For custom modules where embedding names do not follow the HF interface, SkipParametersTransferPolicy lets you skip explicit parameter prefixes instead.
Analytics
Assess downstream transfer, compute-matched baseline comparisons, and basic representational measures (pairwise midlayer CKA, KL-divergence of predictions) with an analytics suite that produces plots and markdown/CSV reports for the built-in synthetic tasks.
# These example config files live in the repository checkout.
pptrain fit configs/nca_minimal.yaml --eval-config configs/eval_perplexity_smoke.yaml
pptrain replicate --test
Citations
- [1] Lee et al. 2026. Training Language Models via Neural Cellular Automata.
- [2] Ri and Tsuruoka. 2022. Pretraining with Artificial Language: Studying Transferable Knowledge in Language Models.
- [3] Jiang et al. 2026. Procedural Pretraining: Warming Up Language Models with Abstract Data.
- [4] Wu et al. 2022. Insights into Pre-training via Simpler Synthetic Tasks.
- [5] Wu et al. 2021. LIME: Learning Inductive Bias for Primitives of Mathematical Reasoning.
- [6] Krishna et al. 2021. Does Pretraining for Summarization Require Knowledge Transfer? and Nath et al. 2021 for the STEP-style synthetic summarization family.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pptrain-0.3.0.tar.gz.
File metadata
- Download URL: pptrain-0.3.0.tar.gz
- Upload date:
- Size: 106.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0e7a6a4704d3aaa2015a52fc5c9e199f01a8e8c033c0770a46f23635a51206d
|
|
| MD5 |
15b0e497816e6554b1e1621721b84335
|
|
| BLAKE2b-256 |
9f8b749790634b3d9a4a13647003796b67bd3081a82842dfa07e0ea3f01df3c5
|
Provenance
The following attestation bundles were made for pptrain-0.3.0.tar.gz:
Publisher:
publish.yml on Axym-Labs/pptrain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pptrain-0.3.0.tar.gz -
Subject digest:
a0e7a6a4704d3aaa2015a52fc5c9e199f01a8e8c033c0770a46f23635a51206d - Sigstore transparency entry: 1340473489
- Sigstore integration time:
-
Permalink:
Axym-Labs/pptrain@de7801a504a099d1e14dbbab4a64cbb36ecc8726 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Axym-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de7801a504a099d1e14dbbab4a64cbb36ecc8726 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pptrain-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pptrain-0.3.0-py3-none-any.whl
- Upload date:
- Size: 110.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9657c9f4cf27f7f484b65c5ac023d48f85940338bd4e0f64abd7030ee5159c65
|
|
| MD5 |
2ad4fa9de96519157ab77f2afb2a0fb3
|
|
| BLAKE2b-256 |
9643515ad4d03fe6819e9de10a35e9e7a409bd648e89701dbe8e1321c5b8f64e
|
Provenance
The following attestation bundles were made for pptrain-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on Axym-Labs/pptrain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pptrain-0.3.0-py3-none-any.whl -
Subject digest:
9657c9f4cf27f7f484b65c5ac023d48f85940338bd4e0f64abd7030ee5159c65 - Sigstore transparency entry: 1340473496
- Sigstore integration time:
-
Permalink:
Axym-Labs/pptrain@de7801a504a099d1e14dbbab4a64cbb36ecc8726 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Axym-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@de7801a504a099d1e14dbbab4a64cbb36ecc8726 -
Trigger Event:
workflow_dispatch
-
Statement type: