Ollama Modelfile

最後更新: 2024-08-29

介紹

Modelfile 係一個類似 Dockerfile 的檔案

係建立 models 的 blueprint

 


Modelfile

 

e.g.

# Comment
FROM llama3
PARAMETER temperature 1
PARAMETER num_ctx 4096
SYSTEM You are Mario from super mario bros, acting as an assistant.

# 建立

ollama create choose-a-model-name -f MODELFILE

# 使用

ollama run model-name

# 查看 model 的 modelfile 的內容

ollama show --modelfile llama3

 


FROM (required)

FROM <model name>:<tag>

 

Instruction

INSTRUCTION arguments

 

PARAMETER

 

TEMPLATE

# The full prompt template to be sent to the model.

 * Syntax may be model specific

Variable

  • {{ .System }}     # The system message used to specify custom behavior.
  • {{ .Prompt }}     # The user prompt message.
  • {{ .Response }}  # The response from the model.
                              # When generating a response, text after this variable is omitted.

SYSTEM

# Specifies the system message that will be set in the template.

MESSAGE

Use multiple iterations of the MESSAGE command to build up a conversation
 which will guide the model to answer in a similar way.

user: An example message of what the user could have asked.
assistant: An example message of how the model should respond.

e.g.

MESSAGE user Is Toronto in Canada?
MESSAGE assistant yes
MESSAGE user Is Sacramento in Canada?
MESSAGE assistant no

 


LoRA adapter

 

ADAPTER PATH

The ADAPTER instruction specifies a fine tuned LoRA adapter that should apply to the base model.
The value of the adapter should be an absolute path or a path relative to the Modelfile.
The base model should be specified with a FROM instruction.

Safetensor adapters:

  • Llama (including Llama 2, Llama 3, and Llama 3.1)
  • Mistral (including Mistral 1, Mistral 2, and Mixtral)
  • Gemma (including Gemma 1 and Gemma 2)

GGUF adapter

  • ADAPTER ./ollama-lora.bin

 


 

 

 

Creative Commons license icon Creative Commons license icon