大家好,感谢邀请,今天来为大家分享一下kuaichuanmirror的问题,以及和int4量化版本速度飞快的一些困惑,大家要是还不太明白的话,也没有关系,因为接下来将为大家分享,希望可以帮助到大家,解决大家的问题,下面就开始吧!
找到个网站可以快速的下载模型。
https://aliendao.cn/models/baichuan-inc/Baichuan-7B
Baichuan-7B是由百川智能开发的一个开源可商用的大规模预训练语言模型。基于Transformer结构,在大约1.2万亿tokens上训练的70亿参数模型,支持中英双语,上下文窗口长度为4096。在标准的中文和英文benchmark(C-Eval/MMLU)上均取得同尺寸最好的效果。
其他信息介绍:https://gitee.com/mirrors/baichuan-7B
在docker中折腾吧,使用python的镜像就可以。因为需要进行转换。
bashngitclonehttps://ghproxy.com/https://github.com/ggerganov/llama.cppnndockerrun-itd--rm--namepython-v`pwd`/llama.cpp:/datapython:slim-bullseyenndockerexec-itpythonbashnn#默认注释了源码镜像以提高aptupdate速度https://developer.aliyun.com/mirror/nnecho"debhttps://mirrors.aliyun.com/debian/bullseyemaincontribnon-free">/etc/apt/sources.listnecho"debhttps://mirrors.aliyun.com/debian/bullseye-updatesmaincontribnon-free">>/etc/apt/sources.listnecho"debhttps://mirrors.aliyun.com/debian/bullseye-backportsmaincontribnon-free">>/etc/apt/sources.listnecho"debhttps://mirrors.aliyun.com/debian-securitybullseye-securitymaincontribnon-free">>/etc/apt/sources.listnnnnn#执行工具安装napt-getupdate&&apt-get-yinstallbuild-essentialncd/datann#设置pyton3源npip3configsetglobal.index-urlhttps://mirrors.aliyun.com/pypi/simple/npip3configsetinstall.trusted-hostmirrors.aliyun.comnnpython3-mpipinstall-rrequirements.txtnn#直接就可以编译成功了nmake-jn3,重要步骤!进行两次转换,生成ggml-model-q4_0.bin文件
LLaMA模型为16位浮点精度,其7B版本有70亿参数,该模型完整大小为13GB,则用户至少须有如此多的内存和磁盘,模型才能可用,更不用提13B版本24GB的大小,令人望而却步。但通过量化,比如将精度降至4位,则7B和13B版本分别压至约4GB和8GB,消费级硬件即可满足要求,大家便能在个人电脑上体验大模型了。
这个地方作者没有写太清楚,参考别人的方法,最近作者升级了,脚本直接叫convert.py了
bashpython3convert.py./models/Baichuan-7B/nn#会生成文件:nWrotemodels/Baichuan-7B/ggml-model-f16.ggufnn
然后生成了文件:models/Baichuan-7B/ggml-model-f16.gguf
bash./quantize./models/Baichuan-7B/ggml-model-f16.gguf./models/Baichuan-7B/ggml-model-q4_0.ggufq4_0nn3.8Gggml-model-q4_0.ggufnn
就生成了文件:ggml-model-q4_0.gguf这个是经过优化的速度快。
bash./main-m./models/Baichuan-7B/ggml-model-q4_0.gguf-n256-p"搜狗公司介绍"n
测试了两个问题,感觉上内容上和chatglm的结果差些。
天津景点有哪些-百度经验这座城市,在古代时被称为直沽。它有两个名字:一个是海河的上游北运河口的小渔村;另一个是南运河南端的大津关码头,与南方的水路相连...[endoftext]nn
问题北京景点:
北京景点大全.2018北京旅游攻略3天2夜行程安排n“不到长城非好汉”来京必须做的事情,去爬一次八达岭。看一场升旗仪式,再去看一次故宫的雪景![endoftext]n
其他的没有测试。
切换显卡镜像,这里使用的是devel镜像,比较大,包括cuda的命令才行。ncvv作为cuda的编译器,在runtime的镜像中是不提供的。
需要使用镜像:nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04才可以。
bashn#还是依赖上面的步骤ndockerrun-itd--rm--namecuda--runtime=nvidia--gpusall-v`pwd`/llama.cpp:/datanvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04nn#进入镜像ndockerexec-itcudabashnn#基础库都已经好了,直接运行即可:nmakeclean&&makeLLAMA_CUBLAS=1nn
如果要执行模型转换需要再安装python3环境:
bashapt-getupdate&&apt-get-yinstallbuild-essentialpython3python3-pipnpython3-mpipinstall-rrequirements.txtnn#转换成gguf格式npython3convert.py./models/Baichuan-7B/nn#支持转换的模型:F16tQ4_0tQ4_1tQ5_0tQ5_1tQ8_0n./quantize./models/Baichuan-7B/ggml-model-f16.gguf./models/Baichuan-7B/ggml-model-q8_0.ggufq8_0nn./quantize./models/Baichuan-7B/ggml-model-f16.gguf./models/Baichuan-7B/ggml-model-q5_0.ggufq5_0nn./quantize./models/Baichuan-7B/ggml-model-f16.gguf./models/Baichuan-7B/ggml-model-f16_0.gguff16n
转换的文件大小:
-rw-r--r--1rootroot13G9月1022:18ggml-model-f16_0.ggufn-rw-r--r--1rootroot14G9月1022:12ggml-model-f16.ggufn-rw-r--r--1rootroot3.8G9月1019:33ggml-model-q4_0.ggufn-rw-r--r--1rootroot4.6G9月1022:20ggml-model-q5_0.ggufn-rw-r--r--1rootroot7.0G9月1022:17ggml-model-q8_0.ggufnn
测试运行main
bashtime./main-m./models/Baichuan-7B/ggml-model-q4_0.gguf-n256-p"北京景点"ntime./main-m./models/Baichuan-7B/ggml-model-q5_0.gguf-n256-p"北京景点"ntime./main-m./models/Baichuan-7B/ggml-model-q8_0.gguf-n256-p"北京景点"ntime./main-m./models/Baichuan-7B/ggml-model-f16.gguf-n256-p"北京景点"nn
q4_0使用GPU内存才148MB
realt1m7.764snusert3m11.404snsyst0m3.073snn+---------------------------------------------------------------------------------------+n|Processes:|n|GPUGICIPIDTypeProcessnameGPUMemory|n|IDIDUsage|n|=======================================================================================|n|0N/AN/A22629C./main148MiB|n+---------------------------------------------------------------------------------------+nn
q5_0使用GPU内存也是148MB
realt1m20.153snusert3m48.040snsyst0m3.741sn
q8_0使用GPU内存也是148MB
realt1m59.107snusert5m36.037snsyst0m4.938snn
f16使用GPU内存也是148MB
realt2m54.644snusert7m13.311snsyst0m9.271sn
每次返回的结果都是不太一样的。尤其是感觉和问题差异比较大:比如这个结果:
北京景点预约1.0.4版本更新,增加了“门票预订”功能。用户在手机淘宝搜索“北京景点网”,进入主页面后点选景区下方的“免费在线购票...[endoftext]
挺奇怪的,GPU的内存消耗并不是很大。但是发现int4是比较顺畅的,但是到了q8和f16就不是很快了。稍微有点卡了。
有一点感觉上这个问题必须要具体点,否则百川给出的结果会不一样。这个和chatglm还是有差距的:
同样的问题,chatglm2结果比较稳定。错误也比较明显,居然返回大雁塔了??!!baichuan好的一点是新模型发布了。baichuan2估计会解决这个问题。同时baichuan可以支持使用llam.cpp上面运行。同时还有13B的模型可以使用,所以要好好的研究下。
好了,文章到此结束,希望可以帮助到大家。