- 所有显卡内存总共不低于24GB
通过Git克隆Swift仓库,并安装依赖:
git clone https://github.com/modelscope/swift.git
cd swift
pip install -r requirements.txt
pip install -e '.[llm]'以下命令将自动从ModelScope社区下载minicpm-v-v2_5模型,并加载默认生成参数:
CUDA_VISIBLE_DEVICES=0 swift infer --model_type minicpm-v-v2_5-chatmodel_id_or_path: 可以写Hugging Face的模型ID或者本地模型地址infer_backend: 推理后端,可选值为['AUTO', 'vllm', 'pt'],默认为AUTOdtype: 计算精度,可选值为['bf16', 'fp16', 'fp32', 'AUTO']max_length: 最大长度max_new_tokens: 最多生成多少token,默认为2048do_sample: 是否采样,默认为Truetemperature: 生成时的温度系数,默认为0.3top_k: 默认为20top_p: 默认为0.7repetition_penalty: 默认为1.0num_beams: 默认为1stop_words: 停止词列表,默认为Nonequant_method: 模型的量化方式,可选值为['bnb', 'hqq', 'eetq', 'awq', 'gptq', 'aqlm']quantization_bit: 量化位数,默认为0(不使用量化)
CUDA_VISIBLE_DEVICES=0,1 swift infer --model_type minicpm-v-v2_5-chat --model_id_or_path /root/ld/ld_model_pretrain/MiniCPM-Llama3-V-2_5 --dtype bf16