MiniMind Dense 64M GSM8K soft distillation
Full-parameter soft knowledge distillation from caspar/MiniMind-MoE-198M-A64M-Mixed-SFT-v1.0 into
caspar/MiniMind-Dense-64M-Mixed-SFT-v1.0. Exact source revisions are in sources.json.
This is an experimental small model; the reported metrics do not imply reliable mathematical reasoning.
Training
Use only the released GSM8K training subset: 6851 conversations,
7333 windows, 845130 assistant targets per epoch.
Identical 6400-token tokenizers. Frozen teacher, full-softmax forward KL:
loss = 0.5 * CE + 0.5 * T^2 * KL(teacher || student), temperature 1.5.
Assistant-only shifted targets; prompts/padding masked. 340-token windows,
stride 256, overlap targets counted once, final partial windows retained.
Continuation windows may not contain the full question.
Three epochs / 345 optimizer updates; microbatch 16 x accumulation 4,
normalized by actual target-token counts. AdamW, LR cosine 5e-6 to 5e-7,
weight decay .01, gradient clip 1, seed 42. BF16 computation, FP32 optimizer
weights, exported FP16 weights. A40 GPU. See settings.json and metrics.jsonl.
GSM8K test evaluation
All 1319 official main/test examples, released as validation_gsm8k, excluded
from training and checkpoint selection. Fixed final epoch, no test tuning.
Zero-shot greedy, max 256 new tokens and total context 340; exact-length batches
without padding. Overflow/invalid outputs remain in the denominator.
Prompt suffix: Solve step by step. End your answer with #### followed by the final number.
Empty think blocks are removed in training and inference.
| Model | Strict #### answer | Last-number fallback |
|---|---|---|
| Original Dense student | 13/1319 (0.99%) | 20/1319 (1.52%) |
| Distilled Dense | 12/1319 (0.91%) | 21/1319 (1.59%) |
Assistant-only test CE: 1.000488 -> 0.933341. Teacher KL at T=1.5: 0.593376 -> 0.455591. All generations and evaluation settings are included. Scores use the reloaded published FP16 checkpoint, not in-memory training weights. No claim of paraphrase-level or upstream-pretraining decontamination.
Loading
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "caspar/MiniMind-Dense-64M-GSM8K-SoftDistill-MoE-v1.0"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(
repo, trust_remote_code=True, torch_dtype=torch.float32,
).to("cuda").eval()
messages = [{"role": "user", "content": "What is 7 times 8?\nSolve step by step. End your answer with #### followed by the final number."}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, open_thinking=False)
text = text.replace("<think>\n\n</think>\n\n", "")
x = tokenizer(text, return_tensors="pt", add_special_tokens=False).input_ids.to("cuda")
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
y = model.generate(inputs=x, max_new_tokens=min(256, 340-x.shape[1]), do_sample=False, top_k=0, top_p=1., temperature=1.)
print(tokenizer.decode(y[0, x.shape[1]:], skip_special_tokens=True))
Use transformers==4.57.6 and torch>=2.6,<3. Custom MiniMind modeling code is
included. Base models/code are Apache-2.0; GSM8K data retains MIT terms.