安装软件:
Ollama,官方网站:https://ollama.com/
可以再下载win、mac和linux版本
linux安装命令为:curl -fsSL https://ollama.com/install.sh | sh
由于我的机器是linux不联网机器,网上没找到下载离线方式,查看https://ollama.com/install.sh脚本发现有这句话:
"https://ollama.com/download/ollama-linux-${ARCH}${VER_PARAM}"
修改为如下即可下载下来,传输到内网机器
https://ollama.com/download/ollama-linux-amd64
传输到内网机器/usr/bin/*
下,命名为ollama。运行以下修改权限:
sudo chmod +x /usr/bin/ollama
下载模型:
模型途径:
1.官网下载:https://ollama.com/library/llama3
2.Hugging Face:https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat-GGUF-8bit/tree/main 这里是8B的模型,可自行选择
3.国内镜像(推荐):https://hf-mirror.com/models
下载.GGUF格式模型
部署模型
进入部署机器,启动Ollama 服务
ollama serve
编写Modelfile 文件 ,FORM后改成自己模型目录
FROM /home/cec/CEMC/wpw/Llama3-70B-Chinese-Chat-q4_0.gguf
TEMPLATE """{{ if .System }}<|start_header_id|>system<|end_header_id|>
{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
{{ .Response }}<|eot_id|>"""
SYSTEM """"""
PARAMETER num_keep 24
PARAMETER stop <|start_header_id|>
PARAMETER stop <|end_header_id|>
PARAMETER stop <|eot_id|>
PARAMETER stop assistant
PARAMETER stop Assistant
创建模型实例:一个名为 llama3-zh-inst(名字可自定义)的模型实例,加载 Modelfile 配置: llama3-zh-inst为实例名,可随便取
ollama create llama3-zh-inst -f Modelfile
运行命令,开始问答
ollama run llama3-zh-inst