| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | import os |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | from tests.models.language.pooling_mteb_test.mteb_embed_utils import ( |
| 8 | MTEB_EMBED_TASKS, |
| 9 | MTEB_EMBED_TOL, |
| 10 | OpenAIClientMtebEncoder, |
| 11 | run_mteb_embed_task, |
| 12 | ) |
| 13 | from tests.utils import RemoteOpenAIServer |
| 14 | |
| 15 | os.environ["VLLM_LOGGING_LEVEL"] = "WARNING" |
| 16 | |
| 17 | MODEL_NAME = "intfloat/e5-small" |
| 18 | MAIN_SCORE = 0.7422994752439667 |
| 19 | |
| 20 | |
| 21 | @pytest.fixture(scope="module") |
| 22 | def server(): |
| 23 | args = ["--runner", "pooling", "--enforce-eager", "--disable-uvicorn-access-log"] |
| 24 | |
| 25 | with RemoteOpenAIServer(MODEL_NAME, args) as remote_server: |
| 26 | yield remote_server |
| 27 | |
| 28 | |
| 29 | def test_mteb_embed(server): |
| 30 | client = server.get_client() |
| 31 | encoder = OpenAIClientMtebEncoder(MODEL_NAME, client) |
| 32 | vllm_main_score = run_mteb_embed_task(encoder, MTEB_EMBED_TASKS) |
| 33 | st_main_score = MAIN_SCORE |
| 34 | |
| 35 | print("VLLM main score: ", vllm_main_score) |
| 36 | print("SentenceTransformer main score: ", st_main_score) |
| 37 | print("Difference: ", st_main_score - vllm_main_score) |
| 38 | |
| 39 | # We are not concerned that the vllm mteb results are better |
| 40 | # than SentenceTransformers, so we only perform one-sided testing. |
| 41 | assert st_main_score - vllm_main_score < MTEB_EMBED_TOL |