anakin87 commited on
Commit
64241ff
·
verified ·
1 Parent(s): 59b12dc

Initial upload

Browse files
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: reinforcement-learning
4
+ tags:
5
+ - vizdoom
6
+ - doom
7
+ - reinforcement-learning
8
+ - ppo
9
+ - behavior-cloning
10
+ - modernbert
11
+ datasets:
12
+ - anakin87/doom-defend-the-center-100k-oracle
13
+ model-index:
14
+ - name: tiny-doom-defender
15
+ results:
16
+ - task:
17
+ type: reinforcement-learning
18
+ name: reinforcement-learning
19
+ dataset:
20
+ name: doom_defend_the_center
21
+ type: doom_defend_the_center
22
+ metrics:
23
+ - type: mean_kills
24
+ value: 23.12 +/- 2.81
25
+ name: mean_kills
26
+ verified: false
27
+ ---
28
+
29
+ # tiny-doom-defender
30
+
31
+ ![cover](https://github.com/anakin87/tiny-doom-defender/blob/main/assets/cover.png?raw=true)
32
+
33
+ A **1.1M-parameter** ModernBERT encoder that plays VizDoom's *Defend the Center* in real time on a CPU from pixels alone.
34
+
35
+ Inspired from [VAGOsolutions/SauerkrautLM-Doom-MultiVec-1.3M](https://huggingface.co/VAGOsolutions/SauerkrautLM-Doom-MultiVec-1.3M).
36
+
37
+ The model underwent SFT from a programmatic oracle and has been refined with PPO.
38
+
39
+ 📝 Read the full story: [blog post](ADD_LINK) · 💻 [GitHub repo](https://github.com/anakin87/tiny-doom-defender)
40
+
41
+
42
+ ## Checkpoints in this repo
43
+
44
+ | Checkpoint | Path | Training | Mean kills | σ | Size |
45
+ | --- | --- | --- | ---: | ---: | ---: |
46
+ | **tiny-doom-defender** (default) | *root* | SFT + PPO | 23.12 | 2.81 | 4.4 MB |
47
+ | tiny-doom-defender-sft | `sft/` | SFT only | 22.19 | 3.76 | 4.4 MB |
48
+ | tiny-doom-defender-int8 | `int8/` | SFT + PPO, int8 | 23.13 | 2.78 | **1.1 MB** |
49
+
50
+ Evaluation on 1000 episodes, seeds 10000–10999.
51
+
52
+ ## Usage
53
+
54
+ Install the package, download the repo, and let it play:
55
+
56
+ ```bash
57
+ pip install git+https://github.com/anakin87/tiny-doom-defender
58
+ hf download anakin87/tiny-doom-defender --local-dir tiny-doom-defender
59
+
60
+ # watch it play in a live DOOM window
61
+ play-doom --ckpt tiny-doom-defender
62
+
63
+ # score it on the held-out test seeds
64
+ eval-model --ckpt tiny-doom-defender --episodes 100
65
+ ```
66
+
67
+ Point `--ckpt` at a subfolder to use the other checkpoints:
68
+
69
+ ```bash
70
+ eval-model --ckpt tiny-doom-defender/sft --episodes 100
71
+ eval-model --ckpt tiny-doom-defender/int8 --episodes 100
72
+ ```
73
+
74
+ ## Architecture
75
+
76
+ | | |
77
+ | --- | --- |
78
+ | Parameters | 1,096,134 |
79
+ | Observation | 3 stacked 160×100 RGB frames (t, t−1, t−2) + the 2 previous actions |
80
+ | Stem | two stride-2 3×3 convs, 32 channels → a 40×25 = 1000-token grid |
81
+ | Encoder | 4-layer ModernBERT, hidden size 128, 4 heads, fed via `inputs_embeds` |
82
+ | Head | learned attention pooling → turn (3) / shoot (2) / value heads |
83
+ | Action space | `MultiDiscrete([3, 2])` — turn left/none/right × shoot/no-shoot |
84
+
85
+ ![Tiny Doom Defender architecture](architecture.png)
config.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DoomConvStemPolicy"
4
+ ],
5
+ "dtype": "float32",
6
+ "encoder_config": {
7
+ "architectures": [
8
+ "ModernBertModel"
9
+ ],
10
+ "attention_bias": false,
11
+ "attention_dropout": 0.0,
12
+ "bos_token_id": 0,
13
+ "classifier_activation": "gelu",
14
+ "classifier_bias": false,
15
+ "classifier_dropout": 0.0,
16
+ "classifier_pooling": "cls",
17
+ "cls_token_id": 0,
18
+ "decoder_bias": true,
19
+ "deterministic_flash_attn": false,
20
+ "dtype": "float32",
21
+ "embedding_dropout": 0.0,
22
+ "eos_token_id": 0,
23
+ "global_attn_every_n_layers": 3,
24
+ "hidden_activation": "gelu",
25
+ "hidden_size": 128,
26
+ "initializer_cutoff_factor": 2.0,
27
+ "initializer_range": 0.02,
28
+ "intermediate_size": 512,
29
+ "layer_norm_eps": 1e-05,
30
+ "layer_types": [
31
+ "full_attention",
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "full_attention"
35
+ ],
36
+ "local_attention": 128,
37
+ "max_position_embeddings": 1536,
38
+ "mlp_bias": false,
39
+ "mlp_dropout": 0.0,
40
+ "model_type": "modernbert",
41
+ "norm_bias": false,
42
+ "norm_eps": 1e-05,
43
+ "num_attention_heads": 4,
44
+ "num_hidden_layers": 4,
45
+ "pad_token_id": 0,
46
+ "rope_parameters": {
47
+ "full_attention": {
48
+ "rope_theta": 160000.0,
49
+ "rope_type": "default"
50
+ },
51
+ "sliding_attention": {
52
+ "rope_theta": 10000.0,
53
+ "rope_type": "default"
54
+ }
55
+ },
56
+ "sep_token_id": 0,
57
+ "sparse_pred_ignore_index": -100,
58
+ "sparse_prediction": false,
59
+ "tie_word_embeddings": false,
60
+ "vocab_size": 32
61
+ },
62
+ "model_type": "doom_conv_stem",
63
+ "n_action_states": 7,
64
+ "n_frames": 3,
65
+ "n_prev_actions": 2,
66
+ "res_h": 100,
67
+ "res_w": 160,
68
+ "stem_channels": 32,
69
+ "transformers_version": "5.13.1"
70
+ }
int8/config.json ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DoomConvStemPolicy"
4
+ ],
5
+ "dtype": "float32",
6
+ "encoder_config": {
7
+ "architectures": [
8
+ "ModernBertModel"
9
+ ],
10
+ "attention_bias": false,
11
+ "attention_dropout": 0.0,
12
+ "bos_token_id": 0,
13
+ "classifier_activation": "gelu",
14
+ "classifier_bias": false,
15
+ "classifier_dropout": 0.0,
16
+ "classifier_pooling": "cls",
17
+ "cls_token_id": 0,
18
+ "decoder_bias": true,
19
+ "deterministic_flash_attn": false,
20
+ "dtype": "float32",
21
+ "embedding_dropout": 0.0,
22
+ "eos_token_id": 0,
23
+ "global_attn_every_n_layers": 3,
24
+ "hidden_activation": "gelu",
25
+ "hidden_size": 128,
26
+ "initializer_cutoff_factor": 2.0,
27
+ "initializer_range": 0.02,
28
+ "intermediate_size": 512,
29
+ "layer_norm_eps": 1e-05,
30
+ "layer_types": [
31
+ "full_attention",
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "full_attention"
35
+ ],
36
+ "local_attention": 128,
37
+ "max_position_embeddings": 1536,
38
+ "mlp_bias": false,
39
+ "mlp_dropout": 0.0,
40
+ "model_type": "modernbert",
41
+ "norm_bias": false,
42
+ "norm_eps": 1e-05,
43
+ "num_attention_heads": 4,
44
+ "num_hidden_layers": 4,
45
+ "pad_token_id": 0,
46
+ "rope_parameters": {
47
+ "full_attention": {
48
+ "rope_theta": 160000.0,
49
+ "rope_type": "default"
50
+ },
51
+ "sliding_attention": {
52
+ "rope_theta": 10000.0,
53
+ "rope_type": "default"
54
+ }
55
+ },
56
+ "sep_token_id": 0,
57
+ "sparse_pred_ignore_index": -100,
58
+ "sparse_prediction": false,
59
+ "tie_word_embeddings": false,
60
+ "vocab_size": 32
61
+ },
62
+ "model_type": "doom_conv_stem",
63
+ "n_action_states": 7,
64
+ "n_frames": 3,
65
+ "n_prev_actions": 2,
66
+ "quantization": "int8-symmetric",
67
+ "res_h": 100,
68
+ "res_w": 160,
69
+ "stem_channels": 32,
70
+ "transformers_version": "5.13.1"
71
+ }
int8/model_int8.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3028d8ea28b778759134c599c7b8178baa61732fbd72791adcfc5e71844b74b8
3
+ size 1130802
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50c3852e747cabaa6f981b50e730611723a069a9ac32c9d920f8e54a26ed2f61
3
+ size 4388152
sft/config.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DoomConvStemForActionClassification"
4
+ ],
5
+ "dtype": "float32",
6
+ "encoder_config": {
7
+ "architectures": [
8
+ "ModernBertModel"
9
+ ],
10
+ "attention_bias": false,
11
+ "attention_dropout": 0.0,
12
+ "bos_token_id": 0,
13
+ "classifier_activation": "gelu",
14
+ "classifier_bias": false,
15
+ "classifier_dropout": 0.0,
16
+ "classifier_pooling": "cls",
17
+ "cls_token_id": 0,
18
+ "decoder_bias": true,
19
+ "deterministic_flash_attn": false,
20
+ "dtype": "float32",
21
+ "embedding_dropout": 0.0,
22
+ "eos_token_id": 0,
23
+ "global_attn_every_n_layers": 3,
24
+ "hidden_activation": "gelu",
25
+ "hidden_size": 128,
26
+ "initializer_cutoff_factor": 2.0,
27
+ "initializer_range": 0.02,
28
+ "intermediate_size": 512,
29
+ "layer_norm_eps": 1e-05,
30
+ "layer_types": [
31
+ "full_attention",
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "full_attention"
35
+ ],
36
+ "local_attention": 128,
37
+ "max_position_embeddings": 1536,
38
+ "mlp_bias": false,
39
+ "mlp_dropout": 0.0,
40
+ "model_type": "modernbert",
41
+ "norm_bias": false,
42
+ "norm_eps": 1e-05,
43
+ "num_attention_heads": 4,
44
+ "num_hidden_layers": 4,
45
+ "pad_token_id": 0,
46
+ "rope_parameters": {
47
+ "full_attention": {
48
+ "rope_theta": 160000.0,
49
+ "rope_type": "default"
50
+ },
51
+ "sliding_attention": {
52
+ "rope_theta": 10000.0,
53
+ "rope_type": "default"
54
+ }
55
+ },
56
+ "sep_token_id": 0,
57
+ "sparse_pred_ignore_index": -100,
58
+ "sparse_prediction": false,
59
+ "tie_word_embeddings": false,
60
+ "vocab_size": 32
61
+ },
62
+ "model_type": "doom_conv_stem",
63
+ "n_action_states": 7,
64
+ "n_frames": 3,
65
+ "n_prev_actions": 2,
66
+ "res_h": 100,
67
+ "res_w": 160,
68
+ "stem_channels": 32,
69
+ "transformers_version": "5.13.1"
70
+ }
sft/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab7296cc1d9271b4f9dedc4732dbd0803cd7bb991155793a2b3f520041b7be3b
3
+ size 4387476