-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add initial qwen2.5-vl model and test
- Loading branch information
Showing
8 changed files
with
857 additions
and
3 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...ration-tests/models/__snapshots__/test_flash_qwen2_5_vl/test_flash_qwen2_5_vl_simple.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"choices": [ | ||
{ | ||
"finish_reason": "stop", | ||
"index": 0, | ||
"logprobs": null, | ||
"message": { | ||
"content": "The image depicts a person in a space-themed environment, possibly on another planet given the red sand and harsh landscape in the background. The individual is wearing a detailed, high-tech spacesuit with various gadgets and gadgets. The space suit features a large red button in the center of the chest, and the individual is in a crouched, ready stance, as if in a dramatic or adventurous pose. The background showcases an expansive high gorge or canyon, with walls of red and orange hues, with potential light sources in the distance that create a dramatic and intense atmosphere.", | ||
"name": null, | ||
"role": "assistant", | ||
"tool_calls": null | ||
}, | ||
"usage": null | ||
} | ||
], | ||
"created": 1738257213, | ||
"id": "", | ||
"model": "Qwen/Qwen2.5-VL-3B-Instruct", | ||
"object": "chat.completion", | ||
"system_fingerprint": "3.0.2-dev0-native", | ||
"usage": { | ||
"completion_tokens": 114, | ||
"prompt_tokens": 1363, | ||
"total_tokens": 1477 | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ts/models/__snapshots__/test_flash_qwen2_5_vl/test_flash_qwen2_5_vl_simple_streaming.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"choices": [ | ||
{ | ||
"delta": { | ||
"content": "", | ||
"role": "assistant", | ||
"tool_calls": null | ||
}, | ||
"finish_reason": "stop", | ||
"index": 0, | ||
"logprobs": null | ||
} | ||
], | ||
"created": 1738257318, | ||
"id": "", | ||
"model": "Qwen/Qwen2.5-VL-3B-Instruct", | ||
"object": "chat.completion.chunk", | ||
"system_fingerprint": "3.0.2-dev0-native", | ||
"usage": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def flash_qwen2_5_vl_handle(launcher): | ||
with launcher("Qwen/Qwen2.5-VL-3B-Instruct") as handle: | ||
yield handle | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def flash_qwen2_5(flash_qwen2_5_vl_handle): | ||
await flash_qwen2_5_vl_handle.health(300) | ||
return flash_qwen2_5_vl_handle.client | ||
|
||
|
||
@pytest.mark.private | ||
async def test_flash_qwen2_5_vl_simple(flash_qwen2_5, response_snapshot): | ||
response = await flash_qwen2_5.chat( | ||
seed=1337, | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": [ | ||
{ | ||
"type": "image_url", | ||
"image_url": { | ||
"url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rabbit.png" | ||
}, | ||
}, | ||
{"type": "text", "text": "Describe the image"}, | ||
], | ||
}, | ||
], | ||
) | ||
|
||
assert ( | ||
response.choices[0].message.content | ||
== "The image depicts a person in a space-themed environment, possibly on another planet given the red sand and harsh landscape in the background. The individual is wearing a detailed, high-tech spacesuit with various gadgets and gadgets. The space suit features a large red button in the center of the chest, and the individual is in a crouched, ready stance, as if in a dramatic or adventurous pose. The background showcases an expansive high gorge or canyon, with walls of red and orange hues, with potential light sources in the distance that create a dramatic and intense atmosphere." | ||
) | ||
|
||
assert response == response_snapshot | ||
|
||
|
||
@pytest.mark.private | ||
async def test_flash_qwen2_5_vl_simple_streaming(flash_qwen2_5, response_snapshot): | ||
responses = await flash_qwen2_5.chat( | ||
seed=1337, | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": [ | ||
{ | ||
"type": "image_url", | ||
"image_url": { | ||
"url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rabbit.png" | ||
}, | ||
}, | ||
{"type": "text", "text": "Describe the image"}, | ||
], | ||
}, | ||
], | ||
stream=True, | ||
) | ||
|
||
count = 0 | ||
generated = "" | ||
last_response = None | ||
async for response in responses: | ||
count += 1 | ||
generated += response.choices[0].delta.content | ||
last_response = response | ||
|
||
assert ( | ||
generated | ||
== "The image depicts a person in a space-themed environment, possibly on another planet given the red sand and harsh landscape in the background. The individual is wearing a detailed, high-tech spacesuit with various gadgets and gadgets. The space suit features a large red button in the center of the chest, and the individual is in a crouched, ready stance, as if in a dramatic or adventurous pose. The background showcases an expansive high gorge or canyon, with walls of red and orange hues, with potential light sources in the distance that create a dramatic and intense atmosphere." | ||
) | ||
assert count == 114 | ||
assert last_response == response_snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.