Puppet is a Language Model (LM) that I've been working on for the past few months. It combines Mamba with an experimental Stepped Weight Generation architecture.
Model definition:
main.py
Pretrained weights: Hugging Face
Due to compute limitations, I was only able to train the model for ~3.5 billion tokens. While this follows the Chinchilla rule
While I may resume pre-training in the future, Puppet-166M currently achieves an acc_norm score of
I originally started Puppet as an experiment, aiming to train a functioning Language Model using Weight Generation, without relying on Attention.
flowchart TB
A([Input Tokens]) --> B[Embedding]
B --> B1(RMSNorm)
B1 --> C(RMSNorm)
subgraph Block ["Block"]
subgraph Bundle ["Bundle"]
C --> C1[Mamba2]
C1 --> C2(RMSNorm)
C2 --> D[MLP] & C3(Split into matrix_div chunks)
subgraph WeightGen ["WeightGen"]
D --> E[Bias Generator]
D --> F[Weight Generator]
C3 --> G((MatMul))
F --> G
G --> G1(Reconstruct)
G1 --> H((+))
E --> H
H --> I[Shuffle]
end
end
end
Bundle --> |"Repeated matrix_div times per Block"| Bundle
Block --> |"Repeated per layer"| Block
I --> X(RMSNorm)
X --> Y[Head]
Y --> Z([Output Logits])
style Block fill:#101010,stroke:#555555,color:white
style Bundle fill:#202020,stroke:#555555,color:white
style WeightGen fill:#303030,stroke:#555555,color:white
classDef linear fill:cornflowerblue,color:white,stroke:steelblue
classDef context fill:mediumpurple,color:white,stroke:indigo
classDef norm fill:slategray,color:white,stroke:dimgray
classDef process fill:teal,color:white,stroke:darkslategray
classDef math fill:goldenrod,color:white,stroke:darkgoldenrod
classDef io fill:seagreen,color:white,stroke:darkgreen
class B,E,F,D,I,Y, linear
class C1 context
class B1,C,C2,X, norm
class C3,G1, process
class G,H, math
class A,Z, io
linkStyle default stroke:#ffffff,stroke-width:1.5px
The idea behind this architecture is to generate transformations specific to the current latent vector, rather than relying on a fixed set of weights. Several existing architectures currently achieve this, typically by selecting between multiple pre-existing sets of parameters. Puppet instead generates a unique weight matrix and bias vector using the latent as the input. This approach is known as Weight Generation.
Despite the benefits, full Weight Generation is rarely used in modern LLMs, largely due to its substantial parameter cost. To generate a weight matrix for a latent of
My previous iteration of Puppet used this full Weight Generation approach, exposing some of its practical limitations. Training suffered from a stalled validation loss of approximately
To solve these issues, I staggered Weight Generation in Puppet-166M. Each Block contains multiple Bundle classes, each containing, in order: a Mamba2 module, Weight Generator, and shuffle matrix.
The Weight Generator only generates a fraction of the full matrix_div
This is equivalent to multiplying the latent by a matrix containing dense blocks along its diagonal. The shuffle matrix allows information from different sections of the latent to interact with every other section across sequential transforms, fixing the main flaw of smaller independent dense blocks.
By staggering Weight Generation, the parameter cost is distributed across multiple smaller generators, allowing me to interleave more context-mixing Mamba2 modules between the sequential transforms, whilst still retaining a fully generated
I trained Puppet-166M for approximately 3.5 billion tokens over the course of a month (intermittently), from random initialisation to a validation loss of
Training was highly inefficient, as this was my first converged model. I varied the effective batch size several times before settling on
One of the main flaws during training was likely the dataset choice. I used several shards from the
Training lasted
$14,000$ optimiser steps
Puppet-166M achieves a HellaSwag score of Pythia-160M and GPT-2 Small. Here is a comparison of how Puppet-166M performs against these mainstream models, along with their parameter counts and training tokens.
| Model | HellaSwag | PIQA | WinoGrande | Arc Easy | Parameters | Training Tokens |
|---|---|---|---|---|---|---|
Puppet-166M |
|
|
|
|
||
Pythia-160M |
|
|
|
|
||
GPT-2 Small |
|
|
|
|
Accuracy shown as
acc_normwhere available, otherwiseacc
Puppet-166M was an experiment to test whether an unconventional architecture (Weight Generation + Mamba2) could compete with, or even outperform, similarly sized models. Despite falling behind smaller models in multiple benchmarks, Puppet-166M remained within Arc Easy. For my first converged (and my largest trained) model, I would not consider this a failure.
I may continue training in the future, or develop a revised variant. Were I to retrain, these would be the main issues I would address:
- Use a more evenly distributed FineWeb sample rather than shards from a single year
- Train for much longer – at least ~
$10$ billion tokens - Use a consistent WSD training schedule
- Improve context mixing, either through more Mamba layers or an adapted variant
This project is licensed under the MIT License