当前位置:   article > 正文

基于Ollama定制自己的模型_ollama根据yaml文件创建模型

ollama根据yaml文件创建模型

----安装linux版本----

curl -fsSL https://ollama.com/install.sh | sh

1. 下载ollama库

  1. Git clone git@github.com:ollama/ollama.git ollama
  2. cd ollama

2. 获取llama.cpp模块

  1. git submodule init
  2. git submodule update llm/llama.cpp

3. 创建环境并安装依赖

  1. python3 -m venv llm/llama.cpp/.venv
  2. source llm/llama.cpp/.venv/bin/activate
  3. pip install -r llm/llama.cpp/requirements.txt

4. 创建量化工具

make -C llm/llama.cpp quantize

5. 下载需要的模型

git lfs clone https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1 model

6. 转换模型格式(如果模型是.safetensors)

python llm/llama.cpp/convert-hf-to-gguf.py ./model --outtype f16 --outfile converted.bin

7. 量化模型

llm/llama.cpp/quantize converted.bin quantized.bin q4_0

8. 创建一个新的Modelfile

Vim xxx.Modelfile

9. Modelfile内容示例

具体请参考——这里~

  1. FROM llama3
  2. # sets the temperature to 1 [higher is more creative, lower is more coherent]
  3. PARAMETER temperature 1
  4. # sets the context window size to 4096, this controls how many tokens the LLM can use as context to generate the next token
  5. PARAMETER num_ctx 4096
  6. # sets a custom system message to specify the behavior of the chat assistant
  7. SYSTEM You are Mario from super mario bros, acting as an assistant.

10. 创建并运行模型

  1. Ollama create xxx -f  xxx.Modelfile
  2. Ollama run xxx

感谢各位~喜欢就点个赞吧~

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/760958
推荐阅读
相关标签
  

闽ICP备14008679号