初始化项目,由ModelHub XC社区提供模型

Model: mrothroc/mixlab-gpt2-strict-small-replica
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-10-13 10:24:19 +08:00
commit f23497761e
9 changed files with 82524 additions and 0 deletions

35
.gitattributes vendored Normal file
View File

@@ -0,0 +1,35 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text

116
README.md Normal file
View File

@@ -0,0 +1,116 @@
---
license: mit
language:
- en
library_name: transformers
tags:
- babylm
- babylm-2026
- gpt2
- mixlab
- reproduction
- causal-language-model
datasets:
- BabyLM-community/BabyLM-2026-Strict-Small
pipeline_tag: text-generation
---
# mixlab reproduction of the BabyLM 2026 GPT-2 Strict-Small baseline
A faithful, from-scratch reproduction of the **official BabyLM 2026 GPT-2 *Strict-Small* baseline**
([`BabyLM-community/babylm-baseline-10m-gpt2`](https://huggingface.co/BabyLM-community/babylm-baseline-10m-gpt2)),
trained entirely on a **single Apple M1 Max GPU** with [**mixlab**](https://github.com/mrothroc/mixlab), an
open Metal/MLX trainer, on the same 10M-word 2026 Strict-Small corpus the organizers use (a data-identical
reproduction).
This model reproduces the baseline as a reproducibility and efficiency study. The companion GitHub repo has the
full recipe, configs, scripts, and per-task eval reports:
[mixlab-babylm-gpt2](https://github.com/mrothroc/mixlab-babylm-gpt2).
## Faithfulness: per-component reproduction
For the six zero-shot components, both the reference baseline and this reproduction were scored through one
identical eval harness ([`babylm-org/babylm-eval`](https://github.com/babylm-org/babylm-eval) @ `3bf5142`,
causal backend); the reference column there is our within-harness re-evaluation of the official baseline, and
it reproduces the official published numbers. GLUE is the exception (see †).
| Component | Reference baseline | This reproduction | Δ |
|---|---:|---:|---:|
| BLiMP | 66.35 | 65.86 | −0.49 |
| BLiMP-supplement | 57.07 | 58.04 | +0.97 |
| EWoK | 49.23 | 49.30 | +0.07 |
| COMPS | 51.72 | 52.05 | +0.33 |
| reading (eye+SPR) | 6.50 | 7.15 | +0.65 |
| GLUE (macro) † | 63.62 | 64.15 | +0.53 |
| entity tracking ‡ | 13.90 | 25.99 | +12.09 |
Within about one point on every stable component.
† **GLUE**: the reproduction was fine-tuned and scored here; the reference (63.62) is the official published
baseline (GPT-2 model card per-task GLUE), not re-fine-tuned locally.
‡ **entity tracking** is a length-bias artifact (both models near chance); the gap is not a real capability
difference and is excluded from any aggregate claim. AoA (age-of-acquisition) is forfeited (0): the board scores it from a per-checkpoint surprisal trajectory submitted with the predictions, which this reproduction's submission does not include. Separately, the AoA scorer has a confirmed, still-open upstream bug — a log2/bits random-chance baseline with a hardcoded ~300k vocabulary instead of the model's actual size ([babylm-org/babylm-eval#2](https://github.com/babylm-org/babylm-eval/issues/2)) — which doesn't zero out small-vocab models (the reference scores 35.68 through it) but makes the metric noise-dominated and extraction-sensitive (one fixed model spans ~12–36). For both reasons we report per-component and exclude AoA.
## Architecture (read from the weights)
The exact architecture is in this repo's
[`config.json`](https://huggingface.co/mrothroc/mixlab-gpt2-strict-small-replica/blob/main/config.json) (the
exported HF model config); the full mixlab spec (architecture **and** training recipe) is in
[`training_config.mixlab.json`](https://huggingface.co/mrothroc/mixlab-gpt2-strict-small-replica/blob/main/training_config.mixlab.json).
A vanilla GPT-2 Small, ≈98M params (16,384 vocab × 768 dim, tied to the output head). The reference model
card's "124M" is the 50k-vocab number; with the 16k BabyLM vocab the real model is 98,425,344 params.
- 12 layers, hidden 768, 12 heads, context 1024, tied embeddings
- Learned absolute position embeddings (GPT-2 WPE)
- GELU (`gelu_new`, tanh approximation) feed-forward, intermediate 3072
- Pre-LayerNorm (eps 1e-5) with affine weight+bias, plus a final LayerNorm
- Standard causal self-attention with attention + projection biases
- Dropout 0.1 (embedding, residual, attention), applied during training
- GPT-2 weight initialization: normal(0, 0.02), residual `c_proj` scaled by 1/√(2·n_layer)
Exported as a native `GPT2LMHeadModel`; native↔HF logit parity verified (≈3e-8).
## Training
- **Trainer:** mixlab v0.40.0 (`-mode arch`), Metal/MLX, single Apple **M1 Max** (32-core GPU, 64 GB unified memory), ≈11h wall-clock (varies across Apple chip generations), seed 42, fp32
- **Data:** the 2026 Strict-Small corpus (≈10M words → 18M tokens), full corpus, tokenized whole-block then
sliced into 512-token chunks; each chunk framed as `<s>` + chunk + `</s>` (the reference convention)
- **Optimizer:** AdamW (betas 0.9/0.999, eps 1e-8), lr 5e-5, **no weight decay**, grad-clip 1.0
- **Schedule:** 21,300 steps (~9.7 epochs over the ~18M-token corpus), batch 16 × 514-token sequences (512 content + `<s>`/`</s>`), warmup 213 + cosine decay
- **Tokenizer:** the reference 16,384-vocab tokenizer (`<unk>`=0, `<s>`=1, `</s>`=2, `<pad>`=3, `<mask>`=4)
## Use
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("mrothroc/mixlab-gpt2-strict-small-replica")
m = AutoModelForCausalLM.from_pretrained("mrothroc/mixlab-gpt2-strict-small-replica")
```
## Reproduce
The full recipe (data prep, train, export, parity, eval), configs, and scripts are in the
[companion GitHub repo](https://github.com/mrothroc/mixlab-babylm-gpt2). One command per step; ≈11h training
on an M1 Max.
## Implementation Notes
- This reproduces the **2026** GPT-2 baseline on the **2026** Strict-Small corpus (data-identical).
- **Weight initialization** was the remaining mismatch: arch, recipe, corpus, and forward (export) parity all
matched the reference as far as verified, yet BLiMP was 5.7 points low until the GPT-2 init scheme (normal
0.02 + residual c_proj scaling) was
matched. Validation loss gave no warning (across our runs it did not track BLiMP), so it does not reveal an
init-driven generalization gap.
- Trained in fp32 on Apple silicon; numerical differences from a CUDA run are not characterized.
- Single training seed; the official seed is unknown, so a residual point or two on BLiMP is expected.
- Zero-shot faithfulness within one pinned harness; GLUE compares our fine-tune to the official published
reference score. Absolute scores can differ across harness versions.
## Links
- Trainer: [mixlab](https://github.com/mrothroc/mixlab)
- Reference: [`BabyLM-community/babylm-baseline-10m-gpt2`](https://huggingface.co/BabyLM-community/babylm-baseline-10m-gpt2)
- Companion recipe: [mixlab-babylm-gpt2](https://github.com/mrothroc/mixlab-babylm-gpt2)
For the story behind it, read [I Built an ML Architecture Lab in Go](https://michael.roth.rocks/blog/mixlab/).

27
config.json Normal file
View File

@@ -0,0 +1,27 @@
{
"model_type": "gpt2",
"architectures": [
"GPT2LMHeadModel"
],
"vocab_size": 16384,
"n_positions": 1024,
"n_ctx": 1024,
"n_embd": 768,
"n_layer": 12,
"n_head": 12,
"n_inner": 3072,
"activation_function": "gelu_new",
"resid_pdrop": 0.1,
"embd_pdrop": 0.1,
"attn_pdrop": 0.1,
"layer_norm_epsilon": 0.00001,
"initializer_range": 0.02,
"scale_attn_weights": true,
"scale_attn_by_inverse_layer_idx": false,
"reorder_and_upcast_attn": false,
"tie_word_embeddings": true,
"pad_token_id": 3,
"eos_token_id": 2,
"bos_token_id": 1,
"unk_token_id": 0
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1617b113ef12b1eb787d6a34688456539fb79830b0d0b25ae93e8d5f0a06b8fc
size 444048248

7
special_tokens_map.json Normal file
View File

@@ -0,0 +1,7 @@
{
"bos_token": "\u003cs\u003e",
"eos_token": "\u003c/s\u003e",
"mask_token": "\u003cmask\u003e",
"pad_token": "\u003cpad\u003e",
"unk_token": "\u003cunk\u003e"
}

81029
tokenizer.json Normal file

File diff suppressed because it is too large Load Diff

60
tokenizer_config.json Normal file
View File

@@ -0,0 +1,60 @@
{
"added_tokens_decoder": {
"0": {
"content": "\u003cunk\u003e",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"1": {
"content": "\u003cs\u003e",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"2": {
"content": "\u003c/s\u003e",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"3": {
"content": "\u003cpad\u003e",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"4": {
"content": "\u003cmask\u003e",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
}
},
"bos_token": "\u003cs\u003e",
"bos_token_id": 1,
"clean_up_tokenization_spaces": false,
"cls_token": null,
"eos_token": "\u003c/s\u003e",
"eos_token_id": 2,
"extra_special_tokens": {},
"mask_token": "\u003cmask\u003e",
"mask_token_id": 4,
"model_max_length": 1024,
"pad_token": "\u003cpad\u003e",
"pad_token_id": 3,
"sep_token": null,
"tokenizer_class": "PreTrainedTokenizer",
"unk_token": "\u003cunk\u003e",
"unk_token_id": 0
}

151
training_config.mixlab.json Normal file
View File

@@ -0,0 +1,151 @@
{
"name": "gpt2_strict_small_gpt2init",
"model_dim": 768,
"vocab_size": 16384,
"seq_len": 514,
"max_positions": 1024,
"mlp_mult": 4.0,
"tie_embeddings": true,
"norm_type": "layernorm",
"norm_affine": true,
"norm_eps": 1e-05,
"positional_embedding": "learned_absolute",
"embedding_dropout": 0.1,
"hidden_dropout": 0.1,
"attn_dropout": 0.1,
"hf_export_format": "gpt2",
"blocks": [
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
},
{
"type": "plain",
"heads": 12,
"attention_mask": "causal",
"attn_bias": true,
"ffn_activation": "gelu_new",
"ffn_pre_norm": true,
"ffn_bias": true
}
],
"training": {
"objective": "causal",
"optimizer": "adamw",
"lr": 5e-05,
"weight_decay": 0.0,
"beta1": 0.9,
"beta2": 0.999,
"epsilon": 1e-08,
"grad_clip": 1.0,
"steps": 21300,
"warmup_steps": 213,
"hold_steps": 0,
"warmdown_steps": 0,
"min_lr_fraction": 1e-06,
"batch_tokens": 8224,
"compute_dtype": "float32",
"seed": 42,
"example_framing": {
"content_len": 512,
"bos_id": 1,
"eos_id": 2
},
"weight_init": "gpt2"
}
}

1096
weight_map.json Normal file

File diff suppressed because it is too large Load Diff