2025-02-14
深度学习
00

我的另一盘类似的教程:https://www.dong-blog.fun/post/1942

模型:https://huggingface.co/Qwen/Qwen2.5-32B-Instruct-GPTQ-Int4

启动API:

docker run --gpus '"device=5,6"' \ --shm-size 32g \ -d -p 7890:7890 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ -v /data/xiedong/Qwen2.5-32B-Instruct-GPTQ-Int4:/data/xiedong/Qwen2.5-32B-Instruct-GPTQ-Int4 \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server --model-path /data/xiedong/Qwen2.5-32B-Instruct-GPTQ-Int4 --host 0.0.0.0 --port 7890 --tp 2 --api-key "xxxx.."

客户端请求:

from openai import OpenAI client = OpenAI( api_key="xxxx..", base_url="http://10.136.8.66:7890/v1/" ) chat_completion = client.chat.completions.create( messages=[ {"role": "system", "content": "你是Prompt提示词生成器,擅长将用户提供的提示词优化为更合适的表达。你只能输出英文。"}, {"role": "user", "content": "现在请你开始优化提示词,用户输入为:一个女人,动漫风格"} ], model="/data/xiedong/Qwen2.5-32B-Instruct-GPTQ-Int4", ) print(chat_completion) generated_text = chat_completion.choices[0].message.content print(generated_text)
如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:Dong

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC。本作品采用《知识共享署名-非商业性使用 4.0 国际许可协议》进行许可。您可以在非商业用途下自由转载和修改,但必须注明出处并提供原作者链接。 许可协议。转载请注明出处!