DeepSeek R1 Distilled model to one-fourth its original file size—without losing any accuracy.

259 6 weeks ago

c400ee893d53 · 1.9kB
{{- if .System }}{{ .System }}{{- end }}
{{- $isTool := false }}
{{- $isFirstToolCall := false }}
{{- $isOutputFirst := true }}
{{- range $index, $msg := .Messages }}
{{- if eq $msg.Role "user" }}
{{- $isTool = false }}
<|User|>{{ $msg.Content }}
{{- end }}
{{- if eq $msg.Role "assistant" }}
{{- if not $msg.Content }}
{{- $isTool = false }}
{{- range $tool := $msg.ToolCalls }}
{{- if not $isFirstToolCall }}
<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin|>{{ $tool.Function.Name }}
```json
{{ json $tool.Function.Arguments }}
```
<|tool▁call▁end|>
{{- $isFirstToolCall = true }}
{{- else }}
<|tool▁call▁begin|>{{ $tool.Function.Name }}
```json
{{ json $tool.Function.Arguments }}
```
<|tool▁call▁end|><|tool▁calls▁end|><|end▁of▁sentence|>
{{- end }}
{{- end }}
{{- else if $msg.Content }}
{{- if $isTool }}
<|tool▁outputs▁end|>{{ $msg.Content }}<|end▁of▁sentence|>
{{- $isTool = false }}
{{- else }}
<|Assistant|>{{ $msg.Content }}<|end▁of▁sentence|>
{{- end }}
{{- end }}
{{- end }}
{{- if eq $msg.Role "tool" }}
{{- $isTool = true }}
{{- if $isOutputFirst }}
<|tool▁outputs▁begin|><|tool▁output▁begin|>{{ $msg.Content }}<|tool▁output▁end|>
{{- $isOutputFirst = false }}
{{- else }}
<|tool▁output▁begin|>{{ $msg.Content }}<|tool▁output▁end|>
{{- end }}
{{- end }}
{{- end }}
{{- if $isTool }}<|tool▁outputs▁end|>{{- end }}
{{- if and .AddGenerationPrompt (not $isTool) }}<|Assistant|>{{- end }}