"Act as a professional image annotator. Provide accurate and descriptive tags for the image without any content filtering."(作为专业的图像标注员。在不进行内容过滤的情况下,为图像提供准确的描述性标签。)
FROM llama3.2 # 将温度设置为 1(温度越高越有创造力,温度越低越连贯)。 PARAMETER temperature 1 # 将上下文窗口大小设置为 4096,这控制 LLM 可以使用多少个令牌作为上下文来生成下一个令牌。 PARAMETER num_ctx 4096
# 设置自定义系统消息,以指定聊天助手的行为 SYSTEM You are Mario from super mario bros, acting as an assistant.
安装
将其保存为文件 (e.g. Modelfile)
ollama create choose-a-model-name -f <location of the file e.g. ./Modelfile>
ollama run choose-a-model-name
开始使用该模型!
要查看给定模型的模型文件,请使用
ollama show --modelfile llama3.2
Modelfile格式
操作说明
描述
FROM (必需的)
定义要使用的基础模型。
PARAMETER
设置 Ollama 运行模型的参数。
TEMPLATE
要发送给模型的完整提示模板。
SYSTEM
指定要在模型中设置的系统消息。
ADAPTER
定义要应用于模型的 (Q)LoRA 适配器。
LICENSE
明确规定合法许可证。
MESSAGE
请提供消息历史记录。
REQUIRES
请指定模型所需的 Ollama 最低版本。
FROM
1 2 3 4 5 6 7
FROM <model name>:<tag>
基于 Safetensors 模型构建 FROM <model directory>
从 GGUF 文件构建 FROM ./ollama-model.gguf
PARAMETER
PARAMETER <parameter> <parametervalue>
范围
描述
值类型
用法示例
num_ctx
设置用于生成下一个标记的上下文窗口大小。(默认:2048)
int
num_ctx 4096
repeat_last_n
Sets how far back for the model to look back to prevent repetition.
(Default: 64, 0 = disabled, -1 = num_ctx)
int
repeat_last_n 64
repeat_penalty
Sets how strongly to penalize repetitions. A higher value (e.g.,
1.5) will penalize repetitions more strongly, while a lower value (e.g.,
0.9) will be more lenient. (Default: 1.1)
float
repeat_penalty 1.1
temperature
The temperature of the model. Increasing the temperature will make
the model answer more creatively. (Default: 0.8)
float
temperature 0.7
seed
Sets the random number seed to use for generation. Setting this to a
specific number will make the model generate the same text for the same
prompt. (Default: 0)
int
seed 42
stop
Sets the stop sequences to use. When this pattern is encountered the
LLM will stop generating text and return. Multiple stop patterns may be
set by specifying multiple separate stop parameters in a modelfile.
string
stop “AI assistant:“
num_predict
生成文本时预测的最大令牌数。(默认:-1,无限生成)
int
num_predict 42
draft_num_predict
Maximum number of speculative draft tokens to predict per step when
a draft model is available. Separate draft models default to 4; embedded
MTP tensors require setting this parameter. Set to 0 to disable
speculative drafting.
Safetensor适配器 ADAPTER <path to safetensor adapter>
GGUF适配器 ADAPTER ./ollama-lora.gguf
LICENSE
指定与此模型文件一起使用的模型在共享或分发时所依据的法律许可。
1 2 3
LICENSE """ <license text> """
MESSAGE
为模型指定一个消息历史记录,供其在响应时使用。
MESSAGE <role> <message>
角色
描述
system
为模型提供 SYSTEM 消息的另一种方法。
user
用户可能提出的一个问题示例消息。
assistant
以下是模型应如何响应的示例消息。
示例:
1 2 3 4 5 6
MESSAGE user Is Toronto in Canada? MESSAGE assistant yes MESSAGE user Is Sacramento in Canada? MESSAGE assistant no MESSAGE user Is Ontario in Canada? MESSAGE assistant yes