[Bugfix][Model] Add base class for vision-language models (#4809)

This commit is contained in:
Cyrus Leung
2024-05-19 15:13:33 +08:00
committed by GitHub
parent 2e9a2227ec
commit f68470e803
4 changed files with 53 additions and 29 deletions

View File

@@ -26,11 +26,7 @@ from vllm.model_executor.model_loader.weight_utils import (
download_weights_from_hf, filter_files_not_needed_for_inference,
get_quant_config, initialize_dummy_weights, np_cache_weights_iterator,
pt_weights_iterator, safetensors_weights_iterator)
from vllm.model_executor.models.llava import LlavaForConditionalGeneration
_VISION_MODEL_CLASSES = [
LlavaForConditionalGeneration,
]
from vllm.model_executor.models.vlm_base import VisionLanguageModelBase
logger = init_logger(__name__)
@@ -73,7 +69,12 @@ def _get_model_initialization_kwargs(
"but LoRA is enabled. Support for this model may "
"be added in the future. If this is important to you, "
"please open an issue on github.")
elif model_class in _VISION_MODEL_CLASSES:
elif issubclass(model_class, VisionLanguageModelBase):
if vision_language_config is None:
raise ValueError("Provide `image_input_type` and other vision "
"related configurations through LLM entrypoint "
"or engine arguments.")
extra_kwargs["vision_language_config"] = vision_language_config
return extra_kwargs