liamsi commited on
Commit
d6132b9
·
verified ·
1 Parent(s): 9e21cee

tiny-dlms-melon-maze: weights and card

Browse files
Files changed (4) hide show
  1. README.md +77 -0
  2. config.json +41 -0
  3. model.safetensors +3 -0
  4. tokenizer.json +1 -0
README.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: tiny-dlms
4
+ pipeline_tag: reinforcement-learning
5
+ tags:
6
+ - tiny-dlms
7
+ - decision-model
8
+ - from-scratch
9
+ - pytorch
10
+ - imitation-learning
11
+ - vision-transformer
12
+ - maze
13
+ ---
14
+
15
+ # tiny-dlms-melon-maze: Mēlon 8x128 (maze)
16
+
17
+ 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.
18
+
19
+ Written and trained from scratch in PyTorch (no Hugging Face `transformers`): tokenizer, Transformer, training.
20
+ Code, all the other checkpoints and the full benchmark: [GitHub](https://github.com/benisalla/tiny-dlms) · [project page](https://benisalla.github.io/tiny-dlms/).
21
+ A learning project, not a production model.
22
+
23
+ ## Usage
24
+
25
+ ```bash
26
+ pip install "tiny-dlm[hub] @ git+https://github.com/benisalla/tiny-dlms"
27
+ ```
28
+
29
+ ```python
30
+ import random, torch
31
+ from tiny_dlm import maze
32
+ from tiny_dlm.hub import from_pretrained
33
+ from tiny_dlm.vision import encode_options
34
+
35
+ model, tokenizer, config = from_pretrained("liamsi/tiny-dlms-melon-maze")
36
+ idx = encode_options(config["option_texts"], tokenizer)[None] # go up / down / left / right
37
+ mask = torch.ones(1, idx.size(1), dtype=torch.bool)
38
+ walls, player, goal = maze.new_maze(random.Random(0))
39
+ choice, probs = model.decide(maze.render(walls, player, goal)[None], idx, mask)
40
+ print(config["option_texts"][choice.item()])
41
+ ```
42
+
43
+ ## Model
44
+
45
+ | | |
46
+ |---|---|
47
+ | Layers x width | 8 x 128 (4 heads) + 1 layer where the options look at each other |
48
+ | Input | 48x48 colour image, 64 patches of 6x6 |
49
+ | Blocks | RMSNorm, RoPE, SwiGLU |
50
+ | Weights | 2.39 M |
51
+ | Training steps | 28,000 |
52
+ | Options | go up · go down · go left · go right |
53
+
54
+ ## Training
55
+
56
+ Imitation: mazes generated on the fly, the target is the shortest path, with detours so it learns to recover.
57
+
58
+ ## Results
59
+
60
+ | Player (200 unseen mazes) | Solved | Steps / shortest path |
61
+ |---|---|---|
62
+ | **this model** | **97.0%** | 1.00 |
63
+ | the teacher (shortest path) | 100.0% | 1.00 |
64
+ | greedy | 74.0% | 1.47 |
65
+ | random | 8.5% | 4.36 |
66
+
67
+ ## The tiny-dlms models
68
+
69
+ | Model | |
70
+ |---|---|
71
+ | [tiny-dlms-rhoa](https://huggingface.co/liamsi/tiny-dlms-rhoa) | the best Rhoa: pre-trained on 2 GB of web text, then fine-tuned |
72
+ | [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 |
73
+ | [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 |
74
+ | [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 |
75
+ | [tiny-dlms-melon-car](https://huggingface.co/liamsi/tiny-dlms-melon-car) | Mēlon driving CarRacing from pixels |
76
+ | [tiny-dlms-melon-car-small](https://huggingface.co/liamsi/tiny-dlms-melon-car-small) | the small Mēlon driving CarRacing from pixels |
77
+ | [tiny-dlms-melon-maze](https://huggingface.co/liamsi/tiny-dlms-melon-maze) | Mēlon solving mazes from pixels |
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "library": "tiny-dlms",
3
+ "kind": "melon",
4
+ "model_args": {
5
+ "block_size": 72,
6
+ "vocab_size": 10,
7
+ "n_layer": 8,
8
+ "n_cand_layer": 1,
9
+ "n_head": 4,
10
+ "n_embd": 128,
11
+ "drop_rate": 0.1,
12
+ "bias": false,
13
+ "pad_id": 0,
14
+ "sep_id": 3,
15
+ "pool": "candidate",
16
+ "n_kv_head": 0,
17
+ "head_dim": 0,
18
+ "norm_type": "rmsnorm",
19
+ "norm_eps": 1e-06,
20
+ "pos_encoding": "rope",
21
+ "rope_base": 10000.0,
22
+ "activation": "silu",
23
+ "gated_mlp": true,
24
+ "intermediate_size": 0
25
+ },
26
+ "stage": "maze",
27
+ "training_steps": 28000,
28
+ "image_args": {
29
+ "image_size": 48,
30
+ "patch_size": 6,
31
+ "channels": 3
32
+ },
33
+ "option_texts": [
34
+ "go up",
35
+ "go down",
36
+ "go left",
37
+ "go right"
38
+ ],
39
+ "params": 2385408,
40
+ "repo": "liamsi/tiny-dlms-melon-maze"
41
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afc0bf547a021021260e1ca8bed79f5043d4f4330963d343a6c0f9fe2fdeecfb
3
+ size 9548592
tokenizer.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"itos": ["<pad>", "<unk>", "<cls>", "<sep>", "<mask>", "down", "go", "left", "right", "up"]}