Views
No views yet
google/gemma-2-2b by model surgery followed by a
recurrence-curriculum healing phase.num_steps).(1+w) fp32 RMSNorm, GeGLU, eager attention with attn/final logit soft-capping, and √d embedding
scaling; all handled by the converter).input → embed (×√d) → prelude (4) → [ adapter + recurrent core (6) ] × R → coda (4) → norm → lm_head
└────────── looped R times ──────────┘| Base model | Gemma-2-2b (26 layers) |
| Split (prelude / recurrent core / coda) | 4 / 6 / 4 (12 middle layers dropped) |
| Recurrence at inference | any num_steps; trained up to 16 |
| Gemma-2 specifics preserved | 4-norm sandwich, (1+w) RMSNorm, GeGLU, attn+final logit soft-capping (50/30), head_dim 256, √hidden embed scale |
| Params | ~2.3B |
model_type | huginn_raven |
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4repo = "irafm-llm/Recurrent-Gemma-2-2b"
5tok = AutoTokenizer.from_pretrained(repo)
6model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, torch_dtype=torch.bfloat16).cuda().eval()
7
8ids = tok("The history of mathematics is", return_tensors="pt").input_ids.cuda()
9out = model.generate(ids, max_new_tokens=40, do_sample=False,
10 num_steps=32, # <-- recurrence depth
11 tokenizer=tok, pad_token_id=tok.eos_token_id)
12print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))trust_remote_code=True is required (the repo bundles its own raven_modeling_minimal.py). Exposes
the full Huginn-0125 step API (embed_inputs, initialize_state, iterate_one_step,
predict_from_latents, …) — a drop-in for Huginn-0125 code / selective-recurrence control.1-sqrt mean-recurrence curriculum up to 16 and
truncated BPTT (last 8 passes). Eval loss (@rec 16): ~18 → ~2.9.1@article{mcleish2025teaching,
2 title={Teaching Pretrained Language Models to Think Deeper with Retrofitted Recurrence},
3 author={McLeish, Sean and Li, Ang and Kirchenbauer, John and Kalra, Dayal Singh and Bartoldson, Brian R. and Kailkhura, Bhavya and Schwarzschild, Avi and Geiping, Jonas and Goldstein, Tom and Goldblum, Micah},
4 journal={arXiv preprint arXiv:2511.07384}, year={2025}
5}