deerfieldgreen/shika-9.5M
A 9.5M-parameter character-level language model trained from scratch with
MiniLLM Lab for educational purposes.
The architecture is Llama-style, so it loads with the standard LlamaForCausalLM class (no
trust_remote_code).
Architecture
| Layers | 6 |
| Hidden size | 384 |
| Attention heads | 6 query / 2 key-value (grouped-query attention) |
| Feed-forward | SwiGLU, 1024 hidden |
| Normalization | RMSNorm (pre-norm) |
| Positions | RoPE (θ = 10000) |
| Context length | 256 characters |
| Vocabulary | 158 characters |
| Tied embeddings | yes |
Training
- Data: ~102 MB mixed English corpus: Tiny Shakespeare, WikiText-2, a TinyStories subset, a Simple English Wikipedia slice, Python code (codeparrot-clean-valid) and project docs. Characters seen fewer than 100 times were removed.
- Steps: 10000 × 32 sequences × 256 characters (≈ 82M characters, about one epoch)
- Optimizer: AdamW, lr 0.001 with 500 warmup steps and cosine decay, weight decay 0.1, gradient clipping 1.0, dropout 0.1
- Hardware: Apple M3 Pro (MPS)
- Validation loss: 0.901 nats/char (perplexity 2.46)
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("deerfieldgreen/shika-9.5M")
model = AutoModelForCausalLM.from_pretrained("deerfieldgreen/shika-9.5M")
inputs = tok("Once upon a time", return_tensors="pt")
out = model.generate(**inputs, max_new_tokens=200, do_sample=True, temperature=0.8, top_k=50)
print(tok.decode(out[0]))
Keep prompt + generated text within 256 characters: the model was never trained on longer sequences.
Limitations
- Tiny model; text is fluent at the word and sentence level but loses coherence over a paragraph.
- Character-level tokens: one token per character, no BOS/EOS tokens.
- Base model only: no instruction tuning, no safety tuning.