GriffithLLM-TinyStories

Small GPT-style language models trained on TinyStories, built to test replacing the Transformer feed-forward network (FFN) with logic gates (LUTs) from Griffith. Attention, embeddings, LayerNorm and the output head stay floating-point; only the FFN is swapped.

The models write short children's stories in English. They cannot chat, answer questions, or write other languages.

Code: manruho/GriffithLLM. The checkpoints need this code; they are not transformers models.

TinyStories の短い英語の物語を書く小型 GPT です。Transformer の FFN だけを Griffith の論理ゲート(LUT)に置き換えた版と、実数 FFN 版・FFN なし版を同じ条件で学習して比べています。会話や質問応答、日本語はできません。

Models

All four share the same setup: 6 layers, 8 heads, d_model 256, context 256 tokens, byte-level BPE with a 4096-token vocabulary, batch 32, 16,000 steps (about 0.27 epoch), one seed. Perplexity is on the full TinyStories validation split (4.8M tokens), with the LUT models evaluated as discrete Boolean circuits.

Folder FFN Validation ppl Parameters Training speed (T4)
fp floating-point (baseline) 5.50 5.85M 0.11 s/step
lut_wide LUT, 1024 input bits, width 2048 6.64 7.82M 0.75 s/step
lut LUT, 512 input bits, width 1024 6.72 5.26M 0.40 s/step
noffn none (attention only, control) 7.27 2.70M 0.06 s/step

The LUT FFN recovers 0.55 of the 1.77 ppl gap between "no FFN" and the floating-point FFN (31%); doubling its width recovers 0.63 (35%).

Each LUT FFN is Linear -> binarize -> 2 layers of 2-input LUTs -> Linear, scaled by a learned scalar initialized to zero (ReZero). Training uses hard gate selection with straight-through gradients, so the training-time forward pass equals the discretized circuit.

Usage

git clone https://github.com/manruho/GriffithLLM && cd GriffithLLM
uv sync --extra cpu
uvx --from huggingface_hub hf download Monruho/GriffithLLM-TinyStories --local-dir models
uv run python -m griffith_llm.generate --ckpt models/lut/best.pt \
  --prompt "Once upon a time" --max-new-tokens 200 --top-k 40

Each best.pt holds the model config, weights and tokenizer, and is loaded with torch.load(..., weights_only=True). log.jsonl is the training log and summary.json has the measurements and sample outputs for all four models.

Sample from lut (prompt Once upon a time, temperature 0.8, top-k 40):

Once upon a time there was a little girl named Lucy. Lucy liked to explore the forest. She wanted to find something to collect. She went into the forest and found a big, juicy apple. Lucy picked up the apple and put it in her pocket.

Limitations

  • Stories are grammatical but often lose the plot or contradict themselves.
  • Results are from one seed, and no model had converged at 16,000 steps.
  • Most parameters of the LUT FFN are in its floating-point input and output matrices; lut has 2048 gates per layer and lut_wide has 4096. The models are not a full logic-gate network.
  • On GPU and CPU the LUT models are slower than the floating-point baseline.

Training data and license

Trained only on TinyStories (Eldan & Li, 2023, arXiv:2305.07759), which is released under CDLA-Sharing-1.0. Griffith is Apache-2.0. These weights are released under Apache-2.0.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train Monruho/GriffithLLM-TinyStories

Paper for Monruho/GriffithLLM-TinyStories