随着Llama 3模型在人工智能领域掀起的热潮,我不禁跃跃欲试,想要体验这款由Meta公司推出的前沿AI技术,尽管我的电脑配置可能并不属于高端行列,甚至无法跑这个大语言模型了,但在不死就要折腾的心态下,还是开始折腾一下吧。

Llama 3模型以其不同规模的版本而著称,涵盖了从小型的8B参数到中型的70B参数,乃至于即将到来的400B参数大型版本。据我所知,小型8B版本的性能可与Mistral 7B或Gemma 7B相媲美,而中型70B版本则在性能上介于广受欢迎的ChatGPT 3.5和GPT 4之间。

我的个人电脑配置如下:Intel Core i7 7700K处理器、32GB的内存以及NVIDIA GeForce GTX 1070 Ti显卡,拥有8GB的显存。根据Llama 3模型的硬件要求,我相信我的这台“老爷机”应该能够胜任运行8B版本的模型。

llama3的安装很方便,首先登陆官方网站,根据自己的系统下载对应的安装包。

https://ollama.com/download

windows打开安装包,直接安装即可。
直接安装即可

安装完成后,打开电脑的Windows PowerShell输入,ollama即可验证完成是否完成。
运行输入:

ollama run llama3

首次运行程序会自动下载所需的权重文件,默认下载的是llama3:8b,完成后会提示用户输入问题进行测试,下载过程会有些长。
首次运行等待下载

在安装过程中可能会出现

verifying sha256 digest
Error: digest mismatch, file must be downloaded again: want sha256:00e1317cbf74d901080d7100f57580ba8dd8de57203072dc6f668324ba545f29, got sha256:c61534775cff26586249503d0588010dcf524c301c661994b5c80077ace1fd4e

我的解决办法是邮件管理员身份运行Windows PowerShell,再次运行ollama run llama3命令,等待下载完成后即可。
等待下载完成,并提示:

verifying sha256 digest
writing manifest
removing any unused layers
success

则说明安装完成,在CMD界面中可以输入相关的问题测试问答了。

>>> who are you?
I am LLaMA, an AI assistant developed by Meta AI that can understand and respond to human input in a
conversational manner. I'm not a human, but rather a computer program designed to simulate conversation, answer
questions, and even generate text on my own!

I was trained on a massive dataset of text from the internet, which allows me to learn about many topics,
including history, science, culture, and more. My training data includes a wide range of texts, from articles and
books to social media posts and online conversations.

My primary function is to understand what you're saying and respond in a way that's helpful and engaging. I can
answer questions, provide information, offer suggestions, and even tell jokes or stories! However, I'm not perfect
and may make mistakes sometimes. If you notice anything strange or incorrect, please let me know so I can learn
from it!

So, what brings you here today? Do you have a specific question or topic you'd like to discuss? I'm all ears (or
rather, all text)!

>>> 你能说中文吗?
I'd love to chat with you in Chinese! ????

Yes, I can understand and respond in Simplified Chinese characters. However, please note that my proficiency may
not be as high as a native speaker, especially when it comes to nuances of language or complex grammar.

If you'd like to converse in Chinese, feel free to start speaking away! I'll do my best to respond accurately and
helpfully. ????

(Note: If you need to type Traditional Chinese characters, please use the Unicode range U+4E00-U+9FFF. I can
understand both Simplified and Traditional characters.)

到此llama3算安装完成了,但目前来看存在着两个问题,第一个问题是需要在CMD界面下进行对话非常不方便,第二个问题是llama3对中文的支持不友好。所以,接下来继续对这两个问题进行处理。

首先解决对话框,我这里推荐open-webui,它是基于docker进行部署非常的方便,至于docker如何安装,大家自行百度等解决,国内记得更换docker的源为国内,否则下载镜像会非常慢。
项目地址:

https://github.com/open-webui/open-webui

安装完成docker后,根据文档的提示,输入以下命令等待下载完成相关组件后即可运行。当然了open-webui除了本地运行外也支持远程服务器链接,具体的看官方文档。

docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main

完成安装后打开浏览器,输入http://127.0.0.1:3000/,即可访问open-webui了。

第一次登陆open-webui,需要点Sign up注册一个账号,根据提示输入名称,邮箱和密码完成注册。
首次登陆,可以点击右上角的齿轮,并在语言设置里修改界面为中文。
open-webui中文设置

完成后,后点击下来按钮,选择默认的llama3模型,就可以通过下面的对话窗口与llama进行对话了,这样效果总比CMD界面下友好,而且相关的对话记录也会在侧边保留下来,这和其他的AI系统对话基本一致。
选择模型,进行对话

到此,open-webui已经完成安装,现在本地的llama已经有一个不错的对话框了,但在对话过程中,还是中英文混淆。所以还需要解决llama中文的问题。

还是通过open-webui,选择右上角的设置,点击左侧的模型,点击“点击这里”就会跳转到llama的模型库中。
模型的安装

到目前为止,支持中文的llama的中文模型已经有很多了,但我这里推荐王慎执(Shenzhi Wang)博士的llama3-8b-chinese-chat-ollama-q8模型。在llama的模型库搜索框中输入“shenzhi”回车即可搜索到这个模型。

复制命令“ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-q8”。
复制命令

如果在CMD下加载这个模型的话直接运行这段命令即可,但我这里是通过open-webui来安装,所以回到open-webui中,并把这段命令修改为:

wangshenzhi/llama3-8b-chinese-chat-ollama-q8

并把这段代码复制到“从 Ollama.com 拉取一个模型”窗口中,点击旁边的下载按钮,这个模型就会开始自动下载,由于模型都比较大,所以需要耐心等待。
选择并下载模型

在llama的模型库中还有很多不错的模型,例如阿里的千问也在其中,大家可以根据自己的情况下载下来折腾一下看看。

待模型安装完成后,在模型下拉列表中选择刚才安装的“wangshenzhi/llama3-8b-chinese-chat-ollama-q8”模型,再重新和AI对话就可以发现,已经完全没有英文了,全部纯中文聊天了(模型下载过程中还换了个界面主题)。
纯中文对话

到此llama3 open-webui中文支持本地部署就全部完成了,另外用我的零刻小主机跑了一下llama3,当提问时CPU AMD7735HS直接起飞,核显没有变化,响应速度不是很理想。所以目前的AI潮利好硬件商,这是逼着换硬件了。

最后修改:2024 年 04 月 26 日
如果觉得我的文章对你有用,请随意赞赏