-
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: support loading gemma2 as vlm text model * feat: add test for paligemma2
- Loading branch information
Showing
3 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
133 changes: 133 additions & 0 deletions
133
...ration-tests/models/__snapshots__/test_flash_pali_gemma2/test_flash_pali_gemma_image.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,133 @@ | ||
{ | ||
"details": { | ||
"best_of_sequences": null, | ||
"finish_reason": "length", | ||
"generated_tokens": 20, | ||
"prefill": [], | ||
"seed": null, | ||
"tokens": [ | ||
{ | ||
"id": 108, | ||
"logprob": -0.73046875, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 30234, | ||
"logprob": -2.328125, | ||
"special": false, | ||
"text": "Brown" | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.12060547, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 3726, | ||
"logprob": -1.7734375, | ||
"special": false, | ||
"text": "Car" | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.041503906, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 2915, | ||
"logprob": -1.796875, | ||
"special": false, | ||
"text": "Color" | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.039794922, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 19178, | ||
"logprob": -1.96875, | ||
"special": false, | ||
"text": "Cool" | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.080566406, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 40544, | ||
"logprob": -2.1875, | ||
"special": false, | ||
"text": "Decor" | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.033935547, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 13936, | ||
"logprob": -1.6328125, | ||
"special": false, | ||
"text": "Green" | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.16210938, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 955, | ||
"logprob": -2.015625, | ||
"special": false, | ||
"text": "..." | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.14746094, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 955, | ||
"logprob": -0.73828125, | ||
"special": false, | ||
"text": "..." | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.051513672, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 955, | ||
"logprob": -0.34765625, | ||
"special": false, | ||
"text": "..." | ||
}, | ||
{ | ||
"id": 108, | ||
"logprob": -0.020141602, | ||
"special": false, | ||
"text": "\n" | ||
}, | ||
{ | ||
"id": 955, | ||
"logprob": -0.11767578, | ||
"special": false, | ||
"text": "..." | ||
} | ||
], | ||
"top_tokens": null | ||
}, | ||
"generated_text": "\nBrown\nCar\nColor\nCool\nDecor\nGreen\n...\n...\n...\n..." | ||
} |
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,29 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def flash_pali_gemma_handle(launcher): | ||
with launcher( | ||
"google/paligemma2-3b-pt-224", | ||
) as handle: | ||
yield handle | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def flash_pali_gemma(flash_pali_gemma_handle): | ||
await flash_pali_gemma_handle.health(300) | ||
return flash_pali_gemma_handle.client | ||
|
||
|
||
async def test_flash_pali_gemma_image(flash_pali_gemma, response_snapshot): | ||
car_image = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg" | ||
response = await flash_pali_gemma.generate( | ||
f"![]({car_image})", | ||
max_new_tokens=20, | ||
) | ||
assert ( | ||
response.generated_text | ||
== "\nBrown\nCar\nColor\nCool\nDecor\nGreen\n...\n...\n...\n..." | ||
) | ||
|
||
assert 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