infinitylogesh commited on
Commit
b014161
·
verified ·
1 Parent(s): 708b82a

Use: vLLM first

Browse files
Files changed (1) hide show
  1. README.md +68 -7
README.md CHANGED
@@ -32,23 +32,84 @@ real distribution over the screen.
32
 
33
  ## Use
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ```bash
36
- pip install "slotread @ git+https://github.com/infinitylogesh/slot-reading"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ```
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  ```python
40
  from PIL import Image
41
  from slotread.local import LocalSlotModel
42
 
43
  m = LocalSlotModel.from_pretrained("infinitylogesh/GUI-Decisions-31B")
44
- shot = Image.open("screenshot.png")
45
- step = m.decide(shot, "turn on dark mode") # {'action': 'click', 'x': 0.47, 'y': 0.12, ...}
46
- box = m.box(Image.open("photo.jpg"), "the red frisbee") # [x1, y1, x2, y2] in [0, 1]
47
  ```
48
 
49
- For speed, serve it on vLLM and read the slots with per-slot `logprob_token_ids` requests
50
- (`slotread.client`, `serving/` in the code repository; vLLM serves this folder as a plain model): ~146 ms per step on one RTX PRO 6000 (NVFP4 base).
51
-
52
  ## Results
53
 
54
  This merged model in bf16 with transformers (`slotread.local`), against the published evaluation of the
 
32
 
33
  ## Use
34
 
35
+ ### With vLLM
36
+
37
+ Served in bf16 on one RTX PRO 6000 a computer-use step takes **190 ms** (median over 60 cold screenshots).
38
+ [The LoRA on the NVFP4 base](https://huggingface.co/infinitylogesh/GUI-Decisions-31B-LoRA) is faster
39
+ (152 ms) and keeps the base model for text steps; use this merged model when you want one plain
40
+ checkpoint.
41
+
42
+ **1. Install** vLLM 0.30 and the reader (`slotread`, from the code repository):
43
+
44
+ ```bash
45
+ git clone https://github.com/infinitylogesh/gui-decisions && cd gui-decisions
46
+ pip install "vllm==0.30.*" -e .
47
+ bash serving/patch_vllm.sh # recommended: 256 label ids per request
48
+ ```
49
+
50
+ **2. Serve** (bf16, 62 GB of weights: one 80–96 GB GPU):
51
+
52
  ```bash
53
+ vllm serve infinitylogesh/GUI-Decisions-31B --served-model-name gui-decisions --port 8001 \
54
+ --max-model-len 8192 --gpu-memory-utilization 0.85 --max-logprobs 300 --enable-prefix-caching \
55
+ --mm-processor-cache-gb 0 --api-server-count 8
56
+ ```
57
+
58
+ **3. Read** steps and boxes:
59
+
60
+ ```python
61
+ from PIL import Image
62
+ from slotread.client import SlotModel
63
+
64
+ m = SlotModel("gui-decisions", "infinitylogesh/GUI-Decisions-31B") # server: VLLM_URL, default http://127.0.0.1:8001
65
+ step = m.decide(Image.open("screenshot.png"), "turn on dark mode") # {'action': 'click', 'x': 0.928, 'y': 0.247, 'ms': 190.0}
66
+ box = m.box(Image.open("photo.jpg"), "the red frisbee") # {'box': [x1, y1, x2, y2], 'ms': ...}, in [0, 1]
67
+ ```
68
+
69
+ `decide` reads `action`, `x` and `y` first, then only the slots the action needs (`key` for press, `sdir`
70
+ and `samt` for scroll, `x2` and `y2` for swipe). `x` and `y` are fractions of the screenshot's width and
71
+ height. For type / answer steps, serve the base model as well and pass its name as `text_model=` (the
72
+ merged weights only answer slots).
73
+
74
+ **What a read is.** For each slot, `SlotModel` sends one chat request whose assistant turn is prefilled up
75
+ to that slot, and asks vLLM for the log-probabilities of exactly that slot's labels; nothing is generated
76
+ beyond one token. The requests for one step run in parallel and share the image through vLLM's prefix cache:
77
+
78
+ ```json
79
+ {"model": "gui-decisions",
80
+ "messages": [{"role": "system", "content": [{"type": "text", "text": "<the task's system prompt, from slotread_config.json>"}]},
81
+ {"role": "user", "content": [{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}},
82
+ {"type": "text", "text": "Please generate the next move according to the UI screenshot, instruction and previous actions.\n\nInstruction: turn on dark mode\n\nPrevious actions:\nNone"}]},
83
+ {"role": "assistant", "content": [{"type": "text", "text": "action: ___ x:"}]}],
84
+ "add_generation_prompt": false, "continue_final_message": true, "chat_template_kwargs": {"enable_thinking": false},
85
+ "max_tokens": 1, "temperature": 0, "logprobs": true, "top_logprobs": 1, "return_tokens_as_token_ids": true,
86
+ "logprob_token_ids": ["<the 256 label ids of slot x, from slotread_config.json>"]}
87
  ```
88
 
89
+ The slot's answer is the softmax over those labels: the argmax for `action`; for a coordinate, the argmax
90
+ bin refined by its ±2 neighbours (bin *k* of 256 is the value (*k* + 0.5) / 256 across the screen).
91
+
92
+ Notes:
93
+
94
+ - `patch_vllm.sh` raises vLLM's per-request `logprob_token_ids` cap from 128 to 256, so a 256-bin slot is
95
+ one request. Without it, set `MAX_LABEL_IDS=128` for the client (each coordinate then takes two requests).
96
+ - `--api-server-count 8`: a single API-server process serializes a step's parallel slot requests.
97
+ `--mm-processor-cache-gb 0`: vLLM 0.30's media cache raced on concurrent requests for the same image.
98
+ - Screenshots go as JPEG at the model's input size (896 × 896 pixels' worth), the fast path. For tiny
99
+ targets send lossless full-size images instead (`IMG_FMT=png IMG_MAX_PX=0`), as the evaluations did.
100
+ - `previous` takes the earlier steps as numbered lines, e.g. `"1. click(One way)\n2. click(From)"`.
101
+
102
+ ### In-process with transformers (no server)
103
+
104
  ```python
105
  from PIL import Image
106
  from slotread.local import LocalSlotModel
107
 
108
  m = LocalSlotModel.from_pretrained("infinitylogesh/GUI-Decisions-31B")
109
+ step = m.decide(Image.open("screenshot.png"), "turn on dark mode")
110
+ box = m.box(Image.open("photo.jpg"), "the red frisbee")
 
111
  ```
112
 
 
 
 
113
  ## Results
114
 
115
  This merged model in bf16 with transformers (`slotread.local`), against the published evaluation of the