tiny-dlms-melon-maze: weights and card
Browse filesFiles changed (4)
- README.mdAdded+77
- config.jsonAdded+41
- model.safetensorsAdded+3
- tokenizer.jsonAdded+1
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677---license: mitlibrary_name: tiny-dlmspipeline_tag: reinforcement-learningtags:- tiny-dlms- decision-model- from-scratch- pytorch- imitation-learning- vision-transformer- maze---
# tiny-dlms-melon-maze: Mēlon 8x128 (maze)
Mēlon (μῆλον, the golden apple) is a tiny decision model that looks at an **image** and picks one option written in words. This is Mēlon solving mazes from pixels. The options are scored all at once and a softmax gives one probability each; nothing is generated.
Written and trained from scratch in PyTorch (no Hugging Face `transformers`): tokenizer, Transformer, training.Code, all the other checkpoints and the full benchmark: [GitHub](https://github.com/benisalla/tiny-dlms) · [project page](https://benisalla.github.io/tiny-dlms/).A learning project, not a production model.
## Usage
```bashpip install "tiny-dlm[hub] @ git+https://github.com/benisalla/tiny-dlms"```
```pythonimport random, torchfrom tiny_dlm import mazefrom tiny_dlm.hub import from_pretrainedfrom tiny_dlm.vision import encode_options
model, tokenizer, config = from_pretrained("liamsi/tiny-dlms-melon-maze")idx = encode_options(config["option_texts"], tokenizer)[None] # go up / down / left / rightmask = torch.ones(1, idx.size(1), dtype=torch.bool)walls, player, goal = maze.new_maze(random.Random(0))choice, probs = model.decide(maze.render(walls, player, goal)[None], idx, mask)print(config["option_texts"][choice.item()])```
## Model
| | ||---|---|| Layers x width | 8 x 128 (4 heads) + 1 layer where the options look at each other || Input | 48x48 colour image, 64 patches of 6x6 || Blocks | RMSNorm, RoPE, SwiGLU || Weights | 2.39 M || Training steps | 28,000 || Options | go up · go down · go left · go right |
## Training
Imitation: mazes generated on the fly, the target is the shortest path, with detours so it learns to recover.
## Results
| Player (200 unseen mazes) | Solved | Steps / shortest path ||---|---|---|| **this model** | **97.0%** | 1.00 || the teacher (shortest path) | 100.0% | 1.00 || greedy | 74.0% | 1.47 || random | 8.5% | 4.36 |
## The tiny-dlms models
| Model | ||---|---|| [tiny-dlms-rhoa](https://huggingface.co/liamsi/tiny-dlms-rhoa) | the best Rhoa: pre-trained on 2 GB of web text, then fine-tuned || [tiny-dlms-rhoa-small](https://huggingface.co/liamsi/tiny-dlms-rhoa-small) | the small Rhoa, pre-trained on 2 GB of web text, then fine-tuned || [tiny-dlms-rhoa-gpt2](https://huggingface.co/liamsi/tiny-dlms-rhoa-gpt2) | Rhoa with GPT-2 blocks (LayerNorm, learned positions, GELU), pre-trained on 2 GB of web text || [tiny-dlms-rhoa-base](https://huggingface.co/liamsi/tiny-dlms-rhoa-base) | the pre-trained Rhoa before fine-tuning: masked-token prediction on 2 GB of web text || [tiny-dlms-melon-car](https://huggingface.co/liamsi/tiny-dlms-melon-car) | Mēlon driving CarRacing from pixels || [tiny-dlms-melon-car-small](https://huggingface.co/liamsi/tiny-dlms-melon-car-small) | the small Mēlon driving CarRacing from pixels || [tiny-dlms-melon-maze](https://huggingface.co/liamsi/tiny-dlms-melon-maze) | Mēlon solving mazes from pixels |1234567891011121314151617181920212223242526272829303132333435363738394041{ "library": "tiny-dlms", "kind": "melon", "model_args": { "block_size": 72, "vocab_size": 10, "n_layer": 8, "n_cand_layer": 1, "n_head": 4, "n_embd": 128, "drop_rate": 0.1, "bias": false, "pad_id": 0, "sep_id": 3, "pool": "candidate", "n_kv_head": 0, "head_dim": 0, "norm_type": "rmsnorm", "norm_eps": 1e-06, "pos_encoding": "rope", "rope_base": 10000.0, "activation": "silu", "gated_mlp": true, "intermediate_size": 0 }, "stage": "maze", "training_steps": 28000, "image_args": { "image_size": 48, "patch_size": 6, "channels": 3 }, "option_texts": [ "go up", "go down", "go left", "go right" ], "params": 2385408, "repo": "liamsi/tiny-dlms-melon-maze"}123version https://git-lfs.github.com/spec/v1oid sha256:afc0bf547a021021260e1ca8bed79f5043d4f4330963d343a6c0f9fe2fdeecfbsize 95485921{"itos": ["<pad>", "<unk>", "<cls>", "<sep>", "<mask>", "down", "go", "left", "right", "up"]}README.mdAdded+77
config.jsonAdded+41
model.safetensorsAdded+3
tokenizer.jsonAdded+1