Lmdeploy python inference engine. Args: pretrained_model_name_or_path (str): It could be one of the following options: - i) The model_id of a lmdeploy-quantized model hosted inside a model repo on huggingface.co, such as
(cls,
pretrained_model_name_or_path: str,
engine_config: PytorchEngineConfig = None,
speculative_config: SpeculativeConfig = None,
trust_remote_code: bool = False,
**kwargs)
| 213 | |
| 214 | @classmethod |
| 215 | def from_pretrained(cls, |
| 216 | pretrained_model_name_or_path: str, |
| 217 | engine_config: PytorchEngineConfig = None, |
| 218 | speculative_config: SpeculativeConfig = None, |
| 219 | trust_remote_code: bool = False, |
| 220 | **kwargs): |
| 221 | """Lmdeploy python inference engine. |
| 222 | |
| 223 | Args: |
| 224 | pretrained_model_name_or_path (str): |
| 225 | It could be one of the following options: |
| 226 | - i) The model_id of a lmdeploy-quantized model hosted |
| 227 | inside a model repo on huggingface.co, such as |
| 228 | "InternLM/internlm-chat-20b-4bit", |
| 229 | "lmdeploy/llama2-chat-70b-4bit", etc. |
| 230 | - ii) The model_id of a model hosted inside a model repo |
| 231 | on huggingface.co, such as "InternLM/internlm-chat-7b", |
| 232 | "Qwen/Qwen-7B-Chat ", "baichuan-inc/Baichuan2-7B-Chat" |
| 233 | and so on. |
| 234 | engine_config (PytorchEngineConfig): Pytorch engine config. |
| 235 | trust_remote_code (bool): Trust remote code |
| 236 | """ |
| 237 | if engine_config is not None and engine_config.enable_mp_engine: |
| 238 | from .mp_engine import build_mp_engine |
| 239 | backend = engine_config.mp_engine_backend |
| 240 | return build_mp_engine( |
| 241 | backend=backend, |
| 242 | model_path=pretrained_model_name_or_path, |
| 243 | engine_config=engine_config, |
| 244 | speculative_config=speculative_config, |
| 245 | trust_remote_code=trust_remote_code |
| 246 | ) |
| 247 | if len(kwargs) > 0: |
| 248 | logger.debug(f'Get unexpected kwargs: {kwargs}') |
| 249 | return cls( |
| 250 | model_path=pretrained_model_name_or_path, |
| 251 | engine_config=engine_config, |
| 252 | speculative_config=speculative_config, |
| 253 | trust_remote_code=trust_remote_code |
| 254 | ) |
| 255 | |
| 256 | def _download_adapters(self, adapters: dict[str, str], engine_config: PytorchEngineConfig): |
| 257 | """Download adapters.""" |
no test coverage detected