Image-Text-to-Text
Transformers
Safetensors
qwen3_5
qwen3.5
game2player
visual-agent
game-playing
sft
conversational
Instructions to use game2player/Game2Player-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use game2player/Game2Player-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="game2player/Game2Player-9B") 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("game2player/Game2Player-9B") model = AutoModelForMultimodalLM.from_pretrained("game2player/Game2Player-9B", 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 game2player/Game2Player-9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "game2player/Game2Player-9B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "game2player/Game2Player-9B", "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/game2player/Game2Player-9B
- SGLang
How to use game2player/Game2Player-9B 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 "game2player/Game2Player-9B" \ --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": "game2player/Game2Player-9B", "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 "game2player/Game2Player-9B" \ --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": "game2player/Game2Player-9B", "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 game2player/Game2Player-9B with Docker Model Runner:
docker model run hf.co/game2player/Game2Player-9B
|
Download README.md from game2player/Game2Player-9B: direct link, hf CLI and curl.
- Browser
- Download file 5.16 kB
-
https://huggingface.co/game2player/Game2Player-9B/resolve/main/README.md
- Command line
-
hf download hf://game2player/Game2Player-9B/README.md
-
curl -L -o README.md https://huggingface.co/game2player/Game2Player-9B/resolve/main/README.md
5.16 kB
| base_model: Qwen/Qwen3.5-9B | |
| base_model_relation: finetune | |
| library_name: transformers | |
| pipeline_tag: image-text-to-text | |
| license: apache-2.0 | |
| tags: | |
| - qwen3.5 | |
| - game2player | |
| - visual-agent | |
| - game-playing | |
| - sft | |
| model_name: Game2Player 9B | |
| # Game2Player 9B | |
| Game2Player 9B is a visual game-playing model fine-tuned from | |
| [Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B). It takes game | |
| screenshots, a task description and recent actions as input, then predicts the | |
| next keyboard or mouse action. | |
| This repository contains the complete model weights. Load it directly with | |
| vLLM or Transformers. | |
| **Game2Player: Scaling Gameplay Experience for Visual Agents through | |
| Environment–Player Co-Development** | |
| [Project](https://game2player.github.io/) · | |
| [Code](https://github.com/game2player/Game2Player) · | |
| [PlayerBench](https://github.com/game2player/Game2Player/tree/main/benchmark/playerbench) | |
| ## Training | |
| The model was trained on gameplay collected from code policies and VLM players | |
| with Game2Player. Training updates the language model while keeping the vision | |
| encoder and visual projector frozen. | |
| | Setting | Value | | |
| | --- | --- | | |
| | Training examples | 1,564,236 | | |
| | Training duration | One epoch, 9,237 optimizer steps | | |
| | Maximum training sequence length | 25,000 tokens | | |
| | Learning rate | 0.00001 with a cosine schedule | | |
| | Weight precision | BF16 | | |
| Dataset coming soon. | |
| ## Input and output | |
| Provide the game rules, available controls and task goal in the system message. | |
| The user message contains the current screenshot and, when available, up to | |
| 50 previous actions with their short notes and six previous screenshots. | |
| Use at most seven images in total and about 1,024 visual tokens per image. | |
| The model returns a `computer_use` action inside `<tool_call>` tags. For example: | |
| ```text | |
| <tool_call> | |
| {"name":"computer_use","arguments":{"action":"press_key","key":"ArrowRight","reasoning":"Move toward the exit."}} | |
| </tool_call> | |
| ``` | |
| The `reasoning` field contains a short action note. Longer thinking, when enabled, | |
| is returned separately. Mouse coordinates use a normalized 0–1000 range and | |
| action durations are in seconds. | |
| ## Run the model | |
| Install vLLM and start an OpenAI-compatible server: | |
| ```bash | |
| pip install vllm==0.29.0 requests | |
| vllm serve game2player/Game2Player-9B \ | |
| --served-model-name game2player-9b \ | |
| --dtype bfloat16 \ | |
| --max-model-len 65536 \ | |
| --max-num-seqs 8 \ | |
| --max-num-batched-tokens 4096 \ | |
| --limit-mm-per-prompt '{"image":7,"video":0}' \ | |
| --mm-processor-kwargs '{"max_pixels":1048576}' \ | |
| --reasoning-parser qwen3 | |
| ``` | |
| Save a screenshot as `screen.png` and send a request. Replace the example game | |
| rules and task with those of the game you want to play. | |
| ```python | |
| import base64 | |
| from pathlib import Path | |
| import requests | |
| system_prompt = """You are an expert game agent. Choose the next action from the screenshot. | |
| # Game Rules | |
| Move the character through the maze to reach the exit. Walls block movement. | |
| # Role and Controls | |
| ArrowUp, ArrowDown, ArrowLeft and ArrowRight move the character. | |
| # Task Instruction | |
| Reach the exit. | |
| # Output Format | |
| Return exactly one action inside <tool_call> tags. | |
| Use press_key with a key from the controls above, or wait with a duration in seconds. | |
| Include reasoning with one short sentence explaining the action. | |
| Think in the thinking channel, then emit only the tool call as the final answer. | |
| Example: | |
| <tool_call>{"name":"computer_use","arguments":{"action":"press_key","key":"ArrowRight","reasoning":"Move toward the exit."}}</tool_call> | |
| """ | |
| encoded = base64.b64encode(Path("screen.png").read_bytes()).decode("ascii") | |
| response = requests.post( | |
| "http://localhost:8000/v1/chat/completions", | |
| json={ | |
| "model": "game2player-9b", | |
| "messages": [ | |
| {"role": "system", "content": system_prompt}, | |
| {"role": "user", "content": [ | |
| {"type": "text", "text": "# Current step\nCurrent game screen:\n"}, | |
| {"type": "image_url", "image_url": { | |
| "url": "data:image/png;base64," + encoded | |
| }}, | |
| {"type": "text", "text": "\nReturn the next action."}, | |
| ]}, | |
| ], | |
| "temperature": 1.0, | |
| "max_tokens": 512, | |
| "chat_template_kwargs": {"enable_thinking": False}, | |
| }, | |
| timeout=180, | |
| ) | |
| response.raise_for_status() | |
| print(response.json()["choices"][0]["message"]["content"]) | |
| ``` | |
| To enable thinking, set `enable_thinking` to `True` and increase `max_tokens` and | |
| the request timeout. Our thinking evaluations allow up to 32,768 output tokens. | |
| Keep previous action notes in the history and omit previous thinking chains. | |
| ## Evaluation | |
| We evaluate Game2Player on PlayerBench, which contains 50 held-out games and | |
| 287 tasks, and GameWorld, which contains 34 games and 170 tasks. Results are | |
| available on the [project leaderboard](https://game2player.github.io/#leaderboard). | |
| ## License | |
| The model weights are released under [Apache-2.0](LICENSE). | |
| Qwen3.5 is also licensed under Apache-2.0. Game titles, assets and screenshots | |
| belong to their respective owners. The model license does not grant rights to | |
| third-party game content. | |