大语言模型
大型语言模型(LLM)
大型语言模型(Large Language Models,简称LLM)是一类基于人工智能技术的高级文本生成系统,其主要特点是能够通过大规模的训练数据来学习和理解人类语言,并能够生成自然流畅的文本。
Ollama是一个开源的工具,旨在简化大型语言模型的部署和运行过程,使得用户可以在本地环境中使用高质量的语言模型。
脚本安装
sudo apt install curl
curl -fsSL https://ollama.com/install.sh | sh
整个安装过程耗时比较久,耐心等待!
出现curl: (22) The requested URL returned error: 404 提示可以忽略!
Ollama使用
终端输入ollama可以看到提示:
命令 | 作用 |
---|---|
ollama serve | 启动ollama |
ollama create | 从模型文件创建模型 |
ollama show | 显示模型信息 |
ollama run | 运行模型 |
ollama pull | 从注册表中拉取模型 |
ollama push | 将模型推送到注册表 |
ollama list | 列出模型 |
ollama ps | 列出运行的模型 |
ollama cp | 复制模型 |
ollama rm | 删除模型 |
ollama help | 获取有关任何命令的帮助信息 |
Ollama卸载
删除服务
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.service
删除文件
sudo rm $(which ollama)
删除模型和服务用户和组
sudo rm -r /usr/share/ollama
sudo userdel ollama
sudo groupdel ollama
大模型对话平台安装
阿里云安装Docker
更新本地软件包列表
sudo apt update
安装必备软件
sudo apt install apt-transport-https ca-certificates curl gnupg2 lsb-release software-properties-common
添加软件源的GPG密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
添加阿里云镜像软件源
echo "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
安装Docker
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
对于已安装Docker的系统,可以直接在终端输入下面命令:图片是已经拉取的结果
sudo docker pull ghcr.io/open-webui/open-webui:main
Open WebUI运行
终端输入下面命令启动指定Docker:
sudo docker run --network=host -v open-webui:/app/backend/data -e OLLAMA_BASE_URL=http://127.0.0.1:11434 --name open-webui --restart always ghcr.io/open-webui/open-webui:main
成功启动后,在浏览器使用下面网址访问:http://localhost:8080/
首次使用需要自己注册一个账号,该账号是管理员账号,信息可按照要求自行填写!
由于我们的镜像所有内容已经设置和测试,用户直接使用我们注册的账号登录即可:
用户名:admin
邮箱:admin@qq.com
密码:admin
注册并登录
模型对话
使用Open WebUI进行对话会比直接使用Ollama工具运行更加慢,甚至出现超时服务连接失败现象,这个和Jetson Nano的内存有关的,无法避免!
切换模型
点击Select a model可以选择指定模型对话。
使用ollama拉取的模型会自动添加到Open WebUI模型选项,刷新一下网页就会出现新模型!
演示:LLaVA
演示的LLaVA案例需要8G甚至8G以上才可以运行,用户可以使用其它案例测试Open WebUI对话功能!
What's in this image?
常见问题
关闭Open WebUI
关闭自启动的Open WebUI。
查看运行的Docker
docker ps
关闭运行的Docker
docker stop [CONTAINER ID] # 示例 docker stop 5f42ee9cf784
查看停止运行的容器
docker ps -a
清理停止运行的容器
docker rm [CONTAINER ID] # 示例 docker rm 5f42ee9cf784
清理停止运行的所有容器:
docker container prune
常见错误
无法启动Open WebUI
docker: Error response from daemon: Conflict. The container name "/open-webui" is already in use by container "cfc05c84f8e38b290337e7178c76fd1c49076f94b11ed3d49d9448be72b7f20f". You have to remove (or rename) that container to be able to reuse that name.
解决办法:关闭Open WebUI一次并重新启动!
服务连接超时
Open WebUI: Server Connection Error
关闭Open WebUI一次并重新启动,然后重新提问或者换Ollama工具运行模型进行提问!