app开发网站建设前景,东莞营销型网站外包,做职业规划的网站,单位外部网站建设价格由于近期代码微调以及测试都是在远程服务器上#xff0c;因此LLamafactory-cli webui 以及vLLM的ui均无法使用#xff0c;因此不断寻求解决方案#xff0c;我提供一个解决方案#xff0c;LLamafactory微调完成的模型需要合并为一个完整模型后再使用vLLM进行代码推理测试微调…由于近期代码微调以及测试都是在远程服务器上因此LLamafactory-cli webui 以及vLLM的ui均无法使用因此不断寻求解决方案我提供一个解决方案LLamafactory微调完成的模型需要合并为一个完整模型后再使用vLLM进行代码推理测试微调模型的结果。
由于chat启动的终端互动模式均无法上传图像进行交互因此需要代码或者参数来上传图像进行理解。
Vision Language — vLLM 这个链接里有vLLM支持的多模态大模型不同的函数对prompt的处理
我在这里提供一个使用vLLM对Qwen2-VL的多模态图像理解的python代码
from vllm import LLM, SamplingParams
from PIL import Imagedef run_qwen2_vl(questions: str, image_path: str):# 模型初始化配置llm LLM(modelQwen/Qwen2-VL-Lora_Sft,max_model_len4096,max_num_seqs5,dtypehalf)# 多模态数据加载image Image.open(image_path)question What is the content of this image?# 提示词构造prompt_template [(|im_start|system\nYou are a helpful assistant.|im_end|\n|im_start|user\n|vision_start||image_pad||vision_end|f{question}|im_end|\n|im_start|assistant\n) for question in questions]print(prompt_template[0])sampling_params SamplingParams(max_tokens1024,temperature0.8,top_p0.95,frequency_penalty0.2,presence_penalty0.3,stop[|im_end|])# 生成请求outputs llm.generate({prompt: prompt_template[0],multi_modal_data: {image: image},}, sampling_paramssampling_params)# 结果解析return [output.outputs[0].text for output in outputs]# 使用示例
if __name__ __main__:response run_qwen2_vl(questions[请使用中文描述下这个图像并给出中文诊断结果],image_pathaaaa.jpg)print(模型输出:, response[0])