Skip to content

Commit 74aeb43

Browse files
committed
feat: enable GLM-4v-9B in vLLM evaluation and registry
1 parent 90c9010 commit 74aeb43

File tree

2 files changed

+78
-21
lines changed

2 files changed

+78
-21
lines changed

eval_with_vllm.sh

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ declare -A MODEL_GROUP_MAP=(
88
# ["Qwen/Qwen3-VL-30B-A3B-Instruct"]="vllm_normal"
99
# ["moonshotai/Kimi-VL-A3B-Instruct"]="vllm_normal" # 今は動かない
1010
# ["deepseek-ai/deepseek-vl2"]="vllm_normal"
11-
["openbmb/MiniCPM-o-2_6"]="vllm_normal"
11+
# ["openbmb/MiniCPM-o-2_6"]="vllm_normal"
12+
["zai-org/glm-4v-9b"]="vllm_normal"
1213
# ["OpenGVLab/InternVL3-1B"]="vllm_normal"
1314
# ["OpenGVLab/InternVL3-2B"]="vllm_normal"
1415
# ["OpenGVLab/InternVL3-8B"]="vllm_normal"
@@ -19,26 +20,26 @@ declare -A MODEL_GROUP_MAP=(
1920

2021
declare -a task_list=(
2122
"japanese-heron-bench"
22-
"ja-vlm-bench-in-the-wild"
23-
"ja-vg-vqa-500"
24-
"jmmmu"
25-
"ja-multi-image-vqa"
26-
"jdocqa"
27-
"mmmu"
28-
"llava-bench-in-the-wild"
29-
"jic-vqa"
30-
"cvqa"
31-
"cc-ocr"
32-
"mecha-ja"
33-
"ai2d"
34-
# "blink"
35-
"docvqa"
36-
"infographicvqa"
37-
"textvqa"
38-
"chartqa"
39-
# "chartqapro"
40-
# "mathvista"
41-
"okvqa"
23+
# "ja-vlm-bench-in-the-wild"
24+
# "ja-vg-vqa-500"
25+
# "jmmmu"
26+
# "ja-multi-image-vqa"
27+
# "jdocqa"
28+
# "mmmu"
29+
# "llava-bench-in-the-wild"
30+
# "jic-vqa"
31+
# "cvqa"
32+
# "cc-ocr"
33+
# "mecha-ja"
34+
# "ai2d"
35+
# # "blink"
36+
# "docvqa"
37+
# "infographicvqa"
38+
# "textvqa"
39+
# "chartqa"
40+
# # "chartqapro"
41+
# # "mathvista"
42+
# "okvqa"
4243
)
4344

4445
# === Metrics Mapping ===

examples/vllm_registry.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def __init__(self, model_id: str):
5454
self._engine_args_minicpm_o,
5555
self._load_minicpm_o,
5656
),
57+
"zai-org/glm-4v-9b": (
58+
self._engine_args_glm4v,
59+
self._load_glm4v,
60+
),
5761
}
5862

5963
for internvl_model in INTERNVL_MODELS:
@@ -237,6 +241,42 @@ def _load_deepseek_vl2(
237241

238242
return ModelRequestData(prompts=prompts)
239243

244+
def _engine_args_glm4v(self) -> EngineArgs:
245+
return EngineArgs(
246+
model=self.model_id,
247+
max_model_len=2048,
248+
max_num_seqs=2,
249+
trust_remote_code=True,
250+
enforce_eager=True,
251+
hf_overrides={"architectures": ["GLM4VForCausalLM"]},
252+
limit_mm_per_prompt={self.modality: 5},
253+
)
254+
255+
def _load_glm4v(
256+
self, texts: list[str], images_list: list[list[Image.Image]]
257+
) -> ModelRequestData:
258+
if len(texts) != len(images_list):
259+
msg = "texts and images_list must have identical length"
260+
raise ValueError(msg)
261+
262+
prompts: list[str] = []
263+
for text, images in zip(texts, images_list):
264+
num_images = len(images)
265+
if num_images > 0:
266+
image_tokens = "".join(
267+
"<|begin_of_image|><|endoftext|><|end_of_image|>"
268+
for _ in range(num_images)
269+
)
270+
else:
271+
image_tokens = ""
272+
273+
prompt = "<|user|>\n" + f"{image_tokens}{text}<|assistant|>"
274+
prompts.append(prompt)
275+
276+
stop_token_ids = [151329, 151336, 151338]
277+
278+
return ModelRequestData(prompts=prompts, stop_token_ids=stop_token_ids)
279+
240280
def _engine_args_minicpm_o(self) -> EngineArgs:
241281
return EngineArgs(
242282
model=self.model_id,
@@ -359,6 +399,20 @@ def preview_deepseek_vl2_requests(
359399
return registry.build_requests(texts, images_list)
360400

361401

402+
def preview_glm4v_requests(
403+
texts: list[str], image_counts: list[int]
404+
) -> ModelRequestData:
405+
"""Build prompts for GLM-4V using dummy images (testing helper)."""
406+
407+
if len(texts) != len(image_counts):
408+
msg = "texts and image_counts must have identical length"
409+
raise ValueError(msg)
410+
411+
images_list = [_generate_dummy_images(count) for count in image_counts]
412+
registry = VLLMModelRegistry("zai-org/glm-4v-9b")
413+
return registry.build_requests(texts, images_list)
414+
415+
362416
def preview_minicpm_o_requests(
363417
texts: list[str], image_counts: list[int]
364418
) -> ModelRequestData:
@@ -384,6 +438,7 @@ def _parse_cli_args() -> argparse.Namespace:
384438
"Qwen/Qwen3-VL-30B-A3B-Instruct",
385439
"moonshotai/Kimi-VL-A3B-Instruct",
386440
"deepseek-ai/deepseek-vl2",
441+
"zai-org/glm-4v-9b",
387442
"openbmb/MiniCPM-o-2_6",
388443
*INTERNVL_MODELS,
389444
],
@@ -436,6 +491,7 @@ def _preview_cli() -> None:
436491
"Qwen/Qwen3-VL-30B-A3B-Instruct": preview_qwen3_vl_requests,
437492
"moonshotai/Kimi-VL-A3B-Instruct": preview_kimi_vl_requests,
438493
"deepseek-ai/deepseek-vl2": preview_deepseek_vl2_requests,
494+
"zai-org/glm-4v-9b": preview_glm4v_requests,
439495
"openbmb/MiniCPM-o-2_6": preview_minicpm_o_requests,
440496
}
441497

0 commit comments

Comments
 (0)