-
Notifications
You must be signed in to change notification settings - Fork 159
ollama_zh
ymcui edited this page May 8, 2024
·
9 revisions
Ollama 是一个多平台(macOS, Windows, Linux)的大模型聊天程序,能够加载GGUF格式(llama.cpp)的模型。接下来将简要介绍使用方法。其余用途请自行尝试和查阅官方手册进行了解。
进入官方页面下载对应平台的软件:https://ollama.com/download

- macOS:下载完毕之后直接拖入“应用程序”
- Windows preview:下载运行exe文件
- Linux:执行以下命令
curl -fsSL https://ollama.com/install.sh | sh
其余平台请参考:https://github.com/ollama/ollama?tab=readme-ov-file#ollama
在文本编辑器中编写Modelfile
文件,其内容如下:
FROM /your-path-to-ggml/ggml-model-q8_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 """You are a helpful assistant. 你是一个乐于助人的助手。"""
PARAMETER temperature 0.2
PARAMETER num_keep 24
PARAMETER stop <|start_header_id|>
PARAMETER stop <|end_header_id|>
PARAMETER stop <|eot_id|>
其中:
-
FROM
字段指向GGUF文件的路径,由于是聊天交互,这里使用的是Instruct模型 -
TEMPLATE
字段定义了Llama-3-Instruct的指令模板格式 -
SYSTEM
字段定义了系统指令(目前设置为空) -
PARAMETER
字段定义了一些超参数,详细列表参见:https://github.com/ollama/ollama/blob/main/docs/modelfile.md
命令行中运行以下命令,创建一个名为llama3-zh-inst
(名字可自定义)的模型实例,加载Modelfile
配置:
ollama create llama3-zh-inst -f Modelfile
创建过程输出日志如;
transferring model data
creating model layer
creating template layer
creating system layer
creating parameters layer
creating config layer
using already created layer sha256:f2a44c6358e8e0a60337f8a1b31f55f457558eeefd4f344272e44b0e73a86a32
using already created layer sha256:8ab4849b038cf0abc5b1c9b8ee1443dca6b93a045c2272180d985126eb40bf6f
writing layer sha256:b821abf159071cfc90f0941b5ca7ef721f229cfcfadcf95b5c58d0ceb3e773c7
writing layer sha256:dc4ec177268acc3382fc6c3a395e577bf13e9e0340dd313a75f62df95c48bc1d
writing manifest
success
输出success
后,即表示完成创建。
输入以下命令进入聊天程序
ollama run llama3-zh-inst
在>>>
后输入用户指令;输入/bye
结束聊天。
关于ollama的其他用法,请参考官方文档:https://github.com/ollama/ollama?tab=readme-ov-file#cli-reference
- Model Reconstruction
- Model Quantization, Inference and Deployment
- System Performance
- Training Scripts
- FAQ