-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathModelfile-deepseek-r1
More file actions
156 lines (135 loc) · 4.85 KB
/
Modelfile-deepseek-r1
File metadata and controls
156 lines (135 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# ollama create sammcj/deepseek-r1-0528-qwen3-8b-ud:16k-Q6_K_XL -f Modelfile-deepseek-r1
# FROM ./DeepSeek-R1-IQ3_XXS.gguf
FROM ../DeepSeek-R1-0528-Qwen3-8B-UD-Q6_K_XL.gguf
PARAMETER num_ctx 16384
# Note this will use a lot of vRAM as deepseek v3 architecture doesn't support flash attention/qkv
# PARAMETER num_batch 32
# basic sampling
PARAMETER temperature 0.6
PARAMETER top_p 0.95
PARAMETER min_p 0.01
PARAMETER num_keep 512
PARAMETER num_gpu 99
PARAMETER stop "<|begin▁of▁sentence|>"
PARAMETER stop "<|end▁of▁sentence|>"
PARAMETER stop "<|User|>"
PARAMETER stop "<|Assistant|>"
# Experimental for Deepseek's official tool calling template below
PARAMETER stop "<|tool▁output▁begin|>"
PARAMETER stop "<|tool▁output▁end|>"
PARAMETER stop "<|tool▁calls▁begin|>"
PARAMETER stop "<|tool▁calls▁end|>"
PARAMETER stop "<|tool▁sep|>"
# Cline stop Parameters
# PARAMETER stop "</thinking>"
PARAMETER stop "</tool_call>"
PARAMETER stop "</tool_response>"
PARAMETER stop "</ask_followup_question>"
PARAMETER stop "</attempt_completion>"
PARAMETER stop "</write_to_file>"
PARAMETER stop "</execute_command>"
PARAMETER stop "</s>"
PARAMETER stop "[/TOOL_RESULTS]"
### TEMPLATES ###
# Sam's hybrid with tool calls
TEMPLATE """{{- if .Messages }}
{{- if or .System .Tools }}
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}
When using a tool, format as:
{"name": "function_name", "parameters": {"param1": "value1"}}
The following tools are available when needed for specific tasks:
{{ $.Tools }}
{{- end }}
{{- end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- if eq .Role "user" }}<|User|>
{{- if and $.Tools $last }}
Given the tools, please respond with a JSON object for a function call with its proper arguments that best answers the given prompt.
Prioritise specific concurrent tool calls over a single generic tool call. Use tools first.
Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.
{{- end }}
{{ .Content }}
{{- if $last }}<|Assistant|>{{ end }}
{{- else if eq .Role "assistant" }}
<|Assistant|>
<think>
{{ .Thinking }}
</think>
{{- if .ToolCalls }}
{{- range .ToolCalls }}
{"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments }}}
{{- end }}
{{- else }}
{{ .Content }}
{{- if not $last }}<|end▁of▁sentence|>{{- end }}
{{- end }}
{{- else if eq .Role "tool" }}<|end▁of▁sentence|><|tool▁outputs▁begin|><|tool▁output▁begin|>{{ .Content }}<|tool▁output▁end|><|tool▁outputs▁end|>
{{- if and $last (ne .Role "assistant") }}<|Assistant|>
{{- if and $.IsThinkSet (not $.Think) -}}
<think>
</think>
{{ end }}
{{- end }}
{{- end }}
{{- end }}
{{- else }}
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Prompt }}
<|User|>
{{ .Prompt }}
{{- end }}
<|Assistant|>
{{ .Response }}
{{- if .Response }}{{ end }}
{{- end }}"""
# DeepSeek R1 Qwen 3 8b distill template from Ollama - might be missing tool calls?
# TEMPLATE """{{- if .System }}{{ .System }}{{ end }}
# {{- range $i, $_ := .Messages }}
# {{- $last := eq (len (slice $.Messages $i)) 1}}
# {{- if eq .Role "user" }}<|User|>{{ .Content }}
# {{- else if eq .Role "assistant" }}<|Assistant|>
# {{- if and $.IsThinkSet (and $last .Thinking) -}}
# <think>
# {{ .Thinking }}
# </think>
# {{- end }}{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}
# {{- end }}
# {{- if and $last (ne .Role "assistant") }}<|Assistant|>
# {{- if and $.IsThinkSet (not $.Think) -}}
# <think>
# </think>
# {{ end }}
# {{- end -}}
# {{- end }}"""
TEMPLATE """{{- if .System }}{{ .System }}{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1}}
{{- if eq .Role "user" }}<|User|>{{ .Content }}
{{- else if eq .Role "assistant" }}
{{- if .Content }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}
{{- else if .ToolCalls }}<|Assistant|><|tool▁calls▁begin|>
{{- range $j, $tool := .ToolCalls }}<|tool▁call▁begin|>{{ $tool.Type }}<|tool▁sep|>{{ $tool.Function.Name }}
```json
{{ $tool.Function.Arguments }}
```<|tool▁call▁end|>{{- end }}<|tool▁calls▁end|><|end▁of▁sentence|>
{{- end }}
{{- else if eq .Role "tool" }}{{- if eq $i 0 }}<|tool▁outputs▁begin|>{{- end }}<|tool▁output▁begin|>{{ .Content }}<|tool▁output▁end|>
{{- if $last }}<|tool▁outputs▁end|>{{- end }}
{{- end }}
{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}
{{- end }}"""
### SAMPLING ###
## min_p sampling (comment out temp and top_p above if using)
### min_p sampling ##
# min_p works best with a bit of temperature
# PARAMETER temperature 0.2
# # # 1.0 disables top_p, so we can use min_p
# PARAMETER top_p 1.0
# PARAMETER min_p 0.9
### min_p sampling ##