test_short_mm_context.py 977 Bytes
Newer Older
1
2
3
import pytest

from ..conftest import IMAGE_ASSETS
zhuwenwen's avatar
zhuwenwen committed
4
from ..utils import models_path_prefix
5
6
7
8
9
10
11
12

HF_IMAGE_PROMPTS = IMAGE_ASSETS.prompts({
    "stop_sign":
    "USER: <image>\nWhat's the content of the image?\nASSISTANT:",
    "cherry_blossom":
    "USER: <image>\nWhat is the season?\nASSISTANT:",
})

zhuwenwen's avatar
zhuwenwen committed
13
models = [os.path.join(models_path_prefix, "llava-hf/llava-1.5-7b-hf")]
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30


@pytest.mark.parametrize("model", models)
def test_context_length_too_short(vllm_runner, image_assets, model):
    images = [asset.pil_image for asset in image_assets]

    with pytest.raises(ValueError, match="too long to fit into the model"):
        vllm_model = vllm_runner(
            model,
            max_model_len=128,  # LLaVA has a feature size of 576
            enforce_eager=True,
        )

        with vllm_model:
            vllm_model.generate_greedy([HF_IMAGE_PROMPTS[0]],
                                       max_tokens=1,
                                       images=[images[0]])