目標(biāo)
1、使用開(kāi)源的大模型服務(wù)搭建屬于自己的模型服務(wù);
2、調(diào)優(yōu)自己的大模型;
選型
采用通義千問(wèn)模型,https://github.com/QwenLM/Qwen
步驟
1、下載模型文件
開(kāi)源模型庫(kù):https://www.modelscope.cn/models
mkdir -p /data/qwen
cd /data/qwen
git clone --depth 1 https://www.modelscope.cn/qwen/Qwen-14B-Chat.git
# 小內(nèi)存機(jī)器下載1.8B參數(shù)的,14B需要幾十內(nèi)存
# git clone --depth 1 https://www.modelscope.cn/qwen/Qwen-1_8B-Chat.git
2、下載使用docker 鏡像
docker pull qwenllm/qwen
3、啟動(dòng)腳本
https://github.com/QwenLM/Qwen/blob/main/docker/docker_web_demo.sh
# 修改如下內(nèi)容
IMAGE_NAME=qwenllm/qwen
QWEN_CHECKPOINT_PATH=/data/qwen/Qwen-14B-Chat
PORT=8000
CONTAINER_NAME=qwen
4、運(yùn)行
訪問(wèn)http://localhost:8080 即可
sh docker_web_demo.sh
輸出如下,可以查看容器日志是否報(bào)錯(cuò)。
Successfully started web demo. Open '...' to try!
Run `docker logs ...` to check demo status.
Run `docker rm -f ...` to stop and remove the demo.
效果
文檔參考
https://github.com/QwenLM/Qwen/blob/main/README_CN.md
常見(jiàn)問(wèn)題
1、運(yùn)行報(bào)錯(cuò)?
去掉docker_web_demo.sh中--gpus all
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
2、Error while deserializing header: HeaderTooLarge
先安裝yum install git-lfs 在下載模型文件,模型是git大文件管理,需要git-lfs的支持。
Traceback (most recent call last):
? File "web_demo.py", line 209, in <module>
? ? main()
? File "web_demo.py", line 203, in main
? ? model, tokenizer, config = _load_model_tokenizer(args)
? File "web_demo.py", line 50, in _load_model_tokenizer
? ? model = AutoModelForCausalLM.from_pretrained(
? File "/usr/local/lib/python3.8/dist-packages/transformers/models/auto/auto_factory.py", line 511, in from_pretrained
? ? return model_class.from_pretrained(
? File "/usr/local/lib/python3.8/dist-packages/transformers/modeling_utils.py", line 3091, in from_pretrained
? ? ) = cls._load_pretrained_model(
? File "/usr/local/lib/python3.8/dist-packages/transformers/modeling_utils.py", line 3456, in _load_pretrained_model
? ? state_dict = load_state_dict(shard_file)
? File "/usr/local/lib/python3.8/dist-packages/transformers/modeling_utils.py", line 458, in load_state_dict
? ? with safe_open(checkpoint_file, framework="pt") as f:
safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge
3、Cannot allocate memory文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-790964.html
內(nèi)存不足,可以嘗試選擇1_8B小參數(shù)的模型。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-790964.html
到了這里,關(guān)于使用開(kāi)源通義千問(wèn)模型(Qwen)搭建自己的大模型服務(wù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!