fix: bump idefics3 tests and snapshots

This commit is contained in:
drbh 2024-12-18 05:06:49 +00:00
parent 53b2bea6b9
commit 34174af8c8
2 changed files with 46 additions and 85 deletions

View File

@ -1,73 +1,67 @@
{ {
"details": { "details": {
"best_of_sequences": null, "best_of_sequences": null,
"finish_reason": "length", "finish_reason": "eos_token",
"generated_tokens": 10, "generated_tokens": 9,
"prefill": [], "prefill": [],
"seed": null, "seed": null,
"tokens": [ "tokens": [
{ {
"id": 578, "id": 2684,
"logprob": -0.2475586, "logprob": -0.24902344,
"special": false, "special": false,
"text": " The" "text": " There"
}, },
{ {
"id": 2217, "id": 374,
"logprob": -0.017303467, "logprob": -0.0703125,
"special": false, "special": false,
"text": " image" "text": " is"
},
{
"id": 62991,
"logprob": -0.7368164,
"special": false,
"text": " depicts"
},
{
"id": 279,
"logprob": -0.39990234,
"special": false,
"text": " the"
},
{
"id": 89675,
"logprob": -0.34350586,
"special": false,
"text": " Statue"
},
{
"id": 315,
"logprob": -0.0002901554,
"special": false,
"text": " of"
},
{
"id": 32492,
"logprob": -0.0009598732,
"special": false,
"text": " Liberty"
},
{
"id": 11,
"logprob": -0.2355957,
"special": false,
"text": ","
}, },
{ {
"id": 264, "id": 264,
"logprob": -0.66503906, "logprob": -0.23535156,
"special": false, "special": false,
"text": " a" "text": " a"
}, },
{ {
"id": 97937, "id": 35372,
"logprob": -0.9199219, "logprob": -0.125,
"special": false, "special": false,
"text": " colossal" "text": " statue"
},
{
"id": 304,
"logprob": -0.30273438,
"special": false,
"text": " in"
},
{
"id": 279,
"logprob": -0.20507812,
"special": false,
"text": " the"
},
{
"id": 2217,
"logprob": -0.076171875,
"special": false,
"text": " image"
},
{
"id": 13,
"logprob": -0.053710938,
"special": false,
"text": "."
},
{
"id": 128258,
"logprob": -0.011352539,
"special": true,
"text": "<end_of_utterance>"
} }
], ],
"top_tokens": null "top_tokens": null
}, },
"generated_text": " The image depicts the Statue of Liberty, a colossal" "generated_text": " There is a statue in the image."
} }

View File

@ -1,21 +1,9 @@
import pytest import pytest
import base64
def get_chicken():
with open("integration-tests/images/chicken_on_money.png", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
return f"data:image/png;base64,{encoded_string.decode('utf-8')}"
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def flash_idefics3_next_handle(launcher): def flash_idefics3_next_handle(launcher):
with launcher( with launcher("HuggingFaceM4/Idefics3-8B-Llama3") as handle:
"HuggingFaceM4/Idefics3-8B-Llama3",
max_total_tokens=3000,
max_batch_prefill_tokens=2501,
max_input_tokens=2500,
) as handle:
yield handle yield handle
@ -25,26 +13,6 @@ async def flash_idefics3_next(flash_idefics3_next_handle):
return flash_idefics3_next_handle.client return flash_idefics3_next_handle.client
# TODO: dont skip when token issue is resolved
@pytest.mark.skip
@pytest.mark.asyncio
@pytest.mark.private
async def test_flash_idefics3_next_simple_base64(
flash_idefics3_next, response_snapshot
):
chicken = get_chicken()
query = "Write me a short story"
response = await flash_idefics3_next.generate(
f"<|begin_of_text|><|begin_of_text|>User:![]({chicken}){query}<end_of_utterance>\nAssistant:",
max_new_tokens=10,
)
assert (
response.generated_text == " A chicken is sitting on a pile of money."
), f"{repr(response.generated_text)}"
# assert response.details.generated_tokens == 10
# assert response == response_snapshot
@pytest.mark.asyncio @pytest.mark.asyncio
@pytest.mark.private @pytest.mark.private
async def test_flash_idefics3_next_simple_url(flash_idefics3_next, response_snapshot): async def test_flash_idefics3_next_simple_url(flash_idefics3_next, response_snapshot):
@ -57,8 +25,7 @@ async def test_flash_idefics3_next_simple_url(flash_idefics3_next, response_snap
) )
print(response) print(response)
assert ( assert (
response.generated_text response.generated_text == " There is a statue in the image."
== " The image depicts the Statue of Liberty, a colossal"
), f"{repr(response.generated_text)}" ), f"{repr(response.generated_text)}"
assert response.details.generated_tokens == 10 assert response.details.generated_tokens == 9
assert response == response_snapshot assert response == response_snapshot