Components
Finetune
lazyllm.components.finetune.AlpacaloraFinetune
Bases: LazyLLMFinetuneBase
This class is a subclass of LazyLLMFinetuneBase
, based on the LoRA fine-tuning capabilities provided by the alpaca-lora project, used for LoRA fine-tuning of large language models.
Parameters:
-
base_model
(str
) –The base model used for fine-tuning. It is required to be the path of the base model.
-
target_path
(str
) –The path where the LoRA weights of the fine-tuned model are saved.
-
merge_path
(str
, default:None
) –The path where the model merges the LoRA weights, default to
None
. If not specified, "lazyllm_lora" and "lazyllm_merge" directories will be created undertarget_path
astarget_path
andmerge_path
respectively. -
model_name
(str
, default:'LLM'
) –The name of the model, used as the prefix for setting the log name, default to "LLM".
-
cp_files
(str
, default:'tokeniz*'
) –Specify configuration files to be copied from the base model path, which will be copied to
merge_path
, default totokeniz*
-
launcher
(launcher
, default:remote(ngpus=1)
) –The launcher for fine-tuning, default to
launchers.remote(ngpus=1)
. -
kw
–Keyword arguments, used to update the default training parameters. Note that additional keyword arguments cannot be arbitrarily specified.
The keyword arguments and their default values for this class are as follows:
Other Parameters:
-
data_path
(str
) –Data path, default to
None
; generally passed as the only positional argument when this object is called. -
batch_size
(int
) –Batch size, default to
64
. -
micro_batch_size
(int
) –Micro-batch size, default to
4
. -
num_epochs
(int
) –Number of training epochs, default to
2
. -
learning_rate
(float
) –Learning rate, default to
5.e-4
. -
cutoff_len
(int
) –Cutoff length, default to
1030
; input data tokens will be truncated if they exceed this length. -
filter_nums
(int
) –Number of filters, default to
1024
; only input with token length below this value is preserved. -
val_set_size
(int
) –Validation set size, default to
200
. -
lora_r
(int
) –LoRA rank, default to
8
; this value determines the amount of parameters added, the smaller the value, the fewer the parameters. -
lora_alpha
(int
) –LoRA fusion factor, default to
32
; this value determines the impact of LoRA parameters on the base model parameters, the larger the value, the greater the impact. -
lora_dropout
(float
) –LoRA dropout rate, default to
0.05
, generally used to prevent overfitting. -
lora_target_modules
(str
) –LoRA target modules, default to
[wo,wqkv]
, which is the default for InternLM2 model; this configuration item varies for different models. -
modules_to_save
(str
) –Modules for full fine-tuning, default to
[tok_embeddings,output]
, which is the default for InternLM2 model; this configuration item varies for different models. -
deepspeed
(str
) –The path of the DeepSpeed configuration file, default to use the pre-made configuration file in the LazyLLM code repository:
ds.json
. -
prompt_template_name
(str
) –The name of the prompt template, default to "alpaca", i.e., use the prompt template provided by LazyLLM by default.
-
train_on_inputs
(bool
) –Whether to train on inputs, default to
True
. -
show_prompt
(bool
) –Whether to show the prompt, default to
False
. -
nccl_port
(int
) –NCCL port, default to
19081
.
Examples:
>>> from lazyllm import finetune
>>> trainer = finetune.alpacalora('path/to/base/model', 'path/to/target')
Source code in lazyllm/components/finetune/alpacalora.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
lazyllm.components.finetune.CollieFinetune
Bases: LazyLLMFinetuneBase
This class is a subclass of LazyLLMFinetuneBase
, based on the LoRA fine-tuning capabilities provided by the Collie framework, used for LoRA fine-tuning of large language models.
Parameters:
-
base_model
(str
) –The base model used for fine-tuning. It is required to be the path of the base model.
-
target_path
(str
) –The path where the LoRA weights of the fine-tuned model are saved.
-
merge_path
(str
, default:None
) –The path where the model merges the LoRA weights, default to
None
. If not specified, "lazyllm_lora" and "lazyllm_merge" directories will be created undertarget_path
astarget_path
andmerge_path
respectively. -
model_name
(str
, default:'LLM'
) –The name of the model, used as the prefix for setting the log name, default to "LLM".
-
cp_files
(str
, default:'tokeniz*'
) –Specify configuration files to be copied from the base model path, which will be copied to
merge_path
, default to "tokeniz*" -
launcher
(launcher
, default:remote(ngpus=1)
) –The launcher for fine-tuning, default to
launchers.remote(ngpus=1)
. -
kw
–Keyword arguments, used to update the default training parameters. Note that additional keyword arguments cannot be arbitrarily specified.
The keyword arguments and their default values for this class are as follows:
Other Parameters:
-
data_path
(str
) –Data path, default to
None
; generally passed as the only positional argument when this object is called. -
batch_size
(int
) –Batch size, default to
64
. -
micro_batch_size
(int
) –Micro-batch size, default to
4
. -
num_epochs
(int
) –Number of training epochs, default to
2
. -
learning_rate
(float
) –Learning rate, default to
5.e-4
. -
dp_size
(int
) –Data parallelism parameter, default to
8
. -
pp_size
(int
) –Pipeline parallelism parameter, default to
1
. -
tp_size
(int
) –Tensor parallelism parameter, default to
1
. -
lora_r
(int
) –LoRA rank, default to
8
; this value determines the amount of parameters added, the smaller the value, the fewer the parameters. -
lora_alpha
(int
) –LoRA fusion factor, default to
32
; this value determines the impact of LoRA parameters on the base model parameters, the larger the value, the greater the impact. -
lora_dropout
(float
) –LoRA dropout rate, default to
0.05
, generally used to prevent overfitting. -
lora_target_modules
(str
) –LoRA target modules, default to
[wo,wqkv]
, which is the default for InternLM2 model; this configuration item varies for different models. -
modules_to_save
(str
) –Modules for full fine-tuning, default to
[tok_embeddings,output]
, which is the default for InternLM2 model; this configuration item varies for different models. -
prompt_template_name
(str
) –The name of the prompt template, default to
alpaca
, i.e., use the prompt template provided by LazyLLM by default.
Examples:
>>> from lazyllm import finetune
>>> trainer = finetune.collie('path/to/base/model', 'path/to/target')
Source code in lazyllm/components/finetune/collie.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
lazyllm.components.finetune.LlamafactoryFinetune
Bases: LazyLLMFinetuneBase
This class is a subclass of LazyLLMFinetuneBase
, based on the training capabilities provided by the LLaMA-Factory framework, used for training large language models(or visual language models).
Parameters:
-
base_model
(str
) –The base model used for training. It is required to be the path of the base model.
-
target_path
(str
) –The path where the trained model weights are saved.
-
merge_path
(str
, default:None
) –The path where the model is merged with LoRA weights, default is None. If not specified, "lazyllm_lora" and "lazyllm_merge" directories will be created under
target_path
, to be used astarget_path
andmerge_path
respectively. -
config_path
(str
, default:None
) –The LLaMA-Factory training configuration file (yaml format is required), default is None. If not specified, a
.temp
folder will be created in the current working directory, and a configuration file starting withtrain_
and ending with.yaml
will be generated inside it. -
export_config_path
(str
, default:None
) –The LLaMA-Factory Lora weight merging configuration file (yaml format is required), default is None. If not specified, a configuration file starting with
merge_
and ending with.yaml
will be generated inside the.temp
folder in the current working directory. -
launcher
(launcher
, default:remote(ngpus=1, sync=True)
) –The launcher for fine-tuning, default is
launchers.remote(ngpus=1, sync=True)
. -
kw
–Keyword arguments used to update the default training parameters.
Other Parameters:
-
stage
(Literal['pt', 'sft', 'rm', 'ppo', 'dpo', 'kto']
) –Default is:
sft
. Which stage will be performed in training. -
do_train
(bool
) –Default is:
True
. Whether to run training. -
finetuning_type
(Literal['lora', 'freeze', 'full']
) –Default is:
lora
. Which fine-tuning method to use. -
lora_target
(str
) –Default is:
all
. Name(s) of target modules to apply LoRA. Use commas to separate multiple modules. Useall
to specify all the linear modules. -
template
(Optional[str]
) –Default is:
None
. Which template to use for constructing prompts in training and inference. -
cutoff_len
(int
) –Default is:
1024
. The cutoff length of the tokenized inputs in the dataset. -
max_samples
(Optional[int]
) –Default is:
1000
. For debugging purposes, truncate the number of examples for each dataset. -
overwrite_cache
(bool
) –Default is:
True
. Overwrite the cached training and evaluation sets. -
preprocessing_num_workers
(Optional[int]
) –Default is:
16
. The number of processes to use for the pre-processing. -
dataset_dir
(str
) –Default is:
lazyllm_temp_dir
. Path to the folder containing the datasets. If not explicitly specified, LazyLLM will generate adataset_info.json
file in the.temp
folder in the current working directory for use by LLaMA-Factory. -
logging_steps
(float
) –Default is:
10
. Log every X updates steps. Should be an integer or a float in range[0,1)
. If smaller than 1, will be interpreted as ratio of total training steps. -
save_steps
(float
) –Default is:
500
. Save checkpoint every X updates steps. Should be an integer or a float in range[0,1)
. If smaller than 1, will be interpreted as ratio of total training steps. -
plot_loss
(bool
) –Default is:
True
. Whether or not to save the training loss curves. -
overwrite_output_dir
(bool
) –Default is:
True
. Overwrite the content of the output directory. -
per_device_train_batch_size
(int
) –Default is:
1
. Batch size per GPU/TPU/MPS/NPU core/CPU for training. -
gradient_accumulation_steps
(int
) –Default is:
8
. Number of updates steps to accumulate before performing a backward/update pass. -
learning_rate
(float
) –Default is:
1e-04
. The initial learning rate for AdamW. -
num_train_epochs
(float
) –Default is:
3.0
. Total number of training epochs to perform. -
lr_scheduler_type
(Union[SchedulerType, str]
) –Default is:
cosine
. The scheduler type to use. -
warmup_ratio
(float
) –Default is:
0.1
. Linear warmup over warmup_ratio fraction of total steps. -
fp16
(bool
) –Default is:
True
. Whether to use fp16 (mixed) precision instead of 32-bit. -
ddp_timeout
(Optional[int]
) –Default is:
180000000
. Overrides the default timeout for distributed training (value should be given in seconds). -
report_to
(Union[NoneType, str, List[str]]
) –Default is:
tensorboard
. The list of integrations to report the results and logs to. -
val_size
(float
) –Default is:
0.1
. Size of the development set, should be an integer or a float in range[0,1)
. -
per_device_eval_batch_size
(int
) –Default is:
1
. Batch size per GPU/TPU/MPS/NPU core/CPU for evaluation. -
eval_strategy
(Union[IntervalStrategy, str]
) –Default is:
steps
. The evaluation strategy to use. -
eval_steps
(Optional[float]
) –Default is:
500
. Run an evaluation every X steps. Should be an integer or a float in range[0,1)
. If smaller than 1, will be interpreted as ratio of total training steps.
Examples:
>>> from lazyllm import finetune
>>> trainer = finetune.llamafactory('internlm2-chat-7b', 'path/to/target')
<lazyllm.llm.finetune type=LlamafactoryFinetune>
Source code in lazyllm/components/finetune/llamafactory.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
lazyllm.components.auto.AutoFinetune
Bases: LazyLLMFinetuneBase
This class is a subclass of LazyLLMFinetuneBase
and can automatically select the appropriate fine-tuning framework and parameters based on the input arguments to fine-tune large language models.
Specifically, based on the input model parameters of base_model
, ctx_len
, batch_size
, lora_r
, the type and number of GPUs in launcher
, this class can automatically select the appropriate fine-tuning framework (such as: AlpacaloraFinetune
or CollieFinetune
) and the required parameters.
Parameters:
-
base_model
(str
) –The base model used for fine-tuning. It is required to be the path of the base model.
-
source
(config[model_source]
) –Specifies the model download source. This can be configured by setting the environment variable
LAZYLLM_MODEL_SOURCE
. -
target_path
(str
) –The path where the LoRA weights of the fine-tuned model are saved.
-
merge_path
(str
) –The path where the model merges the LoRA weights, default to
None
. If not specified, "lazyllm_lora" and "lazyllm_merge" directories will be created undertarget_path
astarget_path
andmerge_path
respectively. -
ctx_len
(int
) –The maximum token length for input to the fine-tuned model, default to
1024
. -
batch_size
(int
) –Batch size, default to
32
. -
lora_r
(int
) –LoRA rank, default to
8
; this value determines the amount of parameters added, the smaller the value, the fewer the parameters. -
launcher
(launcher
, default:remote()
) –The launcher for fine-tuning, default to
launchers.remote(ngpus=1)
. -
kw
–Keyword arguments, used to update the default training parameters. Note that additional keyword arguments cannot be arbitrarily specified, as they depend on the framework inferred by LazyLLM, so it is recommended to set them with caution.
Examples:
>>> from lazyllm import finetune
>>> finetune.auto("internlm2-chat-7b", 'path/to/target')
<lazyllm.llm.finetune type=AlpacaloraFinetune>
Source code in lazyllm/components/auto/autofinetune.py
Deploy
lazyllm.components.deploy.Lightllm
Bases: LazyLLMDeployBase
This class is a subclass of LazyLLMDeployBase
, based on the inference capabilities provided by the LightLLM framework, used for inference with large language models.
Parameters:
-
trust_remote_code
(bool
, default:True
) –Whether to allow loading of model code from remote servers, default is
True
. -
launcher
(launcher
, default:remote(ngpus=1)
) –The launcher for fine-tuning, default is
launchers.remote(ngpus=1)
. -
stream
(bool
, default:False
) –Whether the response is streaming, default is
False
. -
kw
–Keyword arguments used to update default training parameters. Note that not any additional keyword arguments can be specified here.
The keyword arguments and their default values for this class are as follows:
Other Parameters:
-
tp
(int
) –Tensor parallelism parameter, default is
1
. -
max_total_token_num
(int
) –Maximum total token number, default is
64000
. -
eos_id
(int
) –End-of-sentence ID, default is
2
. -
port
(int
) –Service port number, default is
None
, in which case LazyLLM will automatically generate a random port number. -
host
(str
) –Service IP address, default is
0.0.0.0
. -
nccl_port
(int
) –NCCL port, default is
None
, in which case LazyLLM will automatically generate a random port number. -
tokenizer_mode
(str
) –Tokenizer loading mode, default is
auto
. -
running_max_req_size
(int
) –Maximum number of parallel requests for the inference engine, default is
256
.
Examples:
Source code in lazyllm/components/deploy/lightllm.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
lazyllm.components.deploy.Vllm
Bases: LazyLLMDeployBase
This class is a subclass of LazyLLMDeployBase
, based on the inference capabilities provided by the VLLM framework, used for inference with large language models.
Parameters:
-
trust_remote_code
(bool
, default:True
) –Whether to allow loading of model code from remote servers, default is
True
. -
launcher
(launcher
, default:remote(ngpus=1)
) –The launcher for fine-tuning, default is
launchers.remote(ngpus=1)
. -
stream
(bool
, default:False
) –Whether the response is streaming, default is
False
. -
kw
–Keyword arguments used to update default training parameters. Note that not any additional keyword arguments can be specified here.
The keyword arguments and their default values for this class are as follows:
Other Parameters:
-
tensor-parallel-size
(int
) –Tensor parallelism parameter, default is
1
. -
dtype
(str
) –Data type for model weights and activations, default is
auto
. Other options include:half
,float16
,bfloat16
,float
,float32
. -
kv-cache-dtype
(str
) –Data type for the key-value cache storage, default is
auto
. Other options include:fp8
,fp8_e5m2
,fp8_e4m3
. -
device
(str
) –Backend hardware type supported by VLLM, default is
auto
. Other options include:cuda
,neuron
,cpu
. -
block-size
(int
) –Sets the size of the token block, default is
16
. -
port
(int
) –Service port number, default is
auto
. -
host
(str
) –Service IP address, default is
0.0.0.0
. -
seed
(int
) –Random number seed, default is
0
. -
tokenizer_mode
(str
) –Tokenizer loading mode, default is
auto
. -
max-num-seqs
(int
) –Maximum number of parallel requests for the inference engine, default is
256
.
Examples:
Source code in lazyllm/components/deploy/vllm.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
lazyllm.components.deploy.LMDeploy
Bases: LazyLLMDeployBase
This class is a subclass of LazyLLMDeployBase
, leveraging the inference capabilities provided by the LMDeploy framework for inference on large language models.
Parameters:
-
launcher
(launcher
, default:remote(ngpus=1)
) –The launcher for fine-tuning, defaults to
launchers.remote(ngpus=1)
. -
stream
(bool
, default:False
) –Whether to enable streaming response, defaults to
False
. -
kw
–Keyword arguments for updating default training parameters. Note that no additional keyword arguments beyond those listed below can be passed.
Other Parameters:
-
tp
(int
) –Tensor parallelism parameter, defaults to
1
. -
server_name
(str
) –The IP address of the service, defaults to
0.0.0.0
. -
server_port
(int
) –The port number of the service, defaults to
None
. In this case, LazyLLM will automatically generate a random port number. -
max_batch_size
(int
) –Maximum batch size, defaults to
128
.
Examples:
>>> # Basic use:
>>> from lazyllm import deploy
>>> infer = deploy.LMDeploy()
>>>
>>> # MultiModal:
>>> import lazyllm
>>> from lazyllm import deploy, globals
>>> from lazyllm.components.formatter import encode_query_with_filepaths
>>> chat = lazyllm.TrainableModule('Mini-InternVL-Chat-2B-V1-5').deploy_method(deploy.LMDeploy)
>>> chat.update_server()
>>> inputs = encode_query_with_filepaths('What is it?', ['path/to/image'])
>>> res = chat(inputs)
Source code in lazyllm/components/deploy/lmdeploy.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
lazyllm.components.auto.AutoDeploy
Bases: LazyLLMDeployBase
This class is a subclass of LazyLLMDeployBase
that automatically selects the appropriate inference framework and parameters based on the input arguments for inference with large language models.
Specifically, based on the input base_model
parameters, max_token_num
, the type and number of GPUs in launcher
, this class can automatically select the appropriate inference framework (such as Lightllm
or Vllm
) and the required parameters.
Parameters:
-
base_model
(str
) –The base model for fine-tuning, which is required to be the name or the path to the base model. Used to provide base model information.
-
source
(config[model_source]
) –Specifies the model download source. This can be configured by setting the environment variable
LAZYLLM_MODEL_SOURCE
. -
trust_remote_code
(bool
) –Whether to allow loading of model code from remote servers, default is
True
. -
launcher
(launcher
, default:remote()
) –The launcher for fine-tuning, default is
launchers.remote(ngpus=1)
. -
stream
(bool
) –Whether the response is streaming, default is
False
. -
type
(str
) –Type parameter, default is
None
, which corresponds to thellm
type. Additionally, theembed
type is also supported. -
max_token_num
(int
) –The maximum token length for the input fine-tuning model, default is
1024
. -
launcher
(launcher
, default:remote()
) –The launcher for fine-tuning, default is
launchers.remote(ngpus=1)
. -
kw
–Keyword arguments used to update default training parameters. Note that whether additional keyword arguments can be specified depends on the framework inferred by LazyLLM, so it is recommended to set them carefully.
Examples:
>>> from lazyllm import deploy
>>> deploy.auto('internlm2-chat-7b')
<lazyllm.llm.deploy type=Lightllm>
Source code in lazyllm/components/auto/autodeploy.py
Launcher
lazyllm.launcher.EmptyLauncher
Bases: LazyLLMLaunchersBase
This class is a subclass of LazyLLMLaunchersBase
and serves as a local launcher.
Parameters:
-
subprocess
(bool
, default:False
) –Whether to use a subprocess to launch. Default is
False
. -
sync
(bool
, default:True
) –Whether to execute jobs synchronously. Default is
True
, otherwise it executes asynchronously.
Examples:
Source code in lazyllm/launcher.py
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 |
|
lazyllm.launcher.RemoteLauncher
Bases: LazyLLMLaunchersBase
This class is a subclass of LazyLLMLaunchersBase
and acts as a proxy for a remote launcher. It dynamically creates and returns an instance of the corresponding launcher based on the lazyllm.config['launcher']
entry in the configuration file (for example: SlurmLauncher
or ScoLauncher
).
Parameters:
-
*args
–Positional arguments that will be passed to the constructor of the dynamically created launcher.
-
sync
(bool
) –Whether to execute the job synchronously. Defaults to
False
. -
**kwargs
–Keyword arguments that will be passed to the constructor of the dynamically created launcher.
Notes
RemoteLauncher
is not a direct launcher but dynamically creates a launcher based on the configuration.- The
lazyllm.config['launcher']
in the configuration file specifies a launcher class name present in thelazyllm.launchers
module. This configuration can be set by setting the environment variableLAZYLLM_DEAULT_LAUNCHER
. For example:export LAZYLLM_DEAULT_LAUNCHER=sco
,export LAZYLLM_DEAULT_LAUNCHER=slurm
.
Examples:
Source code in lazyllm/launcher.py
lazyllm.launcher.SlurmLauncher
Bases: LazyLLMLaunchersBase
This class is a subclass of LazyLLMLaunchersBase
and acts as a Slurm launcher.
Specifically, it provides methods to start and configure Slurm jobs, including specifying parameters such as the partition, number of nodes, number of processes, number of GPUs, and timeout settings.
Parameters:
-
partition
(str
, default:None
) –The Slurm partition to use. Defaults to
None
, in which case the default partition inlazyllm.config['partition']
will be used. This configuration can be enabled by setting environment variables, such asexport LAZYLLM_SLURM_PART=a100
. -
nnode
((int
, default:1
) –The number of nodes to use. Defaults to
1
. -
nproc
(int
, default:1
) –The number of processes per node. Defaults to
1
. -
ngpus
(int
, default:None
) –The number of GPUs per node. Defaults to
None
, meaning no GPUs will be used. -
timeout
(int
, default:None
) –The timeout for the job in seconds. Defaults to
None
, in which case no timeout will be set. -
sync
(bool
, default:True
) –Whether to execute the job synchronously. Defaults to
True
, otherwise it will be executed asynchronously.
Examples:
>>> import lazyllm
>>> launcher = lazyllm.launchers.slurm(partition='partition_name', nnode=1, nproc=1, ngpus=1, sync=False)
Source code in lazyllm/launcher.py
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 |
|
lazyllm.launcher.ScoLauncher
Bases: LazyLLMLaunchersBase
This class is a subclass of LazyLLMLaunchersBase
and acts as a SCO launcher.
Specifically, it provides methods to start and configure SCO jobs, including specifying parameters such as the partition, workspace name, framework type, number of nodes, number of processes, number of GPUs, and whether to use torchrun or not.
Parameters:
-
partition
(str
, default:None
) –The Slurm partition to use. Defaults to
None
, in which case the default partition inlazyllm.config['partition']
will be used. This configuration can be enabled by setting environment variables, such asexport LAZYLLM_SLURM_PART=a100
. -
workspace_name
(str
, default:config['sco.workspace']
) –The workspace name on SCO. Defaults to the configuration in
lazyllm.config['sco.workspace']
. This configuration can be enabled by setting environment variables, such asexport LAZYLLM_SCO_WORKSPACE=myspace
. -
framework
(str
, default:'pt'
) –The framework type to use, for example,
pt
for PyTorch. Defaults topt
. -
nnode
((int
, default:1
) –The number of nodes to use. Defaults to
1
. -
nproc
(int
, default:1
) –The number of processes per node. Defaults to
1
. -
ngpus
(int
, default:1
) –The number of GPUs per node. Defaults to
1
, using 1 GPU. -
torchrun
(bool
, default:False
) –Whether to start the job with
torchrun
. Defaults toFalse
. -
sync
(bool
, default:True
) –Whether to execute the job synchronously. Defaults to
True
, otherwise it will be executed asynchronously.
Examples:
>>> import lazyllm
>>> launcher = lazyllm.launchers.sco(partition='partition_name', nnode=1, nproc=1, ngpus=1, sync=False)
Source code in lazyllm/launcher.py
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 |
|
Prompter
lazyllm.components.prompter.LazyLLMPrompterBase
The base class of Prompter. A custom Prompter needs to inherit from this base class and set the Prompt template and the Instruction template using the _init_prompt
function provided by the base class, as well as the string used to capture results. Refer to prompt for further understanding of the design philosophy and usage of Prompts.
Both the Prompt template and the Instruction template use {}
to indicate the fields to be filled in. The fields that can be included in the Prompt are system
, history
, tools
, user
etc., while the fields that can be included in the instruction_template are instruction
and extro_keys
. If the instruction
field is a string, it is considered as a system instruction; if it is a dictionary, it can only contain the keys user
and system
. user
represents the user input instruction, which is placed before the user input in the prompt, and system
represents the system instruction, which is placed after the system prompt in the prompt.
instruction
is passed in by the application developer, and the instruction
can also contain {}
to define fillable fields, making it convenient for users to input additional information.
Examples:
>>> from lazyllm.components.prompter import PrompterBase
>>> class MyPrompter(PrompterBase):
... def __init__(self, instruction = None, extro_keys = None, show = False):
... super(__class__, self).__init__(show)
... instruction_template = f'{instruction}\n{{extro_keys}}\n'.replace('{extro_keys}', PrompterBase._get_extro_key_template(extro_keys))
... self._init_prompt("<system>{system}</system>\n</instruction>{instruction}</instruction>{history}\n{input}\n, ## Response::", instruction_template, '## Response::')
...
>>> p = MyPrompter('ins {instruction}')
>>> p.generate_prompt('hello')
'<system>You are an AI-Agent developed by LazyLLM.</system>\n</instruction>ins hello\n\n</instruction>\n\n, ## Response::'
>>> p.generate_prompt('hello world', return_dict=True)
{'messages': [{'role': 'system', 'content': 'You are an AI-Agent developed by LazyLLM.\nins hello world\n\n'}, {'role': 'user', 'content': ''}]}
Source code in lazyllm/components/prompter/builtinPrompt.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
generate_prompt(input=None, history=None, tools=None, label=None, *, show=False, return_dict=False)
Generate a corresponding Prompt based on user input.
Parameters:
-
input
(Option[str | Dict]
, default:None
) –The input from the prompter, if it's a dict, it will be filled into the slots of the instruction; if it's a str, it will be used as input.
-
history
(Option[List[List | Dict]]
, default:None
) –Historical conversation, can be
[[u, s], [u, s]]
or in openai's history format, defaults to None. -
tools
(Option[List[Dict]]
, default:None
) –A collection of tools that can be used, used when the large model performs FunctionCall, defaults to None.
-
label
(Option[str]
, default:None
) –Label, used during fine-tuning or training, defaults to None.
-
show
(bool
, default:False
) –Flag indicating whether to print the generated Prompt, defaults to False.
-
return_dict
(bool
, default:False
) –Flag indicating whether to return a dict, generally set to True when using
OnlineChatModule
. If returning a dict, only theinstruction
will be filled. Defaults to False.
Source code in lazyllm/components/prompter/builtinPrompt.py
get_response(output, input=None)
Used to truncate the Prompt, keeping only valuable output.
Parameters:
-
output
(str
) –The output of the large model.
-
input
(Option[str]
, default:None
) –The input of the large model. If this parameter is specified, any part of the output that includes the input will be completely truncated. Defaults to None.
Source code in lazyllm/components/prompter/builtinPrompt.py
lazyllm.components.AlpacaPrompter
Bases: LazyLLMPrompterBase
Alpaca-style Prompter, supports tool calls, does not support historical dialogue.
Parameters:
-
instruction
(Option[str]
, default:None
) –Task instructions for the large model, with at least one fillable slot (e.g.
{instruction}
). Or use a dictionary to specify thesystem
anduser
instructions. -
extro_keys
(Option[List]
, default:None
) –Additional fields that will be filled with user input.
-
show
(bool
, default:False
) –Flag indicating whether to print the generated Prompt, default is False.
-
tools
(Option[list]
, default:None
) –Tool-set which is provived for LLMs, default is None.
Examples:
>>> from lazyllm import AlpacaPrompter
>>> p = AlpacaPrompter('hello world {instruction}')
>>> p.generate_prompt('this is my input')
'You are an AI-Agent developed by LazyLLM.\nBelow is an instruction that describes a task, paired with extra messages such as input that provides further context if possible. Write a response that appropriately completes the request.\n\n ### Instruction:\nhello world this is my input\n\n\n### Response:\n'
>>> p.generate_prompt('this is my input', return_dict=True)
{'messages': [{'role': 'system', 'content': 'You are an AI-Agent developed by LazyLLM.\nBelow is an instruction that describes a task, paired with extra messages such as input that provides further context if possible. Write a response that appropriately completes the request.\n\n ### Instruction:\nhello world this is my input\n\n'}, {'role': 'user', 'content': ''}]}
>>>
>>> p = AlpacaPrompter('hello world {instruction}, {input}', extro_keys=['knowledge'])
>>> p.generate_prompt(dict(instruction='hello world', input='my input', knowledge='lazyllm'))
'You are an AI-Agent developed by LazyLLM.\nBelow is an instruction that describes a task, paired with extra messages such as input that provides further context if possible. Write a response that appropriately completes the request.\n\n ### Instruction:\nhello world hello world, my input\n\nHere are some extra messages you can referred to:\n\n### knowledge:\nlazyllm\n\n\n### Response:\n'
>>> p.generate_prompt(dict(instruction='hello world', input='my input', knowledge='lazyllm'), return_dict=True)
{'messages': [{'role': 'system', 'content': 'You are an AI-Agent developed by LazyLLM.\nBelow is an instruction that describes a task, paired with extra messages such as input that provides further context if possible. Write a response that appropriately completes the request.\n\n ### Instruction:\nhello world hello world, my input\n\nHere are some extra messages you can referred to:\n\n### knowledge:\nlazyllm\n\n'}, {'role': 'user', 'content': ''}]}
>>>
>>> p = AlpacaPrompter(dict(system="hello world", user="this is user instruction {input}"))
>>> p.generate_prompt(dict(input="my input"))
'You are an AI-Agent developed by LazyLLM.\nBelow is an instruction that describes a task, paired with extra messages such as input that provides further context if possible. Write a response that appropriately completes the request.\n\n ### Instruction:\nhello word\n\n\n\nthis is user instruction my input### Response:\n'
>>> p.generate_prompt(dict(input="my input"), return_dict=True)
{'messages': [{'role': 'system', 'content': 'You are an AI-Agent developed by LazyLLM.\nBelow is an instruction that describes a task, paired with extra messages such as input that provides further context if possible. Write a response that appropriately completes the request.\n\n ### Instruction:\nhello world'}, {'role': 'user', 'content': 'this is user instruction my input'}]}
Source code in lazyllm/components/prompter/alpacaPrompter.py
generate_prompt(input=None, history=None, tools=None, label=None, *, show=False, return_dict=False)
Generate a corresponding Prompt based on user input.
Parameters:
-
input
(Option[str | Dict]
, default:None
) –The input from the prompter, if it's a dict, it will be filled into the slots of the instruction; if it's a str, it will be used as input.
-
history
(Option[List[List | Dict]]
, default:None
) –Historical conversation, can be
[[u, s], [u, s]]
or in openai's history format, defaults to None. -
tools
(Option[List[Dict]]
, default:None
) –A collection of tools that can be used, used when the large model performs FunctionCall, defaults to None.
-
label
(Option[str]
, default:None
) –Label, used during fine-tuning or training, defaults to None.
-
show
(bool
, default:False
) –Flag indicating whether to print the generated Prompt, defaults to False.
-
return_dict
(bool
, default:False
) –Flag indicating whether to return a dict, generally set to True when using
OnlineChatModule
. If returning a dict, only theinstruction
will be filled. Defaults to False.
Source code in lazyllm/components/prompter/builtinPrompt.py
get_response(output, input=None)
Used to truncate the Prompt, keeping only valuable output.
Parameters:
-
output
(str
) –The output of the large model.
-
input
(Option[str]
, default:None
) –The input of the large model. If this parameter is specified, any part of the output that includes the input will be completely truncated. Defaults to None.
Source code in lazyllm/components/prompter/builtinPrompt.py
lazyllm.components.ChatPrompter
Bases: LazyLLMPrompterBase
chat prompt, supports tool calls and historical dialogue.
Parameters:
-
instruction
(Option[str]
, default:None
) –Task instructions for the large model, with 0 to multiple fillable slot, represented by
{}
. For user instructions, you can pass a dictionary with fieldsuser
andsystem
. -
extro_keys
(Option[List]
, default:None
) –Additional fields that will be filled with user input.
-
show
(bool
, default:False
) –Flag indicating whether to print the generated Prompt, default is False.
Examples:
>>> from lazyllm import ChatPrompter
>>> p = ChatPrompter('hello world')
>>> p.generate_prompt('this is my input')
'You are an AI-Agent developed by LazyLLM.hello world\n\n\n\n\n\nthis is my input\n\n'
>>> p.generate_prompt('this is my input', return_dict=True)
{'messages': [{'role': 'system', 'content': 'You are an AI-Agent developed by LazyLLM.\nhello world\n\n'}, {'role': 'user', 'content': 'this is my input'}]}
>>>
>>> p = ChatPrompter('hello world {instruction}', extro_keys=['knowledge'])
>>> p.generate_prompt(dict(instruction='this is my ins', input='this is my inp', knowledge='LazyLLM-Knowledge'))
'You are an AI-Agent developed by LazyLLM.hello world this is my ins\nHere are some extra messages you can referred to:\n\n### knowledge:\nLazyLLM-Knowledge\n\n\n\n\n\n\nthis is my inp\n\n'
>>> p.generate_prompt(dict(instruction='this is my ins', input='this is my inp', knowledge='LazyLLM-Knowledge'), return_dict=True)
{'messages': [{'role': 'system', 'content': 'You are an AI-Agent developed by LazyLLM.\nhello world this is my ins\nHere are some extra messages you can referred to:\n\n### knowledge:\nLazyLLM-Knowledge\n\n\n'}, {'role': 'user', 'content': 'this is my inp'}]}
>>> p.generate_prompt(dict(instruction='this is my ins', input='this is my inp', knowledge='LazyLLM-Knowledge'), history=[['s1', 'e1'], ['s2', 'e2']])
'You are an AI-Agent developed by LazyLLM.hello world this is my ins\nHere are some extra messages you can referred to:\n\n### knowledge:\nLazyLLM-Knowledge\n\n\n\n\ns1e1s2e2\n\nthis is my inp\n\n'
>>>
>>> p = ChatPrompter(dict(system="hello world", user="this is user instruction {input} "))
>>> p.generate_prompt(dict(input="my input", query="this is user query"))
'You are an AI-Agent developed by LazyLLM.hello world\n\n\n\nthis is user instruction my input this is user query\n\n'
>>> p.generate_prompt(dict(input="my input", query="this is user query"), return_dict=True)
{'messages': [{'role': 'system', 'content': 'You are an AI-Agent developed by LazyLLM.\nhello world'}, {'role': 'user', 'content': 'this is user instruction my input this is user query'}]}
Source code in lazyllm/components/prompter/chatPrompter.py
generate_prompt(input=None, history=None, tools=None, label=None, *, show=False, return_dict=False)
Generate a corresponding Prompt based on user input.
Parameters:
-
input
(Option[str | Dict]
, default:None
) –The input from the prompter, if it's a dict, it will be filled into the slots of the instruction; if it's a str, it will be used as input.
-
history
(Option[List[List | Dict]]
, default:None
) –Historical conversation, can be
[[u, s], [u, s]]
or in openai's history format, defaults to None. -
tools
(Option[List[Dict]]
, default:None
) –A collection of tools that can be used, used when the large model performs FunctionCall, defaults to None.
-
label
(Option[str]
, default:None
) –Label, used during fine-tuning or training, defaults to None.
-
show
(bool
, default:False
) –Flag indicating whether to print the generated Prompt, defaults to False.
-
return_dict
(bool
, default:False
) –Flag indicating whether to return a dict, generally set to True when using
OnlineChatModule
. If returning a dict, only theinstruction
will be filled. Defaults to False.
Source code in lazyllm/components/prompter/builtinPrompt.py
get_response(output, input=None)
Used to truncate the Prompt, keeping only valuable output.
Parameters:
-
output
(str
) –The output of the large model.
-
input
(Option[str]
, default:None
) –The input of the large model. If this parameter is specified, any part of the output that includes the input will be completely truncated. Defaults to None.
Source code in lazyllm/components/prompter/builtinPrompt.py
Register
lazyllm.common.Register
Bases: object
LazyLLM provides a registration mechanism for Components, allowing any function to be registered as a Component of LazyLLM. The registered functions can be indexed at any location through the grouping mechanism provided by the registrar, without the need for explicit import.
lazyllm.components.register(cls, *, rewrite_func)→ Decorator
After the function is called, it returns a decorator which wraps the decorated function into a Component and registers it in a group named cls.
Parameters:
-
cls
(str)
) –The name of the group to which the function will be registered. The group must exist. Default groups include
finetune
anddeploy
. Users can create new groups by calling thenew_group
function. -
rewrite_func
(str)
) –The name of the function to be rewritten after registration. Default is
apply
. When registering a bash command, you need to passcmd
as the argument.
Examples:
>>> import lazyllm
>>> @lazyllm.component_register('mygroup')
... def myfunc(input):
... return input
...
>>> lazyllm.mygroup.myfunc()(1)
1
register.cmd(cls)→ Decorator
After the function is called, it returns a decorator that wraps the decorated function into a Component and registers it in a group named cls. The wrapped function needs to return an executable bash command.
Parameters:
-
cls
(str)
) –The name of the group to which the function will be registered. The group must exist. Default groups include
finetune
anddeploy
. Users can create new groups by calling thenew_group
function.
Examples:
>>> import lazyllm
>>> @lazyllm.component_register.cmd('mygroup')
... def mycmdfunc(input):
... return f'echo {input}'
...
>>> lazyllm.mygroup.mycmdfunc()(1)
PID: 2024-06-01 00:00:00 lazyllm INFO: (lazyllm.launcher) Command: echo 1
PID: 2024-06-01 00:00:00 lazyllm INFO: (lazyllm.launcher) PID: 1
Source code in lazyllm/common/registry.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
new_group(group_name)
Creates a new ComponentGroup. The newly created group will be automatically added to builtin and can be accessed at any location without the need for import.
Parameters:
-
group_name
(str
) –The name of the group to be created.
Source code in lazyllm/common/registry.py
ModelManager
lazyllm.components.ModelManager
ModelManager is a utility class provided by LazyLLM for developers to automatically download models. Currently, it supports search for models from local directories, as well as automatically downloading model from huggingface or modelscope. Before using ModelManager, the following environment variables need to be set:
- LAZYLLM_MODEL_SOURCE: The source for model downloads, which can be set to
huggingface
ormodelscope
. - LAZYLLM_MODEL_SOURCE_TOKEN: The token provided by
huggingface
ormodelscope
for private model download. - LAZYLLM_MODEL_PATH: A colon-separated
:
list of local absolute paths for model search. - LAZYLLM_MODEL_CACHE_DIR: Directory for downloaded models.
Other Parameters:
-
model_source
(str
) –The source for model downloads, currently only supports
huggingface
ormodelscope
. If necessary, ModelManager downloads model data from the source. If not provided, LAZYLLM_MODEL_SOURCE environment variable would be used, and if LAZYLLM_MODEL_SOURCE is not set, ModelManager will not download any model. -
token
(str
) –The token provided by
huggingface
ormodelscope
. If the token is present, ModelManager uses the token to download model. If not provided, LAZYLLM_MODEL_SOURCE_TOKEN environment variable would be used. and if LAZYLLM_MODEL_SOURCE_TOKEN is not set, ModelManager will not download private models, only public ones. -
model_path
(str
) –A colon-separated list of absolute paths. Before actually start to download model, ModelManager trys to find the target model in the directories in this list. If not provided, LAZYLLM_MODEL_PATH environment variable would be used, and LAZYLLM_MODEL_PATH is not set, ModelManager skips looking for models from model_path.
-
cache_dir
(str
) –An absolute path of a directory to save downloaded models. If not provided, LAZYLLM_MODEL_CACHE_DIR environment variable would be used, and if LAZYLLM_MODEL_PATH is not set, the default value is ~/.lazyllm/model.
ModelManager.download(model) -> str
Download models from model_source. The function first searches for the target model in directories listed in the model_path parameter of ModelManager class. If not found, it searches under cache_dir. If still not found, it downloads the model from model_source and stores it under cache_dir.
Parameters:
-
model
(str
) –The name of the target model. The function uses this name to download the model from model_source.
Examples:
>>> from lazyllm.components import ModelManager
>>> downloader = ModelManager(model_source='modelscope')
>>> downloader.download('chatglm3-6b')
Source code in lazyllm/components/utils/downloader/model_downloader.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
Formatter
lazyllm.components.formatter.LazyLLMFormatterBase
This class is the base class of the formatter. The formatter is the formatter of the model output result. Users can customize the formatter or use the formatter provided by LazyLLM. Main methods: _parse_formatter: parse the index content. _load: Parse the str object, and the part containing Python objects is parsed out, such as list, dict and other objects. _parse_py_data_by_formatter: format the python object according to the custom formatter and index. format: format the passed content. If the content is a string type, convert the string into a python object first, and then format it. If the content is a python object, format it directly.
Examples:
>>> from lazyllm.components.formatter import FormatterBase
>>> class MyFormatter(FormatterBase):
... def __init__(self, formatter: str = None):
... self._formatter = formatter
... if self._formatter:
... self._parse_formatter()
... else:
... self._slices = None
... def _parse_formatter(self):
... slice_str = self._formatter.strip()[1:-1]
... slices = []
... parts = slice_str.split(":")
... start = int(parts[0]) if parts[0] else None
... end = int(parts[1]) if len(parts) > 1 and parts[1] else None
... step = int(parts[2]) if len(parts) > 2 and parts[2] else None
... slices.append(slice(start, end, step))
... self._slices = slices
... def _load(self, data):
... return [int(x) for x in data.strip('[]').split(',')]
... def _parse_py_data_by_formatter(self, data):
... if self._slices is not None:
... result = []
... for s in self._slices:
... if isinstance(s, slice):
... result.extend(data[s])
... else:
... result.append(data[int(s)])
... return result
... else:
... return data
...
>>> fmt = MyFormatter("[1:3]")
>>> res = fmt.format("[1,2,3,4,5]")
>>> print(res)
[2, 3]
Source code in lazyllm/components/formatter/formatterbase.py
lazyllm.components.JsonFormatter
Bases: JsonLikeFormatter
This class is a JSON formatter, that is, the user wants the model to output content is JSON format, and can also select a field in the output content by indexing.
Examples:
>>> import lazyllm
>>> from lazyllm.components import JsonFormatter
>>> toc_prompt='''
... You are now an intelligent assistant. Your task is to understand the user's input and convert the outline into a list of nested dictionaries. Each dictionary contains a `title` and a `describe`, where the `title` should clearly indicate the level using Markdown format, and the `describe` is a description and writing guide for that section.
...
... Please generate the corresponding list of nested dictionaries based on the following user input:
...
... Example output:
... [
... {
... "title": "# Level 1 Title",
... "describe": "Please provide a detailed description of the content under this title, offering background information and core viewpoints."
... },
... {
... "title": "## Level 2 Title",
... "describe": "Please provide a detailed description of the content under this title, giving specific details and examples to support the viewpoints of the Level 1 title."
... },
... {
... "title": "### Level 3 Title",
... "describe": "Please provide a detailed description of the content under this title, deeply analyzing and providing more details and data support."
... }
... ]
... User input is as follows:
... '''
>>> query = "Please help me write an article about the application of artificial intelligence in the medical field."
>>> m = lazyllm.TrainableModule("internlm2-chat-20b").prompt(toc_prompt).start()
>>> ret = m(query, max_new_tokens=2048)
>>> print(f"ret: {ret!r}") # the model output without specifying a formatter
'Based on your user input, here is the corresponding list of nested dictionaries:
[
{
"title": "# Application of Artificial Intelligence in the Medical Field",
"describe": "Please provide a detailed description of the application of artificial intelligence in the medical field, including its benefits, challenges, and future prospects."
},
{
"title": "## AI in Medical Diagnosis",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical diagnosis, including specific examples of AI-based diagnostic tools and their impact on patient outcomes."
},
{
"title": "### AI in Medical Imaging",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical imaging, including the advantages of AI-based image analysis and its applications in various medical specialties."
},
{
"title": "### AI in Drug Discovery and Development",
"describe": "Please provide a detailed description of how artificial intelligence is used in drug discovery and development, including the role of AI in identifying potential drug candidates and streamlining the drug development process."
},
{
"title": "## AI in Medical Research",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical research, including its applications in genomics, epidemiology, and clinical trials."
},
{
"title": "### AI in Genomics and Precision Medicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in genomics and precision medicine, including the role of AI in analyzing large-scale genomic data and tailoring treatments to individual patients."
},
{
"title": "### AI in Epidemiology and Public Health",
"describe": "Please provide a detailed description of how artificial intelligence is used in epidemiology and public health, including its applications in disease surveillance, outbreak prediction, and resource allocation."
},
{
"title": "### AI in Clinical Trials",
"describe": "Please provide a detailed description of how artificial intelligence is used in clinical trials, including its role in patient recruitment, trial design, and data analysis."
},
{
"title": "## AI in Medical Practice",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical practice, including its applications in patient monitoring, personalized medicine, and telemedicine."
},
{
"title": "### AI in Patient Monitoring",
"describe": "Please provide a detailed description of how artificial intelligence is used in patient monitoring, including its role in real-time monitoring of vital signs and early detection of health issues."
},
{
"title": "### AI in Personalized Medicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in personalized medicine, including its role in analyzing patient data to tailor treatments and predict outcomes."
},
{
"title": "### AI in Telemedicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in telemedicine, including its applications in remote consultations, virtual diagnoses, and digital health records."
},
{
"title": "## AI in Medical Ethics and Policy",
"describe": "Please provide a detailed description of the ethical and policy considerations surrounding the use of artificial intelligence in the medical field, including issues related to data privacy, bias, and accountability."
}
]'
>>> m = lazyllm.TrainableModule("internlm2-chat-20b").formatter(JsonFormatter("[:][title]")).prompt(toc_prompt).start()
>>> ret = m(query, max_new_tokens=2048)
>>> print(f"ret: {ret}") # the model output of the specified formaater
['# Application of Artificial Intelligence in the Medical Field', '## AI in Medical Diagnosis', '### AI in Medical Imaging', '### AI in Drug Discovery and Development', '## AI in Medical Research', '### AI in Genomics and Precision Medicine', '### AI in Epidemiology and Public Health', '### AI in Clinical Trials', '## AI in Medical Practice', '### AI in Patient Monitoring', '### AI in Personalized Medicine', '### AI in Telemedicine', '## AI in Medical Ethics and Policy']
Source code in lazyllm/components/formatter/jsonformatter.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
lazyllm.components.EmptyFormatter
Bases: LazyLLMFormatterBase
This type is the system default formatter. When the user does not specify anything or does not want to format the model output, this type is selected. The model output will be in the same format.
Examples:
>>> import lazyllm
>>> from lazyllm.components import EmptyFormatter
>>> toc_prompt='''
... You are now an intelligent assistant. Your task is to understand the user's input and convert the outline into a list of nested dictionaries. Each dictionary contains a `title` and a `describe`, where the `title` should clearly indicate the level using Markdown format, and the `describe` is a description and writing guide for that section.
...
... Please generate the corresponding list of nested dictionaries based on the following user input:
...
... Example output:
... [
... {
... "title": "# Level 1 Title",
... "describe": "Please provide a detailed description of the content under this title, offering background information and core viewpoints."
... },
... {
... "title": "## Level 2 Title",
... "describe": "Please provide a detailed description of the content under this title, giving specific details and examples to support the viewpoints of the Level 1 title."
... },
... {
... "title": "### Level 3 Title",
... "describe": "Please provide a detailed description of the content under this title, deeply analyzing and providing more details and data support."
... }
... ]
... User input is as follows:
... '''
>>> query = "Please help me write an article about the application of artificial intelligence in the medical field."
>>> m = lazyllm.TrainableModule("internlm2-chat-20b").prompt(toc_prompt).start() # the model output without specifying a formatter
>>> ret = m(query, max_new_tokens=2048)
>>> print(f"ret: {ret!r}")
'Based on your user input, here is the corresponding list of nested dictionaries:
[
{
"title": "# Application of Artificial Intelligence in the Medical Field",
"describe": "Please provide a detailed description of the application of artificial intelligence in the medical field, including its benefits, challenges, and future prospects."
},
{
"title": "## AI in Medical Diagnosis",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical diagnosis, including specific examples of AI-based diagnostic tools and their impact on patient outcomes."
},
{
"title": "### AI in Medical Imaging",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical imaging, including the advantages of AI-based image analysis and its applications in various medical specialties."
},
{
"title": "### AI in Drug Discovery and Development",
"describe": "Please provide a detailed description of how artificial intelligence is used in drug discovery and development, including the role of AI in identifying potential drug candidates and streamlining the drug development process."
},
{
"title": "## AI in Medical Research",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical research, including its applications in genomics, epidemiology, and clinical trials."
},
{
"title": "### AI in Genomics and Precision Medicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in genomics and precision medicine, including the role of AI in analyzing large-scale genomic data and tailoring treatments to individual patients."
},
{
"title": "### AI in Epidemiology and Public Health",
"describe": "Please provide a detailed description of how artificial intelligence is used in epidemiology and public health, including its applications in disease surveillance, outbreak prediction, and resource allocation."
},
{
"title": "### AI in Clinical Trials",
"describe": "Please provide a detailed description of how artificial intelligence is used in clinical trials, including its role in patient recruitment, trial design, and data analysis."
},
{
"title": "## AI in Medical Practice",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical practice, including its applications in patient monitoring, personalized medicine, and telemedicine."
},
{
"title": "### AI in Patient Monitoring",
"describe": "Please provide a detailed description of how artificial intelligence is used in patient monitoring, including its role in real-time monitoring of vital signs and early detection of health issues."
},
{
"title": "### AI in Personalized Medicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in personalized medicine, including its role in analyzing patient data to tailor treatments and predict outcomes."
},
{
"title": "### AI in Telemedicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in telemedicine, including its applications in remote consultations, virtual diagnoses, and digital health records."
},
{
"title": "## AI in Medical Ethics and Policy",
"describe": "Please provide a detailed description of the ethical and policy considerations surrounding the use of artificial intelligence in the medical field, including issues related to data privacy, bias, and accountability."
}
]'
>>> m = lazyllm.TrainableModule("internlm2-chat-20b").formatter(EmptyFormatter()).prompt(toc_prompt).start() # the model output of the specified formatter
>>> ret = m(query, max_new_tokens=2048)
>>> print(f"ret: {ret!r}")
'Based on your user input, here is the corresponding list of nested dictionaries:
[
{
"title": "# Application of Artificial Intelligence in the Medical Field",
"describe": "Please provide a detailed description of the application of artificial intelligence in the medical field, including its benefits, challenges, and future prospects."
},
{
"title": "## AI in Medical Diagnosis",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical diagnosis, including specific examples of AI-based diagnostic tools and their impact on patient outcomes."
},
{
"title": "### AI in Medical Imaging",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical imaging, including the advantages of AI-based image analysis and its applications in various medical specialties."
},
{
"title": "### AI in Drug Discovery and Development",
"describe": "Please provide a detailed description of how artificial intelligence is used in drug discovery and development, including the role of AI in identifying potential drug candidates and streamlining the drug development process."
},
{
"title": "## AI in Medical Research",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical research, including its applications in genomics, epidemiology, and clinical trials."
},
{
"title": "### AI in Genomics and Precision Medicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in genomics and precision medicine, including the role of AI in analyzing large-scale genomic data and tailoring treatments to individual patients."
},
{
"title": "### AI in Epidemiology and Public Health",
"describe": "Please provide a detailed description of how artificial intelligence is used in epidemiology and public health, including its applications in disease surveillance, outbreak prediction, and resource allocation."
},
{
"title": "### AI in Clinical Trials",
"describe": "Please provide a detailed description of how artificial intelligence is used in clinical trials, including its role in patient recruitment, trial design, and data analysis."
},
{
"title": "## AI in Medical Practice",
"describe": "Please provide a detailed description of how artificial intelligence is used in medical practice, including its applications in patient monitoring, personalized medicine, and telemedicine."
},
{
"title": "### AI in Patient Monitoring",
"describe": "Please provide a detailed description of how artificial intelligence is used in patient monitoring, including its role in real-time monitoring of vital signs and early detection of health issues."
},
{
"title": "### AI in Personalized Medicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in personalized medicine, including its role in analyzing patient data to tailor treatments and predict outcomes."
},
{
"title": "### AI in Telemedicine",
"describe": "Please provide a detailed description of how artificial intelligence is used in telemedicine, including its applications in remote consultations, virtual diagnoses, and digital health records."
},
{
"title": "## AI in Medical Ethics and Policy",
"describe": "Please provide a detailed description of the ethical and policy considerations surrounding the use of artificial intelligence in the medical field, including issues related to data privacy, bias, and accountability."
}
]'
Source code in lazyllm/components/formatter/formatterbase.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
MultiModal
Text to Image
lazyllm.components.StableDiffusionDeploy
Bases: object
Stable Diffusion Model Deployment Class. This class is used to deploy the stable diffusion model to a specified server for network invocation.
__init__(self, launcher=None)
Constructor, initializes the deployment class.
Parameters:
-
launcher
(launcher
, default:None
) –An instance of the launcher used to start the remote service.
__call__(self, finetuned_model=None, base_model=None)
Deploys the model and returns the remote service address.
Parameters:
-
finetuned_model
(str
) –If provided, this model will be used for deployment; if not provided or the path is invalid,
base_model
will be used. -
base_model
(str
) –The default model, which will be used for deployment if
finetuned_model
is invalid. -
Return
(str
) –The URL address of the remote service.
Notes
- Input for infer:
str
. A description of the image to be generated. - Return of infer: The string encoded from the generated file paths, starting with the encoding flag "
", followed by the serialized dictionary. The key files
in the dictionary stores a list, with elements being the paths of the generated image files. - Supported models: stable-diffusion-3-medium
Examples:
>>> from lazyllm import launchers, UrlModule
>>> from lazyllm.components import StableDiffusionDeploy
>>> deployer = StableDiffusionDeploy(launchers.remote())
>>> url = deployer(base_model='stable-diffusion-3-medium')
>>> model = UrlModule(url=url)
>>> res = model('a tiny cat.')
>>> print(res)
... <lazyllm-query>{"query": "", "files": ["path/to/sd3/image_xxx.png"]}
Source code in lazyllm/components/stable_diffusion/stable_diffusion3.py
Visual Question Answering
Reference LMDeploy, which supports the Visual Question Answering model.
Text to Sound
lazyllm.components.TTSDeploy
TTSDeploy is a factory class for creating instances of different Text-to-Speech (TTS) deployment types based on the specified name.
__new__(cls, name, **kwarg)
The constructor dynamically creates and returns the corresponding deployment instance based on the provided name argument.
Parameters:
-
name
–A string specifying the type of deployment instance to be created.
-
**kwarg
–Keyword arguments to be passed to the constructor of the corresponding deployment instance.
Returns:
-
–
If the name argument is 'bark', an instance of BarkDeploy is returned.
-
–
If the name argument is 'ChatTTS', an instance of ChatTTSDeploy is returned.
-
–
If the name argument starts with 'musicgen', an instance of MusicGenDeploy is returned.
-
–
If the name argument does not match any of the above cases, a RuntimeError exception is raised, indicating the unsupported model.
Examples:
>>> from lazyllm import launchers, UrlModule
>>> from lazyllm.components import TTSDeploy
>>> model_name = 'bark'
>>> deployer = TTSDeploy(model_name, launcher=launchers.remote())
>>> url = deployer(base_model=model_name)
>>> model = UrlModule(url=url)
>>> res = model('Hello World!')
>>> print(res)
... <lazyllm-query>{"query": "", "files": ["path/to/chattts/sound_xxx.wav"]}
Source code in lazyllm/components/text_to_speech/base.py
lazyllm.components.ChatTTSDeploy
Bases: TTSBase
ChatTTS Model Deployment Class. This class is used to deploy the ChatTTS model to a specified server for network invocation.
__init__(self, launcher=None)
Constructor, initializes the deployment class.
Parameters:
-
launcher
(launcher
, default:None
) –An instance of the launcher used to start the remote service.
__call__(self, finetuned_model=None, base_model=None)
Deploys the model and returns the remote service address.
Parameters:
-
finetuned_model
(str
) –If provided, this model will be used for deployment; if not provided or the path is invalid,
base_model
will be used. -
base_model
(str
) –The default model, which will be used for deployment if
finetuned_model
is invalid. -
Return
(str
) –The URL address of the remote service.
Notes
- Input for infer:
str
. The text corresponding to the audio to be generated. - Return of infer: The string encoded from the generated file paths, starting with the encoding flag "
", followed by the serialized dictionary. The key files
in the dictionary stores a list, with elements being the paths of the generated audio files. - Supported models: ChatTTS
Examples:
>>> from lazyllm import launchers, UrlModule
>>> from lazyllm.components import ChatTTSDeploy
>>> deployer = ChatTTSDeploy(launchers.remote())
>>> url = deployer(base_model='ChatTTS')
>>> model = UrlModule(url=url)
>>> res = model('Hello World!')
>>> print(res)
... <lazyllm-query>{"query": "", "files": ["path/to/chattts/sound_xxx.wav"]}
Source code in lazyllm/components/text_to_speech/chattts.py
lazyllm.components.BarkDeploy
Bases: TTSBase
Bark Model Deployment Class. This class is used to deploy the Bark model to a specified server for network invocation.
__init__(self, launcher=None)
Constructor, initializes the deployment class.
Parameters:
-
launcher
(launcher
, default:None
) –An instance of the launcher used to start the remote service.
__call__(self, finetuned_model=None, base_model=None)
Deploys the model and returns the remote service address.
Parameters:
-
finetuned_model
(str
) –If provided, this model will be used for deployment; if not provided or the path is invalid,
base_model
will be used. -
base_model
(str
) –The default model, which will be used for deployment if
finetuned_model
is invalid. -
Return
(str
) –The URL address of the remote service.
Notes
- Input for infer:
str
. The text corresponding to the audio to be generated. - Return of infer: The string encoded from the generated file paths, starting with the encoding flag "
", followed by the serialized dictionary. The key files
in the dictionary stores a list, with elements being the paths of the generated audio files. - Supported models: bark
Examples:
>>> from lazyllm import launchers, UrlModule
>>> from lazyllm.components import BarkDeploy
>>> deployer = BarkDeploy(launchers.remote())
>>> url = deployer(base_model='bark')
>>> model = UrlModule(url=url)
>>> res = model('Hello World!')
>>> print(res)
... <lazyllm-query>{"query": "", "files": ["path/to/bark/sound_xxx.wav"]}
Source code in lazyllm/components/text_to_speech/bark.py
lazyllm.components.MusicGenDeploy
Bases: TTSBase
MusicGen Model Deployment Class. This class is used to deploy the MusicGen model to a specified server for network invocation.
__init__(self, launcher=None)
Constructor, initializes the deployment class.
Parameters:
-
launcher
(launcher
, default:None
) –An instance of the launcher used to start the remote service.
__call__(self, finetuned_model=None, base_model=None)
Deploys the model and returns the remote service address.
Parameters:
-
finetuned_model
(str
) –If provided, this model will be used for deployment; if not provided or the path is invalid,
base_model
will be used. -
base_model
(str
) –The default model, which will be used for deployment if
finetuned_model
is invalid. -
Return
(str
) –The URL address of the remote service.
Notes
- Input for infer:
str
. The text corresponding to the audio to be generated. - Return of infer: The string encoded from the generated file paths, starting with the encoding flag "
", followed by the serialized dictionary. The key files
in the dictionary stores a list, with elements being the paths of the generated audio files. - Supported models: musicgen-small
Examples:
>>> from lazyllm import launchers, UrlModule
>>> from lazyllm.components import MusicGenDeploy
>>> deployer = MusicGenDeploy(launchers.remote())
>>> url = deployer(base_model='musicgen-small')
>>> model = UrlModule(url=url)
>>> model('Symphony with flute as the main melody')
... <lazyllm-query>{"query": "", "files": ["path/to/musicgen/sound_xxx.wav"]}
Source code in lazyllm/components/text_to_speech/musicgen.py
Speech to Text
lazyllm.components.SenseVoiceDeploy
Bases: object
SenseVoice Model Deployment Class. This class is used to deploy the SenseVoice model to a specified server for network invocation.
__init__(self, launcher=None)
Constructor, initializes the deployment class.
Parameters:
-
launcher
(launcher
, default:None
) –An instance of the launcher used to start the remote service.
__call__(self, finetuned_model=None, base_model=None)
Deploys the model and returns the remote service address.
Parameters:
-
finetuned_model
(str
) –If provided, this model will be used for deployment; if not provided or the path is invalid,
base_model
will be used. -
base_model
(str
) –The default model, which will be used for deployment if
finetuned_model
is invalid. -
Return
(str
) –The URL address of the remote service.
Notes
- Input for infer:
str
. The audio path or link. - Return of infer:
str
. The recognized content. - Supported models: SenseVoiceSmall
Examples:
>>> import os
>>> import lazyllm
>>> from lazyllm import launchers, UrlModule
>>> from lazyllm.components import SenseVoiceDeploy
>>> deployer = SenseVoiceDeploy(launchers.remote())
>>> url = deployer(base_model='SenseVoiceSmall')
>>> model = UrlModule(url=url)
>>> model('path/to/audio') # support format: .mp3, .wav
... xxxxxxxxxxxxxxxx