| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | import pytest |
| 4 | |
| 5 | from tests.models.language.pooling.embed_utils import correctness_test_embed_models |
| 6 | from tests.models.utils import EmbedModelInfo |
| 7 | |
| 8 | from .mteb_embed_utils import mteb_test_embed_models |
| 9 | |
| 10 | MODELS = [ |
| 11 | ########## BertModel |
| 12 | EmbedModelInfo( |
| 13 | "intfloat/e5-small", |
| 14 | architecture="BertModel", |
| 15 | mteb_score=0.742285423, |
| 16 | mteb_tol=2e-3, |
| 17 | seq_pooling_type="MEAN", |
| 18 | attn_type="encoder_only", |
| 19 | is_prefix_caching_supported=False, |
| 20 | is_chunked_prefill_supported=False, |
| 21 | enable_test=True, |
| 22 | ), |
| 23 | EmbedModelInfo("intfloat/e5-base", architecture="BertModel", enable_test=False), |
| 24 | EmbedModelInfo("intfloat/e5-large", architecture="BertModel", enable_test=False), |
| 25 | EmbedModelInfo( |
| 26 | "intfloat/multilingual-e5-small", architecture="BertModel", enable_test=False |
| 27 | ), |
| 28 | ########## XLMRobertaModel |
| 29 | EmbedModelInfo( |
| 30 | "intfloat/multilingual-e5-base", |
| 31 | architecture="XLMRobertaModel", |
| 32 | mteb_score=0.779325955, |
| 33 | mteb_tol=2e-3, |
| 34 | seq_pooling_type="MEAN", |
| 35 | attn_type="encoder_only", |
| 36 | is_prefix_caching_supported=False, |
| 37 | is_chunked_prefill_supported=False, |
| 38 | enable_test=True, |
| 39 | ), |
| 40 | EmbedModelInfo( |
| 41 | "intfloat/multilingual-e5-large", |
| 42 | architecture="XLMRobertaModel", |
| 43 | enable_test=False, |
| 44 | ), |
| 45 | EmbedModelInfo( |
| 46 | "intfloat/multilingual-e5-large-instruct", |
| 47 | architecture="XLMRobertaModel", |
| 48 | enable_test=False, |
| 49 | ), |
| 50 | ] |
| 51 | |
| 52 | |
| 53 | @pytest.mark.flaky(reruns=2) |
| 54 | @pytest.mark.parametrize("model_info", MODELS) |
| 55 | def test_embed_models_mteb(hf_runner, vllm_runner, model_info: EmbedModelInfo) -> None: |
| 56 | mteb_test_embed_models(hf_runner, vllm_runner, model_info) |
| 57 | |
| 58 | |
| 59 | @pytest.mark.parametrize("model_info", MODELS) |
| 60 | def test_embed_models_correctness( |
| 61 | hf_runner, vllm_runner, model_info: EmbedModelInfo, example_prompts |
| 62 | ) -> None: |
| 63 | correctness_test_embed_models(hf_runner, vllm_runner, model_info, example_prompts) |