Views
No views yet


vLLM library as follows:1from vllm import LLM, SamplingParams
2from transformers import AutoProcessor
3from PIL import Image
4
5# Model configuration (choose one)
6# For gWorld-8B:
7MODEL_PATH = "trillionlabs/gWorld-8B"
8BASE_MODEL = "Qwen/Qwen3-VL-8B-Instruct"
9
10# For gWorld-32B:
11# MODEL_PATH = "trillionlabs/gWorld-32B"
12# BASE_MODEL = "Qwen/Qwen3-VL-32B"
13
14# Image processing settings
15MM_PROCESSOR_KWARGS = {
16 "max_pixels": 4233600,
17 "min_pixels": 3136,
18}
19
20# Load model
21llm = LLM(
22 model=MODEL_PATH,
23 tokenizer=BASE_MODEL,
24 tensor_parallel_size=8,
25 gpu_memory_utilization=0.9,
26 max_model_len=19384,
27 trust_remote_code=True,
28 mm_processor_kwargs=MM_PROCESSOR_KWARGS,
29 enable_chunked_prefill=True,
30 max_num_batched_tokens=16384,
31)
32
33# Load processor for chat template
34processor = AutoProcessor.from_pretrained(BASE_MODEL, trust_remote_code=True)
35
36# Prepare input
37image = Image.open("screenshot.png")
38if image.mode != 'RGB':
39 image = image.convert('RGB')
40
41action = '{"action_type": "TAP", "coordinates": [512, 890]}'
42
43# World model prompt template
44user_content = f"""You are an expert mobile UI World Model that can accurately predict the next state given an action.
45Given a screenshot of a mobile interface and an action, you must generate clean, responsive HTML code that represents the state of the interface AFTER the action is performed.
46First generate reasoning about what the next state should look like based on the action.
47Afterwards, generate the HTML code representing the next state that logically follows the action.
48You will render this HTML in a mobile viewport to see how similar it looks and acts like the mobile screenshot.
49
50Requirements:
511. Provide reasoning about what the next state should look like based on the action
522. Generate complete, valid HTML5 code
533. Choose between using inline CSS and utility classes from Bootstrap, Tailwind CSS, or MUI for styling, depending on which option generates the closest code to the screenshot.
544. Use mobile-first design principles matching screenshot dimensions.
555. For images, use inline SVG placeholders with explicit width and height attributes that match the approximate dimensions from the screenshot. Matching the approximate color is also good.
566. Use modern web standards and best practices
577. Return ONLY the HTML code, no explanations or markdown formatting
588. The generated HTML should render properly in a mobile viewport.
599. Generated HTML should look like the screen that logically follows the current screen and the action.
60
61Action:
62{action}
63
64Output format:
65# Next State Reasoning: <your reasoning about what the next state should look like>
66# HTML: <valid_html_code>
67
68Generate the next state reasoning and the next state in html:"""
69
70# Build messages
71messages = [
72 {
73 "role": "user",
74 "content": [
75 {"type": "image", "image": image},
76 {"type": "text", "text": user_content},
77 ],
78 }
79]
80
81# Apply chat template
82prompt = processor.apply_chat_template(
83 messages,
84 tokenize=False,
85 add_generation_prompt=True,
86)
87
88# Generation parameters
89sampling_params = SamplingParams(
90 max_tokens=15000,
91 temperature=0,
92 seed=42,
93 top_p=1.0,
94)
95
96# Generate
97outputs = llm.generate(
98 [{"prompt": prompt, "multi_modal_data": {"image": image}}],
99 sampling_params=sampling_params
100)
101
102print(outputs[0].outputs[0].text)Qwen3-VL-8B
Llama 4 402B-A17B) on GUI-specific benchmarks.{"action_type": "TAP", "coordinates": [512, 890]} or {"action_type": "TYPE", "text": "gWorld is a generative code mobile world model"}@misc{koh2026generativevisualcodemobile,
title={Generative Visual Code Mobile World Models},
author={Woosung Koh and Sungjun Han and Segyu Lee and Se-Young Yun and Jamin Shin},
year={2026},
eprint={2602.01576},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2602.01576},
}