From 1bbc6e05daee32a2c6dc0a9dda02e88c47052806 Mon Sep 17 00:00:00 2001 From: RunningLeon Date: Fri, 3 Nov 2023 15:43:40 +0800 Subject: [PATCH] add cli to list the supported model names (#639) * update * resolve comment --- README.md | 2 +- README_zh-CN.md | 2 +- lmdeploy/cli/cli.py | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b40c0b90c..7639675ab 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ LMDeploy is a toolkit for compressing, deploying, and serving LLM, developed by ## Supported Models -`LMDeploy` has two inference backends, `Pytorch` and `TurboMind`. +`LMDeploy` has two inference backends, `Pytorch` and `TurboMind`. You can run `lmdeploy list` to check the supported model names. ### TurboMind diff --git a/README_zh-CN.md b/README_zh-CN.md index 763432f7c..38faad058 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -53,7 +53,7 @@ LMDeploy 由 [MMDeploy](https://github.com/open-mmlab/mmdeploy) 和 [MMRazor](ht ## 支持的模型 -`LMDeploy` 支持 `TurboMind` 和 `Pytorch` 两种推理后端 +`LMDeploy` 支持 `TurboMind` 和 `Pytorch` 两种推理后端。运行`lmdeploy list`可查看支持模型列表 ### TurboMind diff --git a/lmdeploy/cli/cli.py b/lmdeploy/cli/cli.py index 7b2634b53..6faef49de 100644 --- a/lmdeploy/cli/cli.py +++ b/lmdeploy/cli/cli.py @@ -49,6 +49,30 @@ def convert(self, quant_path=quant_path, group_size=group_size) + def list(self, engine: str = 'turbomind'): + """List supported model names. + + Examples 1: + lmdeploy list + + Examples 2: + lmdeploy list --engine pytorch + + Args: + engine (str): The backend for the model to run. Choice from + ['turbomind', 'pytorch']. + """ + assert engine in ['turbomind', 'pytorch'] + if engine == 'pytorch': + model_names = ['llama', 'llama2', 'internlm-7b'] + elif engine == 'turbomind': + from lmdeploy.model import MODELS + model_names = list(MODELS.module_dict.keys()) + model_names = [n for n in model_names if n.lower() not in ['base']] + model_names.sort() + print('Supported model names:') + print('\n'.join(model_names)) + def run(): """The entry point of running LMDeploy CLI."""