(model: Union[str, List[str], Model,
List[Model]],
revision: Optional[str],
kwargs: Dict[str, Any])
| 299 | |
| 300 | |
| 301 | def external_engine_for_llm_checker(model: Union[str, List[str], Model, |
| 302 | List[Model]], |
| 303 | revision: Optional[str], |
| 304 | kwargs: Dict[str, Any]) -> Optional[str]: |
| 305 | from .nlp.llm_pipeline import ModelTypeHelper, LLMAdapterRegistry |
| 306 | from ..hub.check_model import get_model_id_from_cache |
| 307 | if isinstance(model, list): |
| 308 | model = model[0] |
| 309 | if not isinstance(model, str): |
| 310 | model = model.model_dir |
| 311 | |
| 312 | llm_framework = kwargs.get('llm_framework', '') |
| 313 | if llm_framework == 'swift': |
| 314 | try: |
| 315 | from swift.model import get_model_info_meta |
| 316 | except ImportError: |
| 317 | from swift.llm import get_model_info_meta |
| 318 | # check if swift supports |
| 319 | if os.path.exists(model): |
| 320 | model_id = get_model_id_from_cache(model) |
| 321 | else: |
| 322 | model_id = model |
| 323 | |
| 324 | try: |
| 325 | info = get_model_info_meta(model_id) |
| 326 | model_type = info[0].model_type |
| 327 | except Exception as e: |
| 328 | logger.warning(f'Cannot using llm_framework with {model_id}, ' |
| 329 | f'ignoring llm_framework={llm_framework} : {e}') |
| 330 | model_type = None |
| 331 | if model_type: |
| 332 | return 'llm' |
| 333 | |
| 334 | model_type = ModelTypeHelper.get( |
| 335 | model, revision, with_adapter=True, split='-', use_cache=True) |
| 336 | if LLMAdapterRegistry.contains(model_type): |
| 337 | return 'llm' |
| 338 | |
| 339 | |
| 340 | def clear_llm_info(kwargs: Dict, pipeline_name: str): |
no test coverage detected
searching dependent graphs…