[Model] Add support for BERT-like Chinese ERNIE pooling models (#36385)
Signed-off-by: whyiug <whyiug@hotmail.com> Co-authored-by: wang.yuqi <yuqi.wang@daocloud.io>
This commit is contained in:
@@ -18,6 +18,7 @@ from vllm.platforms import current_platform
|
||||
pytest.mark.slow_test,
|
||||
],
|
||||
),
|
||||
pytest.param("Forrest20231206/ernie-3.0-base-zh-cls"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("dtype", ["half"] if current_platform.is_rocm() else ["float"])
|
||||
@@ -47,5 +48,6 @@ def test_models(
|
||||
assert torch.allclose(
|
||||
hf_output,
|
||||
vllm_output,
|
||||
atol=1e-3 if dtype == "float" else 1e-2,
|
||||
rtol=2e-3 if dtype == "float" else 1e-2,
|
||||
)
|
||||
|
||||
@@ -25,11 +25,17 @@ def seed_everything():
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", ["boltuix/NeuroBERT-NER"])
|
||||
@pytest.mark.parametrize(
|
||||
"model",
|
||||
[
|
||||
"boltuix/NeuroBERT-NER",
|
||||
"gyr66/Ernie-3.0-base-chinese-finetuned-ner",
|
||||
],
|
||||
)
|
||||
# The float32 is required for this tiny model to pass the test.
|
||||
@pytest.mark.parametrize("dtype", ["float"])
|
||||
@torch.inference_mode
|
||||
def test_bert_models(
|
||||
def test_bert_like_models(
|
||||
hf_runner,
|
||||
vllm_runner,
|
||||
example_prompts,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.models.language.pooling.embed_utils import correctness_test_embed_models
|
||||
from tests.models.utils import EmbedModelInfo
|
||||
|
||||
from .mteb_embed_utils import mteb_test_embed_models
|
||||
|
||||
MODELS = [
|
||||
EmbedModelInfo(
|
||||
"shibing624/text2vec-base-chinese-sentence",
|
||||
architecture="ErnieModel",
|
||||
mteb_score=0.536523112,
|
||||
seq_pooling_type="MEAN",
|
||||
attn_type="encoder_only",
|
||||
is_prefix_caching_supported=False,
|
||||
is_chunked_prefill_supported=False,
|
||||
enable_test=True,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model_info", MODELS)
|
||||
def test_embed_models_mteb(hf_runner, vllm_runner, model_info: EmbedModelInfo) -> None:
|
||||
mteb_test_embed_models(
|
||||
hf_runner,
|
||||
vllm_runner,
|
||||
model_info,
|
||||
vllm_extra_kwargs={"gpu_memory_utilization": 0.2},
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model_info", MODELS)
|
||||
def test_embed_models_correctness(
|
||||
hf_runner, vllm_runner, model_info: EmbedModelInfo, example_prompts
|
||||
) -> None:
|
||||
correctness_test_embed_models(
|
||||
hf_runner,
|
||||
vllm_runner,
|
||||
model_info,
|
||||
example_prompts,
|
||||
vllm_extra_kwargs={"gpu_memory_utilization": 0.2},
|
||||
)
|
||||
@@ -552,6 +552,7 @@ _TEXT_GENERATION_EXAMPLE_MODELS = {
|
||||
_EMBEDDING_EXAMPLE_MODELS = {
|
||||
# [Text-only]
|
||||
"BertModel": _HfExamplesInfo("BAAI/bge-base-en-v1.5"),
|
||||
"ErnieModel": _HfExamplesInfo("shibing624/text2vec-base-chinese-sentence"),
|
||||
"BertSpladeSparseEmbeddingModel": _HfExamplesInfo(
|
||||
"naver/splade-v3",
|
||||
hf_overrides={"architectures": ["BertSpladeSparseEmbeddingModel"]},
|
||||
@@ -666,6 +667,9 @@ _REWARD_EXAMPLE_MODELS = {
|
||||
|
||||
_TOKEN_CLASSIFICATION_EXAMPLE_MODELS = {
|
||||
"BertForTokenClassification": _HfExamplesInfo("boltuix/NeuroBERT-NER"),
|
||||
"ErnieForTokenClassification": _HfExamplesInfo(
|
||||
"gyr66/Ernie-3.0-base-chinese-finetuned-ner"
|
||||
),
|
||||
"ModernBertForTokenClassification": _HfExamplesInfo(
|
||||
"disham993/electrical-ner-ModernBERT-base"
|
||||
),
|
||||
@@ -675,6 +679,9 @@ _SEQUENCE_CLASSIFICATION_EXAMPLE_MODELS = {
|
||||
"BertForSequenceClassification": _HfExamplesInfo(
|
||||
"cross-encoder/ms-marco-MiniLM-L-6-v2"
|
||||
),
|
||||
"ErnieForSequenceClassification": _HfExamplesInfo(
|
||||
"Forrest20231206/ernie-3.0-base-zh-cls",
|
||||
),
|
||||
"GPT2ForSequenceClassification": _HfExamplesInfo(
|
||||
"nie3e/sentiment-polish-gpt2-small"
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user