minijev-snake / README.md
markuz89's picture
MiniJEV v2 model export
026f63e verified
|
Raw History Blame Contribute Delete
2.42 kB
---
license: apache-2.0
language:
- en
tags:
- decision-model
- reinforcement-learning
- snake
- minijev
library_name: minijev
---
# MiniJEV · Snake
A **tiny decision model** (≈0.5M parameters, 2 MB) that plays Snake on a 10×10 board.
It is not a language model and generates no text. At each step it scores the
available choices (`move up`, `move down`, `move left`, `move right`) and returns a
**calibrated probability** for each one.
It is the first benchmark of **MiniJEV**. The same core (state + question +
dynamic list of choices → choice + calibrated confidence) is used for text decisions
in [`markuz89/minijev-general`](https://huggingface.co/markuz89/minijev-general).
## Results (200 games, 10×10, max score 97)
| metric | value |
|---|---|
| average score | **88.6** |
| median score | 97 (board filled) |
| games won (board filled) | **73.5 %** |
| deaths | 19 % |
| stopped for starvation | 7.5 % |
| fatal moves | 0.02 % of decisions |
For comparison, the search-based oracle the model was first distilled from scores
95 on average and wins 38 % of games. The model wins more often but has a lower
average score.
Training pipeline:
1. Supervised distillation from the oracle.
2. DAgger.
3. PPO (two rounds, γ = 0.995, on an RTX 4090).
4. The choices were then renamed from `UP/DOWN/…` to `move up/…` without retraining. Only the choice encoder was re-fit, and the probabilities are identical (max difference 4e-7).
## Usage
```bash
git clone https://huggingface.co/markuz89/minijev-snake && cd minijev-snake/code
pip install -e ".[train]" # needs torch; ONNX export is available for torch-free inference
```
```python
from minijev.inference.runtime import MiniJEV
dec = MiniJEV.load("..") # the cloned repo folder (or the repo id)
state = dec.task.example_states(1)[0] # {"body": [...], "food": (x, y), "direction": ...}
d = dec.decide(state) # question and choices default to the Snake task
print(d.choice, d.confidence, d.scores) # e.g. "move left" 0.999 {...}
```
## Files
- `model.safetensors`: weights (no pickle)
- `config.json`: architecture, task config, calibration temperature, metrics
- `code/`: the `minijev` package and the Snake environment needed to run it
## Limits
The model was trained only on 10×10 boards. Inputs are the grid channels of the
MiniJEV Snake environment, and it is not a general game-playing agent.