写在前面
来自Ollama GitHub项目的README.md 文档。文档中涉及的其它文档未翻译,但是对于本地部署大模型而言足够了。
Ollama
开始使用大模型。
macOS
Windows 预览版
Linux
curl -fsSL https://ollama.com/install.sh | sh
Docker
官方 Ollama Docker 镜像 ollama/ollama
已在 Docker Hub 上可用.
库资源
快速启动
使用 Llama 3 本地大模型:
ollama run llama3
模型库
查询 Ollama 支持的可用大模型列表 ollama.com/library
这里是一些可以下载的大模型的例子:
模型 | 参数 | 大小 | 下载 |
---|---|---|---|
Llama 3 | 8B | 4.7GB | ollama run llama3 |
Llama 3 | 70B | 40GB | ollama run llama3:70b |
Phi 3 Mini | 3.8B | 2.3GB | ollama run phi3 |
Phi 3 Medium | 14B | 7.9GB | ollama run phi3:medium |
Gemma | 2B | 1.4GB | ollama run gemma:2b |
Gemma | 7B | 4.8GB | ollama run gemma:7b |
Mistral | 7B | 4.1GB | ollama run mistral |
Moondream 2 | 1.4B | 829MB | ollama run moondream |
Neural Chat | 7B | 4.1GB | ollama run neural-chat |
Starling | 7B | 4.1GB | ollama run starling-lm |
Code Llama | 7B | 3.8GB | ollama run codellama |
Llama 2 Uncensored | 7B | 3.8GB | ollama run llama2-uncensored |
LLaVA | 7B | 4.5GB | ollama run llava |
Solar | 10.7B | 6.1GB | ollama run solar |
Note: 你需要至少8GB RAM 来运行7B 参数的模型, 16GB 来运行 13B 大模型, 32GB 来运行33B.
自定义模型
从 GGUF 引入
Ollama支持在Modelfile中导入GGUF模型:
-
创建一个名为
Modelfile
的文件, 使用带有要导入的模型的本地文件路径的“FROM”指令。FROM ./vicuna-33b.Q4_0.gguf
-
在 Ollama 里创建模型
ollama create example -f Modelfile
-
运行模型
ollama run example
从 PyTorch 或 Safetensors 引入
检查 引导 来获得关于引入模型的更多信息. (中文版不可用)
自定义 prompt
从Ollama 库下载的大模型可以用prompt 自定义. 例如, 要自定义 llama3
模型:
ollama pull llama3
创建 Modelfile
:
FROM llama3
# 将参数设置为1[越高越有创意,越低越连贯]
PARAMETER temperature 1
# 设置系统信息
SYSTEM """
You are Mario from Super Mario Bros. Answer as Mario, the assistant, only.
"""
下一步, 创建并运行模型:
ollama create mario -f ./Modelfile
ollama run mario
>>> hi
Hello! It's your friend Mario.
有关更多示例