Instructions to use THUSI-Lab/GameDojo-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use THUSI-Lab/GameDojo-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="THUSI-Lab/GameDojo-4B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("THUSI-Lab/GameDojo-4B") model = AutoModelForMultimodalLM.from_pretrained("THUSI-Lab/GameDojo-4B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use THUSI-Lab/GameDojo-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "THUSI-Lab/GameDojo-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "THUSI-Lab/GameDojo-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/THUSI-Lab/GameDojo-4B
- SGLang
How to use THUSI-Lab/GameDojo-4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "THUSI-Lab/GameDojo-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "THUSI-Lab/GameDojo-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "THUSI-Lab/GameDojo-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "THUSI-Lab/GameDojo-4B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use THUSI-Lab/GameDojo-4B with Docker Model Runner:
docker model run hf.co/THUSI-Lab/GameDojo-4B
|
Download README.md from THUSI-Lab/GameDojo-4B: direct link, hf CLI and curl.
- Browser
- Download file 12.8 kB
-
https://huggingface.co/THUSI-Lab/GameDojo-4B/resolve/main/README.md
- Command line
-
hf download hf://THUSI-Lab/GameDojo-4B/README.md
-
curl -L -o README.md https://huggingface.co/THUSI-Lab/GameDojo-4B/resolve/main/README.md
12.8 kB
| library_name: transformers | |
| pipeline_tag: image-text-to-text | |
| base_model: Qwen/Qwen3.5-4B | |
| base_model_relation: finetune | |
| datasets: | |
| - THUSI-Lab/GameDojo | |
| tags: | |
| - gamedojo | |
| - game-agent | |
| - computer-use | |
| <div style="background-color: #0d0f17; border: 1px solid #232737; border-radius: 12px; color: #eef0f6; padding: 16px 10px; margin: 8px 0 22px;"> | |
| <p align="center" style="margin-bottom: 8px;"> | |
| <img src="https://gamedojo-benchmark.github.io/assets/img/logo.webp" alt="GameDojo" width="520" style="display: inline-block; width: 520px; max-width: 100%; height: auto; margin: 0;"> | |
| </p> | |
| <h1 align="center" style="color: #eef0f6; font-size: 1.35em; line-height: 1.35; margin-top: 0; margin-bottom: 12px;"><span style="color: #ffd98a;">Game</span><span style="color: #3fd9c6;">Dojo</span>: Benchmarking Real-Time Interactive Agents in Video Games</h1> | |
| <p align="center" style="margin: 6px 0 14px;"> | |
| <a href="https://arxiv.org/abs/2611.30771" style="display: inline-block; margin: 2px;"><img src="https://img.shields.io/badge/Paper-b31b1b?style=for-the-badge&logo=arxiv&logoColor=white" alt="Paper (arXiv)" style="display: inline-block; vertical-align: middle; margin: 0;"></a> | |
| <a href="https://gamedojo-benchmark.github.io/" style="display: inline-block; margin: 2px;"><img src="https://img.shields.io/badge/Project%20Page-1f6feb?style=for-the-badge&logo=googlechrome&logoColor=white" alt="Project Page" style="display: inline-block; vertical-align: middle; margin: 0;"></a> | |
| <a href="https://github.com/THUSI-Lab/GameDojo" style="display: inline-block; margin: 2px;"><img src="https://img.shields.io/badge/GitHub-232737?style=for-the-badge&logo=github&logoColor=eef0f6" alt="GitHub" style="display: inline-block; vertical-align: middle; margin: 0;"></a> | |
| <a href="https://huggingface.co/datasets/THUSI-Lab/GameDojo" style="display: inline-block; margin: 2px;"><img src="https://img.shields.io/badge/Dataset%20%26%20Benchmark-ffcc4d?style=for-the-badge&logo=huggingface&logoColor=white" alt="Dataset & Benchmark" style="display: inline-block; vertical-align: middle; margin: 0;"></a> | |
| <a href="https://huggingface.co/papers/2611.30771" style="display: inline-block; margin: 2px;"><img src="https://img.shields.io/badge/Daily%20Paper-232737?style=for-the-badge&logo=huggingface&logoColor=ffcc4d" alt="Daily Paper" style="display: inline-block; vertical-align: middle; margin: 0;"></a> | |
| </p> | |
| <p align="center" style="background-color: #fff; border-radius: 8px; padding: 4px 1px; margin: 0 auto 14px;"> | |
| <img src="https://gamedojo-benchmark.github.io/assets/img/institutions/tsinghua.jpg" alt="Tsinghua University" height="30" style="display: inline-block; vertical-align: middle; height: 30px; width: auto; margin: 4px 2px;"> | |
| <img src="https://gamedojo-benchmark.github.io/assets/img/institutions/ucas.png" alt="University of Chinese Academy of Sciences" height="27" style="display: inline-block; vertical-align: middle; height: 27px; width: auto; margin: 4px 2px;"> | |
| <img src="https://gamedojo-benchmark.github.io/assets/img/institutions/nus.jpg" alt="National University of Singapore" height="34" style="display: inline-block; vertical-align: middle; height: 34px; width: auto; margin: 4px 2px;"> | |
| <img src="https://gamedojo-benchmark.github.io/assets/img/institutions/hku-bilingual.svg" alt="香港大學 · The University of Hong Kong" height="24" style="display: inline-block; vertical-align: middle; height: 24px; width: auto; margin: 4px 2px;"> | |
| <img src="https://gamedojo-benchmark.github.io/assets/img/institutions/macau.png" alt="University of Macau" height="30" style="display: inline-block; vertical-align: middle; height: 30px; width: auto; margin: 4px 2px;"> | |
| </p> | |
| <p align="center" style="line-height: 1.65; margin-bottom: 6px;"><strong style="color: #eef0f6;"><span style="white-space: nowrap;">Kuan Zhang<sup style="color: #ffd98a;">1,*</sup>,</span> <span style="white-space: nowrap;">Zhihao Yang<sup style="color: #ffd98a;">2,*</sup>,</span> <span style="white-space: nowrap;">Yukun Chen<sup style="color: #ffd98a;">2,*</sup>,</span> <span style="white-space: nowrap;">Xingyiliang Yin<sup style="color: #ffd98a;">3</sup>,</span> <span style="white-space: nowrap;">Mingyu Ouyang<sup style="color: #ffd98a;">4</sup>,</span> <span style="white-space: nowrap;">Yue Su<sup style="color: #ffd98a;">5</sup>,</span> <span style="white-space: nowrap;">Xiangnan Wu<sup style="color: #ffd98a;">2</sup>,</span> <span style="white-space: nowrap;">Jiaming Li<sup style="color: #ffd98a;">2</sup>,</span> <span style="white-space: nowrap;">Longze Chen<sup style="color: #ffd98a;">2</sup>,</span> <span style="white-space: nowrap;">Run Luo<sup style="color: #ffd98a;">4</sup>,</span> <span style="white-space: nowrap;">Zirong Chen<sup style="color: #ffd98a;">1</sup>,</span> <span style="white-space: nowrap;">Lu Wang<sup style="color: #ffd98a;">1,†</sup>,</span> <span style="white-space: nowrap;">Yiming Li<sup style="color: #ffd98a;">1,†</sup></span></strong></p> | |
| <p align="center" style="color: rgba(238, 240, 246, 0.62); font-size: 0.9em; line-height: 1.6; margin-top: 0; margin-bottom: 4px;"><span style="display: inline-block; margin: 0 5px;"><sup style="color: #ffd98a;">1</sup> Tsinghua University</span> <span style="display: inline-block; margin: 0 5px;"><sup style="color: #ffd98a;">2</sup> University of the Chinese Academy of Sciences</span> <span style="display: inline-block; margin: 0 5px;"><sup style="color: #ffd98a;">3</sup> University of Macau</span> <span style="display: inline-block; margin: 0 5px;"><sup style="color: #ffd98a;">4</sup> National University of Singapore</span> <span style="display: inline-block; margin: 0 5px;"><sup style="color: #ffd98a;">5</sup> University of Hong Kong</span></p> | |
| <p align="center" style="color: rgba(238, 240, 246, 0.62); font-size: 0.85em; margin: 0;"><span style="display: inline-block; margin: 0 5px;"><sup style="color: #ffd98a;">*</sup> Equal contribution</span> <span style="display: inline-block; margin: 0 5px;"><sup style="color: #ffd98a;">†</sup> Co-corresponding authors</span></p> | |
| </div> | |
| ## Overview | |
| GameDojo-4B is a vision-language model for video game boss encounters. It takes game observations and task context and generates keyboard and mouse actions for the GameDojo computer-use (CUA) interface. Each action chunk covers 200 ms of game control. | |
| GameDojo provides 120 boss encounters across 20 game environments, split evenly between 2D and 3D. Its CUA and Semantic interfaces expose different levels of action abstraction. Real-time and time-paused modes let researchers vary whether the simulation advances during inference. | |
| ## Training | |
| We fine-tuned [Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) with supervised learning on a balanced 240-hour subset of GameDojo-Data. The subset contains 40 minutes of gameplay for each of the 120 bosses at each of three difficulty levels (Easy, Medium, and Hard). | |
| ## Evaluation | |
| We evaluate GameDojo-4B through CUA in both timing modes at all three difficulty levels. We report average win rate and average progress. A win requires defeating the boss, and progress measures the fraction of total boss health removed during the episode. | |
| ## Download | |
| The checkpoint is distributed as BF16 Safetensors. Download it together with its configuration and processor files. | |
| ```bash | |
| hf download THUSI-Lab/GameDojo-4B --local-dir GameDojo-4B | |
| ``` | |
| ## Load with Transformers | |
| ```python | |
| import torch | |
| from transformers import AutoProcessor, Qwen3_5ForConditionalGeneration | |
| repo_id = "THUSI-Lab/GameDojo-4B" | |
| processor = AutoProcessor.from_pretrained(repo_id) | |
| model = Qwen3_5ForConditionalGeneration.from_pretrained( | |
| repo_id, dtype=torch.bfloat16, device_map="auto" | |
| ).eval() | |
| ``` | |
| Use the bundled `chat_template.jinja` to format observations and task context. Pass the generated actions to the GameDojo CUA executor to advance the encounter. | |
| ## Single-frame CUA example | |
| This example uses the Terraria King Slime CUA system prompt shown in the GameDojo supplementary material. The conversation contains this system prompt and one image-only user turn. | |
| ### System prompt for King Slime | |
| ```text | |
| You are an experienced PC game player, proficient in keyboard and mouse operations. You are playing "Pixel Arena: Sword and Bow". Based on the current game screen and the corresponding historical trajectory, plan the next 200ms of actions, consisting of 6 steps. Each step is spaced 33ms apart. Every step lasts 33ms from its start time until the next step begins. | |
| Output Format | |
| <|action_start|>X Y Z ; k1 k2 ; k3 ; k4 ; k5 ; k6 ; k7<|action_end|> | |
| Explanation | |
| 1. Mouse Movement: Relative integers X, Y in [-1000, 1000] (X>0 right, Y>0 down) and scroll Z in [-5, 5] (Z>0 up). | |
| 2. Key Sequence: 6 groups separated by ;; space-separated keys within each group (at most 4 keys/group). Leave an empty group blank while keeping ;. Keys listed in consecutive groups stay held; unlisted keys are released. | |
| 3. Output only one plain line matching the format, with no line breaks or quotes. | |
| Key Naming Rules: Capital letters (W, A), capitalized names (Space, Shift), mouse buttons (LB, RB). | |
| Game: Side-view 2D arena with two wooden platforms. Empty the boss's health bar within 300 s without losing all health. | |
| Controls (only these keys are active): A/D move left/right; Space jump/fly; S drop through platform; J/LB use weapon; Q swap sword/bow; E shoot bow at crosshair; RB swing sword. | |
| Mouse: X/Y move crosshair (1000 = full screen width/height); bow shoots toward crosshair. | |
| Boss: King Slime: Giant gel creature that leaps to crush you, sheds small blobs when hit, and teleports near you. Moves: 1. Leap; 2. Teleport; 3. Gel Spawns. | |
| Health bars and other status are shown on the screen; read them yourself. | |
| ``` | |
| ### Input frame | |
| The source frame below is resized to 854 × 480 and JPEG-encoded at quality 90 before inference. | |
|  | |
| ### Model output | |
| The published BF16 checkpoint generated this reply with its non-thinking chat template. The run used Transformers 5.24.0 on Apple MPS, sampling at temperature 1.0 with top-p 1.0, no top-k cutoff, and a 256-token limit. Generation stopped upon emitting `<|action_end|>`. | |
| <pre style="white-space: pre-wrap; overflow-wrap: anywhere;"><code style="white-space: inherit; overflow-wrap: inherit;"><|action_start|>-7 33 0 ; E S ; E S ; E S ; E S ; E S ; E S<|action_end|></code></pre> | |
| The mouse deltas move the crosshair left and down, with no scroll. Each of the six steps holds `E` to shoot the bow and `S` to drop through the platform. | |
| <details> | |
| <summary>Run the same example with Transformers</summary> | |
| Load `processor` and `model` as shown above. Save the system prompt as `king_slime_cua_prompt.txt` and the source image as `king-slime.jpg`. | |
| ```python | |
| from io import BytesIO | |
| from pathlib import Path | |
| from PIL import Image | |
| import torch | |
| system_prompt = Path("king_slime_cua_prompt.txt").read_text(encoding="utf-8").rstrip("\n") | |
| with Image.open("king-slime.jpg") as source: | |
| encoded = BytesIO() | |
| resized = source.convert("RGB").resize((854, 480), Image.Resampling.LANCZOS) | |
| resized.save(encoded, format="JPEG", quality=90) | |
| frame = Image.open(encoded).convert("RGB") | |
| messages = [ | |
| {"role": "system", "content": system_prompt}, | |
| {"role": "user", "content": [{"type": "image", "image": frame}]}, | |
| ] | |
| inputs = processor.apply_chat_template( | |
| messages, | |
| add_generation_prompt=True, | |
| tokenize=True, | |
| return_dict=True, | |
| return_tensors="pt", | |
| ).to(model.device) | |
| torch.manual_seed(42) | |
| with torch.inference_mode(): | |
| output = model.generate( | |
| **inputs, | |
| do_sample=True, | |
| temperature=1.0, | |
| top_p=1.0, | |
| top_k=0, | |
| max_new_tokens=256, | |
| stop_strings=["<|action_end|>"], | |
| tokenizer=processor.tokenizer, | |
| ) | |
| new_ids = output[0, inputs["input_ids"].shape[-1]:].tolist() | |
| print(processor.decode(new_ids, skip_special_tokens=False, clean_up_tokenization_spaces=False)) | |
| ``` | |
| </details> | |
| ## Citation | |
| ```bibtex | |
| @article{zhang2026gamedojo, | |
| title = {GameDojo: Benchmarking Real-Time Interactive Agents in Video Games}, | |
| author = {Zhang, Kuan and Yang, Zhihao and Chen, Yukun and Yin, Xingyiliang and Ouyang, Mingyu and Su, Yue and Wu, Xiangnan and Li, Jiaming and Chen, Longze and Luo, Run and Chen, Zirong and Wang, Lu and Li, Yiming}, | |
| journal = {arXiv preprint arXiv:2611.30771}, | |
| year = {2026} | |
| } | |
| ``` | |
| We also invite you to explore and cite [Gamer](https://mihoyo-gamer.github.io/), [GameScaling](https://gamescaling.github.io/), and [Survey: Towards Generalist Game Agents](https://github.com/THUSI-Lab/Awesome-LFMs-Play-Games). | |