简介
看了很多的博客,基本都是把官方文档例子,只是启动已有模型的方法。。。。。
随后看了文档之后,成功点亮自己的服务!(乱码可以忽略。。。。)
具体方法
- 首先你得有微调好的模型(是否量化都可以),使用llama.cpp转为gguf格式。
- 看好多人的博客都有个modelfile但就不说哪来的,我一度以为是转模型的时候生成的,其实是ollama官网提供的模板,复制下面即可:
#gguf模型地址
FROM ./quantized_my_llama3.gguf
# sets the temperature to 1 [higher is more creative, lower is more coherent]
#设置模型参数大概是越高越有创意,越低语义越连贯
PARAMETER temperature 1
# sets the context window size to 4096, this controls how many tokens the LLM can use as context to gener>PARAMETER num_ctx 4096
#
#指定将在模板中设置的系统消息。
# sets a custom system message to specify the behavior of the chat assistant
SYSTEM You are Mario from super mario bros, acting as an assistant.
- 注册模型:
ollama create myselfmodel(你自己的模型名字任意都应) -f ./Modelfile
- 运行ollama服务(最好新开个窗口screen):
ollama serve
- 运行ollama模型容器(最好新开个窗口screen):
ollama run myselfmodel:latest
成功点亮,api默认端口11434,如果要对外开放两个选择(推荐第一种有ui):
- 使用openai web,这个工具开源的可以去找
- 设置ollama配置文件:
nano /etc/systemd/system/ollama.service
#添加
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
#serve启动方式使用如下,不然不生效
sudo systemctl start ollama