Skip to content

Commit 11eb878

Browse files
committed
Add static api/work.json and move pptrain article onto its project page
1 parent a66535b commit 11eb878

3 files changed

Lines changed: 84 additions & 37 deletions

File tree

‎scripts/prepare-static-routes.mjs‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,28 @@ const read = (dir, extension) => fs.existsSync(dir)
4848
.map((name) => fm(fs.readFileSync(path.join(dir, name), "utf8")))
4949
: [];
5050

51-
const items = [...read(generated, ".html"), ...read(markdown, ".md")]
52-
.filter(({ attributes }) => !attributes.draft && !attributes.external_url)
51+
const allItems = [...read(generated, ".html"), ...read(markdown, ".md")]
52+
.filter(({ attributes }) => !attributes.draft)
5353
.sort((a, b) => (a.attributes.rank ?? 999) - (b.attributes.rank ?? 999));
54+
const items = allItems.filter(({ attributes }) => !attributes.external_url);
55+
56+
// Static JSON endpoint listing the work shown on /work/, in display order.
57+
const apiDir = path.join(dist, "api");
58+
fs.mkdirSync(apiDir, { recursive: true });
59+
fs.writeFileSync(path.join(apiDir, "work.json"), `${JSON.stringify({
60+
source: `${origin}/work/`,
61+
items: allItems
62+
.filter(({ attributes }) => attributes.listed !== false)
63+
.map(({ attributes: a }) => ({
64+
slug: a.slug,
65+
title: a.title,
66+
eyebrow: a.eyebrow ?? null,
67+
category: a.category,
68+
summary: a.summary,
69+
date: a.date instanceof Date ? a.date.toISOString().slice(0, 10) : String(a.date),
70+
url: a.external_url ?? `${origin}/work/${a.slug}/`,
71+
})),
72+
}, null, 2)}\n`);
5473

5574
for (const { attributes } of items) {
5675
const route = `/work/${attributes.slug}/`;
@@ -73,4 +92,4 @@ const urls = ["/", "/work/", ...items.map(({ attributes }) => `/work/${attribute
7392
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls.map((route) => ` <url><loc>${origin}${route}</loc></url>`).join("\n")}\n</urlset>\n`;
7493
fs.writeFileSync(path.join(dist, "sitemap.xml"), sitemap);
7594

76-
console.log(`Prepared ${items.length + 1} static work routes and sitemap.xml`);
95+
console.log(`Prepared ${items.length + 1} static work routes, sitemap.xml, and api/work.json`);

‎src/content/latex/work/pptrain.tex‎

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,69 +32,91 @@
3232
\publicationaction{https://pypi.org/project/pptrain/}{Open package}%
3333
}
3434

35-
Pre-pretraining is a good idea trapped in an awkward workflow. The basic recipe is to train a language model on synthetic tasks before natural text, using tasks that may teach useful structure. Cellular automata, symbolic transformations, and mathematical primitives all fit this pattern. One hurdle to production use is that most of the work lives in paper-specific code, hidden data generators, and one-off training scripts. A second is verifying that the prepretrainer matches the intended method and improves subsequent training. The package \href{https://github.com/Axym-Labs/pptrain}{\texttt{pptrain}} addresses both:
35+
\section{Citation}
3636

37-
\section{Ready to use}
37+
\begin{verbatim}
38+
@misc{axym2026pptrain,
39+
author = {{Axym Labs}},
40+
title = {pptrain: A Library for Prepretraining},
41+
year = {2026},
42+
url = {https://github.com/Axym-Labs/pptrain}
43+
}
44+
\end{verbatim}
3845

39-
Install it via:
46+
\section{Overview}
47+
48+
Prepretraining initializes a language model on synthetic or abstract sequences before continuing training on natural text. \href{https://github.com/Axym-Labs/pptrain}{\texttt{pptrain}} exposes paper-derived task generators through common interfaces for upstream training, weight transfer, and evaluation. It installs with
4049

4150
\begin{verbatim}
4251
pip install pptrain
4352
\end{verbatim}
4453

45-
and start pre-pretraining with:
54+
The built-in families generate neural cellular automata rollouts (\texttt{nca}), balanced-bracket sequences (\texttt{dyck}), short programs (\texttt{procedural}), copy, set, and query transformations (\texttt{simpler\_tasks}), induction, deduction, and abduction problems (\texttt{lime}), and synthetic document transformations (\texttt{summarization}). Paper-derived presets expose configurable generation and dataset fields.
55+
56+
\section{Example: prepretrain a Hugging Face model}
57+
58+
The first example prepretrains a small GPT-2 on neural cellular automata rollouts and transfers the weights into a fresh downstream model. The embedding layer is reinitialized because the synthetic vocabulary differs from the natural-text one.
4659

4760
\begin{verbatim}
4861
from pptrain import PrePreTrainer, RunConfig, create_task
4962
from pptrain.integrations import HFCausalLMAdapter, HFModelConfig
63+
from pptrain.transfer import ReinitializeEmbeddingTransferPolicy
5064
5165
trainer = PrePreTrainer(
52-
task=create_task(
53-
"simpler_tasks",
54-
{
55-
"preset": "paper_binary_1m",
56-
"sequence_count": 256,
57-
"eval_sequence_count": 64,
58-
"max_length": 128,
59-
},
60-
),
66+
task=create_task("nca", {"preset": "smoke"}),
6167
model_adapter=HFCausalLMAdapter(
6268
HFModelConfig(model_name_or_path="sshleifer/tiny-gpt2")
6369
),
64-
run_config=RunConfig(output_dir="runs/initial", max_steps=20),
70+
run_config=RunConfig(output_dir="runs/nca", max_steps=20),
6571
)
66-
6772
bundle = trainer.fit().load_transfer_bundle()
73+
74+
target_model = trainer.model_adapter.load_downstream_model()
75+
policy = ReinitializeEmbeddingTransferPolicy()
76+
report = policy.apply_bundle(bundle, target_model)
77+
print(report.loaded_parameter_count)
6878
\end{verbatim}
6979

70-
\texttt{pptrain} packages several task families from the literature as reusable presets:
80+
\section{Example: bring your own architecture}
7181

72-
\begin{itemize}
73-
\tightlist
74-
\item \texttt{nca}: cellular-automata rollouts; tests whether simple dynamical systems can provide useful upstream structure.
75-
\item \texttt{dyck}: balanced-bracket languages; isolates nested and stack-like structure.
76-
\item \texttt{procedural}: abstract programs such as reverse, sort, set, union, and delete; tests algorithmic text transformations.
77-
\item \texttt{simpler\_tasks}: copy, search, set operations, and related symbolic transformations; breaks pretraining into small controlled operations.
78-
\item \texttt{lime}: induction, deduction, and abduction tasks; targets primitives of mathematical reasoning.
79-
\item \texttt{summarization}: synthetic document transformations; separates compression and selection from factual knowledge transfer.
80-
\end{itemize}
82+
The second example builds the upstream model from the synthetic vocabulary size, prepretrains it on balanced-bracket sequences, and copies every parameter except the token embedding and output head into the downstream model.
8183

82-
The presets are based on suggestions from the original papers and implementation, but can be heavily customized: for example, \texttt{nca} exposes grid size, number of states, patch size, perception and hidden dimensions, rollout stride and initial rollout steps, train/eval rule counts, sequence counts, maximum length, gzip-complexity band, and per-epoch regeneration.
84+
\begin{verbatim}
85+
from transformers import GPT2Config, GPT2LMHeadModel
86+
from pptrain import PrePreTrainer, RunConfig, create_task
87+
from pptrain.integrations import VocabSizeCausalLMAdapter
88+
from pptrain.transfer import SkipParametersTransferPolicy
8389
84-
\section{Reference parity}
8590
86-
Production use also requires a correctness check. A changed generator, tokenizer, or serialization no longer tests the mechanism from the paper, so \texttt{pptrain} includes reference-parity utilities that compare local outputs against original-source fixtures for LIME, synthetic summarization, procedural pretraining, and NCA pre-pretraining.
91+
def gpt2(vocab_size: int) -> GPT2LMHeadModel:
92+
return GPT2LMHeadModel(GPT2Config(
93+
n_layer=2, n_head=2, n_embd=64,
94+
n_positions=128, vocab_size=vocab_size,
95+
))
8796
88-
These checks are exact where they should be exact: normalized examples or token sequences must match the reference output.
8997
90-
\section{Empirical testing}
98+
trainer = PrePreTrainer(
99+
task=create_task("dyck", {"preset": "smoke"}),
100+
model_adapter=VocabSizeCausalLMAdapter(
101+
create_prepretrain_model=gpt2,
102+
load_downstream_model=lambda: gpt2(vocab_size=50257),
103+
),
104+
run_config=RunConfig(output_dir="runs/dyck", max_steps=20),
105+
)
106+
bundle = trainer.fit().load_transfer_bundle()
91107
92-
To determine whether a synthetic task transfers in a particular model and training setup, users can run the evaluation and replication utilities through the same interface used for training. The library supports downstream transfer evaluation, compute-matched natural warmups, diagnostic metrics, plots, CSVs, and Markdown reports.
108+
target_model = gpt2(vocab_size=50257)
109+
policy = SkipParametersTransferPolicy(
110+
skip_parameter_prefixes=("transformer.wte", "lm_head"),
111+
)
112+
report = policy.apply_bundle(bundle, target_model)
113+
print(report.loaded_parameter_count)
114+
\end{verbatim}
93115

94-
\section{Extensibility}
116+
\section{Verify and evaluate}
95117

96-
Users can write their own pre-pretraining logic by implementing \texttt{SymbolicTaskFamily}: define how examples are sampled, executed, serialized, and tokenized. If the task needs a custom dataset or loss path, implement \texttt{Task} directly.
118+
Reference-parity tests compare normalized examples or token sequences with fixtures produced by the original LIME, synthetic-summarization, procedural-pretraining, and NCA implementations. The replication interface compares downstream training after synthetic initialization with both random initialization and a natural-text warmup, then exports the resulting metrics, plots, tables, and reports.
97119

98-
The core abstraction is a task family. It samples an example, executes it if needed, serializes it into tokens, and exposes a tokenizer specification. The remaining path is ordinary model training: build a dataset, train a Hugging Face causal language model, save the checkpoint, and export a transfer bundle.
120+
A custom symbolic generator implements \texttt{SymbolicTaskFamily} by defining how an example is sampled, executed, serialized, and tokenized. A method that requires a different dataset construction or loss implements \texttt{Task} directly.
99121

100122
\end{document}

‎tests/indexing-routes.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ for (const route of routes) {
4747
);
4848
}
4949

50+
const workApi = JSON.parse(fs.readFileSync(path.join(dist, "api", "work.json"), "utf8"));
51+
assert.ok(workApi.items.length > 0, "api/work.json must list the work items");
52+
for (const item of workApi.items) {
53+
assert.ok(item.title && item.summary && /^https:\/\//.test(item.url), `api/work.json entry ${item.slug} is incomplete`);
54+
}
55+
5056
console.log("Axym indexing route test: PASS");

0 commit comments

Comments
 (0)