update named templates
This commit is contained in:
parent
326363b3a7
commit
fb6cbc02fb
75 changed files with 611 additions and 27 deletions
3
go.mod
3
go.mod
|
@ -18,6 +18,7 @@ require (
|
||||||
require (
|
require (
|
||||||
github.com/agnivade/levenshtein v1.1.1
|
github.com/agnivade/levenshtein v1.1.1
|
||||||
github.com/d4l3k/go-bfloat16 v0.0.0-20211005043715-690c3bdd05f1
|
github.com/d4l3k/go-bfloat16 v0.0.0-20211005043715-690c3bdd05f1
|
||||||
|
github.com/google/go-cmp v0.6.0
|
||||||
github.com/mattn/go-runewidth v0.0.14
|
github.com/mattn/go-runewidth v0.0.14
|
||||||
github.com/nlpodyssey/gopickle v0.3.0
|
github.com/nlpodyssey/gopickle v0.3.0
|
||||||
github.com/pdevine/tensor v0.0.0-20240510204454-f88f4562727c
|
github.com/pdevine/tensor v0.0.0-20240510204454-f88f4562727c
|
||||||
|
@ -71,7 +72,7 @@ require (
|
||||||
golang.org/x/net v0.25.0 // indirect
|
golang.org/x/net v0.25.0 // indirect
|
||||||
golang.org/x/sys v0.20.0
|
golang.org/x/sys v0.20.0
|
||||||
golang.org/x/term v0.20.0
|
golang.org/x/term v0.20.0
|
||||||
golang.org/x/text v0.15.0 // indirect
|
golang.org/x/text v0.15.0
|
||||||
google.golang.org/protobuf v1.34.1
|
google.golang.org/protobuf v1.34.1
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
|
@ -545,9 +545,9 @@ func TestCreateDetectTemplate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
checkFileExists(t, filepath.Join(p, "blobs", "*"), []string{
|
checkFileExists(t, filepath.Join(p, "blobs", "*"), []string{
|
||||||
filepath.Join(p, "blobs", "sha256-2f8e594e6f34b1b4d36a246628eeb3365ce442303d656f1fcc69e821722acea0"),
|
|
||||||
filepath.Join(p, "blobs", "sha256-542b217f179c7825eeb5bca3c77d2b75ed05bafbd3451d9188891a60a85337c6"),
|
|
||||||
filepath.Join(p, "blobs", "sha256-553c4a3f747b3d22a4946875f1cc8ed011c2930d83f864a0c7265f9ec0a20413"),
|
filepath.Join(p, "blobs", "sha256-553c4a3f747b3d22a4946875f1cc8ed011c2930d83f864a0c7265f9ec0a20413"),
|
||||||
|
filepath.Join(p, "blobs", "sha256-9512c372dfc7d84d6065b8dd2b601aeed8cc1a78e7a7aa784a42fff37f5524b7"),
|
||||||
|
filepath.Join(p, "blobs", "sha256-b8b78cb8c6eefd14c06f1af042e6161255bf87bbf2dd14fce57cdac893db8139"),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1 +1,8 @@
|
||||||
{{ if .System }}<start_system>{{ .System }}<end_message>{{ end }}{{ if .Prompt }}<start_user>{{ .Prompt }}<end_message>{{ end }}<start_assistant>{{ .Response }}<end_message>
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}<start_system>{{ .System }}<end_message>
|
||||||
|
{{- end }}
|
||||||
|
{{- range .Messages }}<start_{{ .Role }}>{{ .Content }}<end_message>
|
||||||
|
{{- end }}<start_assistant>
|
||||||
|
{{- else }}
|
||||||
|
{{ if .System }}<start_system>{{ .System }}<end_message>{{ end }}{{ if .Prompt }}<start_user>{{ .Prompt }}<end_message>{{ end }}<start_assistant>{{ .Response }}<end_message>
|
||||||
|
{{- end }}
|
|
@ -1,7 +1,19 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}{{ .System }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range .Messages }}
|
||||||
|
{{- if eq .Role "user" }}### Instruction:
|
||||||
|
{{- else if eq .Role "assistant" }}### Response:
|
||||||
|
{{- end }}
|
||||||
|
{{ .Content }}
|
||||||
|
|
||||||
|
{{ end }}### Response:
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}{{ .System }}
|
{{ if .System }}{{ .System }}
|
||||||
|
|
||||||
{{ end }}{{ if .Prompt }}### Instruction:
|
{{ end }}{{ if .Prompt }}### Instruction:
|
||||||
{{ .Prompt }}
|
{{ .Prompt }}
|
||||||
|
|
||||||
{{ end }}### Response:
|
{{ end }}### Response:
|
||||||
{{ .Response }}
|
{{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1,6 +1,15 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}<|im_start|>system
|
||||||
|
{{ .System }}<|im_end|>
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}<|im_start|>{{ .Role }}
|
||||||
|
{{ .Content }}<|im_end|>
|
||||||
|
{{ end }}<|im_start|>assistant
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}<|im_start|>system
|
{{ if .System }}<|im_start|>system
|
||||||
{{ .System }}<|im_end|>
|
{{ .System }}<|im_end|>
|
||||||
{{ end }}{{ if .Prompt }}<|im_start|>user
|
{{ end }}{{ if .Prompt }}<|im_start|>user
|
||||||
{{ .Prompt }}<|im_end|>
|
{{ .Prompt }}<|im_end|>
|
||||||
{{ end }}<|im_start|>assistant
|
{{ end }}<|im_start|>assistant
|
||||||
{{ .Response }}<|im_end|>
|
{{ .Response }}<|im_end|>
|
||||||
|
{{- end }}
|
|
@ -1,5 +1,17 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}System: {{ .System }}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}
|
||||||
|
{{- if eq .Role "user" }}User:
|
||||||
|
{{- else if eq .Role "assistant" }}Assistant:
|
||||||
|
{{- end }} {{ .Content }}
|
||||||
|
|
||||||
|
{{ end }}Assistant:
|
||||||
|
{{- else }}
|
||||||
{{ if .System }}System: {{ .System }}
|
{{ if .System }}System: {{ .System }}
|
||||||
|
|
||||||
{{ end }}{{ if .Prompt }}User: {{ .Prompt }}
|
{{ end }}{{ if .Prompt }}User: {{ .Prompt }}
|
||||||
|
|
||||||
{{ end }}Assistant: <|begin_of_text|>{{ .Response }}
|
{{ end }}Assistant: <|begin_of_text|>{{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1,3 +1,13 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}Source: system
|
||||||
|
|
||||||
|
{{ .System }} <step> {{ end }}
|
||||||
|
{{- range .Messages }}Source: {{ .Role }}
|
||||||
|
|
||||||
|
{{ .Content }} <step> {{ end }}Source: assistant
|
||||||
|
Destination: user
|
||||||
|
|
||||||
|
{{ else }}
|
||||||
{{ if .System }} Source: system
|
{{ if .System }} Source: system
|
||||||
|
|
||||||
{{ .System }} <step>{{ end }} Source: user
|
{{ .System }} <step>{{ end }} Source: user
|
||||||
|
@ -5,4 +15,5 @@
|
||||||
{{ .Prompt }} <step> Source: assistant
|
{{ .Prompt }} <step> Source: assistant
|
||||||
Destination: user
|
Destination: user
|
||||||
|
|
||||||
{{ .Response }}<step>
|
{{ .Response }}<step>
|
||||||
|
{{- end }}
|
|
@ -1,3 +1,13 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}System: {{ .System }}
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}
|
||||||
|
{{- if eq .Role "user" }}User:
|
||||||
|
{{ else if eq .Role "assistant" }}Falcon:
|
||||||
|
{{ end }}{{ .Content }}
|
||||||
|
{{ end }}Falcon:
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}{{ .System }}
|
{{ if .System }}{{ .System }}
|
||||||
{{ end }}{{ if .Prompt }}User: {{ .Prompt }}
|
{{ end }}{{ if .Prompt }}User: {{ .Prompt }}
|
||||||
{{ end }}Assistant: {{ .Response }}
|
{{ end }}Assistant: {{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1,4 +1,16 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- range $index, $_ := .Messages }}<start_of_turn>
|
||||||
|
{{- if eq .Role "user" }}user
|
||||||
|
{{- if and $.System (eq $index 0) }}
|
||||||
|
{{ $.System }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else if eq .Role "assistant" }}model
|
||||||
|
{{- end }}
|
||||||
|
{{ .Content }}<end_of_turn>
|
||||||
|
{{ end }}<start_of_turn>model
|
||||||
|
{{ else }}
|
||||||
<start_of_turn>user
|
<start_of_turn>user
|
||||||
{{ if .System }}{{ .System }} {{ end }}{{ .Prompt }}<end_of_turn>
|
{{ if .System }}{{ .System }} {{ end }}{{ .Prompt }}<end_of_turn>
|
||||||
<start_of_turn>model
|
<start_of_turn>model
|
||||||
{{ .Response }}<end_of_turn>
|
{{ .Response }}<end_of_turn>
|
||||||
|
{{- end }}
|
|
@ -1,3 +1,16 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}System:
|
||||||
|
{{ .System }}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}
|
||||||
|
{{- if eq .Role "user" }}Question:
|
||||||
|
{{- else if eq .Role "assistant" }}Answer:
|
||||||
|
{{- end }}
|
||||||
|
{{ .Content }}
|
||||||
|
|
||||||
|
{{ end }}Answer:
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}
|
{{ if .System }}
|
||||||
System:
|
System:
|
||||||
{{ .System }}
|
{{ .System }}
|
||||||
|
@ -6,4 +19,5 @@ System:
|
||||||
{{ .Prompt }}
|
{{ .Prompt }}
|
||||||
|
|
||||||
{{ end }}Answer:
|
{{ end }}Answer:
|
||||||
{{ .Response }}
|
{{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1,3 +1,16 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- range $index, $_ := .Messages }}
|
||||||
|
{{- if eq .Role "user" }}[INST] {{ if eq $index 0 }}<<SYS>>
|
||||||
|
{{- if $.System }}
|
||||||
|
{{ $.System }}
|
||||||
|
{{ end }}<</SYS>>
|
||||||
|
|
||||||
|
{{ end }}{{ .Content }}
|
||||||
|
{{- else }} [/INST] {{ .Content }}</s><s>
|
||||||
|
{{- end }}
|
||||||
|
{{- end }} [/INST]
|
||||||
|
{{- else }}
|
||||||
[INST] <<SYS>>{{ .System }}<</SYS>>
|
[INST] <<SYS>>{{ .System }}<</SYS>>
|
||||||
|
|
||||||
{{ .Prompt }} [/INST] {{ .Response }}
|
{{ .Prompt }} [/INST] {{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1,7 +1,19 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}<|start_header_id|>system<|end_header_id|>
|
||||||
|
|
||||||
|
{{ .System }}<|eot_id|>
|
||||||
|
{{- end }}
|
||||||
|
{{- range .Messages }}<|start_header_id|>{{ .Role }}<|end_header_id|>
|
||||||
|
|
||||||
|
{{ .Content }}<|eot_id|>
|
||||||
|
{{- end }}<|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}<|start_header_id|>system<|end_header_id|>
|
{{ if .System }}<|start_header_id|>system<|end_header_id|>
|
||||||
|
|
||||||
{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
|
{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
|
||||||
|
|
||||||
{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
|
{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
{{ .Response }}<|eot_id|>
|
{{ .Response }}<|eot_id|>
|
||||||
|
{{- end }}
|
|
@ -1,7 +1,20 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}{{ .System }}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}
|
||||||
|
{{- if eq .Role "user" }}@@ Instruction
|
||||||
|
{{- else if eq .Role "assistant" }}@@ Response
|
||||||
|
{{- end }}
|
||||||
|
{{ .Content }}
|
||||||
|
|
||||||
|
{{ end }}@@ Response
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}{{ .System }}
|
{{ if .System }}{{ .System }}
|
||||||
|
|
||||||
{{ end }}{{ if .Prompt }}@@ Instruction
|
{{ end }}{{ if .Prompt }}@@ Instruction
|
||||||
{{ .Prompt }}
|
{{ .Prompt }}
|
||||||
|
|
||||||
{{ end }}@@ Response
|
{{ end }}@@ Response
|
||||||
{{ .Response }}
|
{{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1,6 +1,9 @@
|
||||||
{{ if .System }}<|im_start|>system
|
{{- if .Messages }}
|
||||||
{{ .System }}<|im_end|>
|
{{- range $index, $_ := .Messages }}
|
||||||
{{ end }}{{ if .Prompt }}<|im_start|>user
|
{{- if eq .Role "user" }}[INST] {{ if and $.System (eq (len (slice $.Messages $index)) 1) }}{{ $.System }}
|
||||||
{{ .Prompt }}<|im_end|>
|
{{ end }}{{ .Content }}
|
||||||
{{ end }}<|im_start|>assistant
|
{{- else if eq .Role "assistant" }}[/INST] {{ .Content }}</s>
|
||||||
{{ .Response }}<|im_end|>
|
{{- end }}
|
||||||
|
{{- end }}[/INST]
|
||||||
|
{{- else }}[INST] {{ if .System }}{{ .System }} {{ end }}{{ .Prompt }} [/INST] {{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1 +1,11 @@
|
||||||
{{ .System }}<|end_of_turn|>GPT4 Correct User: {{ .Prompt }}<|end_of_turn|>GPT4 Correct Assistant: {{ .Response }}<|end_of_turn|>
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}GPT Correct System: {{ .System }}<|end_of_turn|>
|
||||||
|
{{- end }}
|
||||||
|
{{- range .Messages }}GPT Correct
|
||||||
|
{{- if eq .Role "user" }} User:
|
||||||
|
{{- else if eq .Role "assistant" }} Assistant:
|
||||||
|
{{- end }} {{ .Content }}<|end_of_turn|>
|
||||||
|
{{- end }}GPT Correct Assistant:
|
||||||
|
{{- else }}
|
||||||
|
{{ .System }}<|end_of_turn|>GPT4 Correct User: {{ .Prompt }}<|end_of_turn|>GPT4 Correct Assistant: {{ .Response }}<|end_of_turn|>
|
||||||
|
{{- end }}
|
|
@ -1,6 +1,15 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}<|system|>
|
||||||
|
{{ .System }}<|end|>
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}<|{{ .Role }}|>
|
||||||
|
{{ .Content }}<|end|>
|
||||||
|
{{ end }}<|assistant|>
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}<|system|>
|
{{ if .System }}<|system|>
|
||||||
{{ .System }}<|end|>
|
{{ .System }}<|end|>
|
||||||
{{ end }}{{ if .Prompt }}<|user|>
|
{{ end }}{{ if .Prompt }}<|user|>
|
||||||
{{ .Prompt }}<|end|>
|
{{ .Prompt }}<|end|>
|
||||||
{{ end }}<|assistant|>
|
{{ end }}<|assistant|>
|
||||||
{{ .Response }}<|end|>
|
{{ .Response }}<|end|>
|
||||||
|
{{- end }}
|
|
@ -1,3 +1,16 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}### System:
|
||||||
|
{{ .System }}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}
|
||||||
|
{{- if eq .Role "user" }}### User:
|
||||||
|
{{ .Content }}
|
||||||
|
{{ else if eq .Role "assistant" }}### Assistant:
|
||||||
|
{{ .Content }}</s>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}### Assistant:
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}### System:
|
{{ if .System }}### System:
|
||||||
{{ .System }}
|
{{ .System }}
|
||||||
|
|
||||||
|
@ -5,4 +18,5 @@
|
||||||
{{ .Prompt }}
|
{{ .Prompt }}
|
||||||
|
|
||||||
{{ end }}### Assistant:
|
{{ end }}### Assistant:
|
||||||
{{ .Response }}
|
{{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1,3 +1,17 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}{{ .System }}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}
|
||||||
|
{{- if eq .Role "user" }}### Instruction
|
||||||
|
{{ .Content }}
|
||||||
|
|
||||||
|
{{ else if eq .Role "assistant" }}### Response
|
||||||
|
{{ .Content }}<|endoftext|>
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
{{- end }}### Response
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}{{ .System }}
|
{{ if .System }}{{ .System }}
|
||||||
|
|
||||||
{{ end }}{{ if .Prompt }}### Instruction
|
{{ end }}{{ if .Prompt }}### Instruction
|
||||||
|
@ -7,3 +21,4 @@
|
||||||
{{ end }}### Response
|
{{ end }}### Response
|
||||||
{{ .Response }}<|endoftext|>
|
{{ .Response }}<|endoftext|>
|
||||||
|
|
||||||
|
{{- end }}
|
|
@ -8,9 +8,10 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"text/template"
|
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/ollama/ollama/api"
|
"github.com/ollama/ollama/api"
|
||||||
"github.com/ollama/ollama/llm"
|
"github.com/ollama/ollama/llm"
|
||||||
)
|
)
|
||||||
|
@ -47,7 +48,7 @@ func TestNamed(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.New(s).Parse(b.String())
|
tmpl, err := Parse(b.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -60,6 +61,70 @@ func TestNamed(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTemplate(t *testing.T) {
|
||||||
|
cases := make(map[string][]api.Message)
|
||||||
|
for _, mm := range [][]api.Message{
|
||||||
|
{
|
||||||
|
{Role: "user", Content: "Hello, how are you?"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{Role: "user", Content: "Hello, how are you?"},
|
||||||
|
{Role: "assistant", Content: "I'm doing great. How can I help you today?"},
|
||||||
|
{Role: "user", Content: "I'd like to show off how chat templating works!"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{Role: "system", Content: "You are a helpful assistant."},
|
||||||
|
{Role: "user", Content: "Hello, how are you?"},
|
||||||
|
{Role: "assistant", Content: "I'm doing great. How can I help you today?"},
|
||||||
|
{Role: "user", Content: "I'd like to show off how chat templating works!"},
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
var roles []string
|
||||||
|
for _, m := range mm {
|
||||||
|
roles = append(roles, m.Role)
|
||||||
|
}
|
||||||
|
|
||||||
|
cases[strings.Join(roles, "-")] = mm
|
||||||
|
}
|
||||||
|
|
||||||
|
matches, err := filepath.Glob("*.gotmpl")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, match := range matches {
|
||||||
|
t.Run(match, func(t *testing.T) {
|
||||||
|
bts, err := os.ReadFile(match)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpl, err := Parse(string(bts))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for n, tt := range cases {
|
||||||
|
t.Run(n, func(t *testing.T) {
|
||||||
|
var actual bytes.Buffer
|
||||||
|
if err := tmpl.Execute(&actual, Values{Messages: tt}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expect, err := os.ReadFile(filepath.Join("testdata", match, n))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if diff := cmp.Diff(actual.Bytes(), expect); diff != "" {
|
||||||
|
t.Errorf("mismatch (-got +want):\n%s", diff)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
func TestParse(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
template string
|
template string
|
||||||
|
|
1
template/testdata/alfred.gotmpl/system-user-assistant-user
vendored
Normal file
1
template/testdata/alfred.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<start_system>You are a helpful assistant.<end_message><start_user>Hello, how are you?<end_message><start_assistant>I'm doing great. How can I help you today?<end_message><start_user>I'd like to show off how chat templating works!<end_message><start_assistant>
|
1
template/testdata/alfred.gotmpl/user
vendored
Normal file
1
template/testdata/alfred.gotmpl/user
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<start_user>Hello, how are you?<end_message><start_assistant>
|
1
template/testdata/alfred.gotmpl/user-assistant-user
vendored
Normal file
1
template/testdata/alfred.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<start_user>Hello, how are you?<end_message><start_assistant>I'm doing great. How can I help you today?<end_message><start_user>I'd like to show off how chat templating works!<end_message><start_assistant>
|
10
template/testdata/alpaca.gotmpl/system-user-assistant-user
vendored
Normal file
10
template/testdata/alpaca.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
You are a helpful assistant.### Instruction:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Response:
|
||||||
|
I'm doing great. How can I help you today?
|
||||||
|
|
||||||
|
### Instruction:
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
### Response:
|
4
template/testdata/alpaca.gotmpl/user
vendored
Normal file
4
template/testdata/alpaca.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
### Instruction:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Response:
|
10
template/testdata/alpaca.gotmpl/user-assistant-user
vendored
Normal file
10
template/testdata/alpaca.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
### Instruction:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Response:
|
||||||
|
I'm doing great. How can I help you today?
|
||||||
|
|
||||||
|
### Instruction:
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
### Response:
|
9
template/testdata/chatml.gotmpl/system-user-assistant-user
vendored
Normal file
9
template/testdata/chatml.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<|im_start|>system
|
||||||
|
You are a helpful assistant.<|im_end|>
|
||||||
|
<|im_start|>user
|
||||||
|
Hello, how are you?<|im_end|>
|
||||||
|
<|im_start|>assistant
|
||||||
|
I'm doing great. How can I help you today?<|im_end|>
|
||||||
|
<|im_start|>user
|
||||||
|
I'd like to show off how chat templating works!<|im_end|>
|
||||||
|
<|im_start|>assistant
|
3
template/testdata/chatml.gotmpl/user
vendored
Normal file
3
template/testdata/chatml.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<|im_start|>user
|
||||||
|
Hello, how are you?<|im_end|>
|
||||||
|
<|im_start|>assistant
|
7
template/testdata/chatml.gotmpl/user-assistant-user
vendored
Normal file
7
template/testdata/chatml.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<|im_start|>user
|
||||||
|
Hello, how are you?<|im_end|>
|
||||||
|
<|im_start|>assistant
|
||||||
|
I'm doing great. How can I help you today?<|im_end|>
|
||||||
|
<|im_start|>user
|
||||||
|
I'd like to show off how chat templating works!<|im_end|>
|
||||||
|
<|im_start|>assistant
|
9
template/testdata/chatqa.gotmpl/system-user-assistant-user
vendored
Normal file
9
template/testdata/chatqa.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
System: You are a helpful assistant.
|
||||||
|
|
||||||
|
User: Hello, how are you?
|
||||||
|
|
||||||
|
Assistant: I'm doing great. How can I help you today?
|
||||||
|
|
||||||
|
User: I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
Assistant:
|
3
template/testdata/chatqa.gotmpl/user
vendored
Normal file
3
template/testdata/chatqa.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
User: Hello, how are you?
|
||||||
|
|
||||||
|
Assistant:
|
7
template/testdata/chatqa.gotmpl/user-assistant-user
vendored
Normal file
7
template/testdata/chatqa.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
User: Hello, how are you?
|
||||||
|
|
||||||
|
Assistant: I'm doing great. How can I help you today?
|
||||||
|
|
||||||
|
User: I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
Assistant:
|
11
template/testdata/codellama-70b-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
11
template/testdata/codellama-70b-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Source: system
|
||||||
|
|
||||||
|
You are a helpful assistant. <step> Source: user
|
||||||
|
|
||||||
|
Hello, how are you? <step> Source: assistant
|
||||||
|
|
||||||
|
I'm doing great. How can I help you today? <step> Source: user
|
||||||
|
|
||||||
|
I'd like to show off how chat templating works! <step> Source: assistant
|
||||||
|
Destination: user
|
||||||
|
|
5
template/testdata/codellama-70b-instruct.gotmpl/user
vendored
Normal file
5
template/testdata/codellama-70b-instruct.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Source: user
|
||||||
|
|
||||||
|
Hello, how are you? <step> Source: assistant
|
||||||
|
Destination: user
|
||||||
|
|
9
template/testdata/codellama-70b-instruct.gotmpl/user-assistant-user
vendored
Normal file
9
template/testdata/codellama-70b-instruct.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Source: user
|
||||||
|
|
||||||
|
Hello, how are you? <step> Source: assistant
|
||||||
|
|
||||||
|
I'm doing great. How can I help you today? <step> Source: user
|
||||||
|
|
||||||
|
I'd like to show off how chat templating works! <step> Source: assistant
|
||||||
|
Destination: user
|
||||||
|
|
8
template/testdata/falcon-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
8
template/testdata/falcon-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
System: You are a helpful assistant.
|
||||||
|
User:
|
||||||
|
Hello, how are you?
|
||||||
|
Falcon:
|
||||||
|
I'm doing great. How can I help you today?
|
||||||
|
User:
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
Falcon:
|
3
template/testdata/falcon-instruct.gotmpl/user
vendored
Normal file
3
template/testdata/falcon-instruct.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
User:
|
||||||
|
Hello, how are you?
|
||||||
|
Falcon:
|
7
template/testdata/falcon-instruct.gotmpl/user-assistant-user
vendored
Normal file
7
template/testdata/falcon-instruct.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
User:
|
||||||
|
Hello, how are you?
|
||||||
|
Falcon:
|
||||||
|
I'm doing great. How can I help you today?
|
||||||
|
User:
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
Falcon:
|
8
template/testdata/gemma-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
8
template/testdata/gemma-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<start_of_turn>user
|
||||||
|
You are a helpful assistant.
|
||||||
|
Hello, how are you?<end_of_turn>
|
||||||
|
<start_of_turn>model
|
||||||
|
I'm doing great. How can I help you today?<end_of_turn>
|
||||||
|
<start_of_turn>user
|
||||||
|
I'd like to show off how chat templating works!<end_of_turn>
|
||||||
|
<start_of_turn>model
|
3
template/testdata/gemma-instruct.gotmpl/user
vendored
Normal file
3
template/testdata/gemma-instruct.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<start_of_turn>user
|
||||||
|
Hello, how are you?<end_of_turn>
|
||||||
|
<start_of_turn>model
|
7
template/testdata/gemma-instruct.gotmpl/user-assistant-user
vendored
Normal file
7
template/testdata/gemma-instruct.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<start_of_turn>user
|
||||||
|
Hello, how are you?<end_of_turn>
|
||||||
|
<start_of_turn>model
|
||||||
|
I'm doing great. How can I help you today?<end_of_turn>
|
||||||
|
<start_of_turn>user
|
||||||
|
I'd like to show off how chat templating works!<end_of_turn>
|
||||||
|
<start_of_turn>model
|
13
template/testdata/granite-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
13
template/testdata/granite-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
System:
|
||||||
|
You are a helpful assistant.
|
||||||
|
|
||||||
|
Question:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
Answer:
|
||||||
|
I'm doing great. How can I help you today?
|
||||||
|
|
||||||
|
Question:
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
Answer:
|
4
template/testdata/granite-instruct.gotmpl/user
vendored
Normal file
4
template/testdata/granite-instruct.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Question:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
Answer:
|
10
template/testdata/granite-instruct.gotmpl/user-assistant-user
vendored
Normal file
10
template/testdata/granite-instruct.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Question:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
Answer:
|
||||||
|
I'm doing great. How can I help you today?
|
||||||
|
|
||||||
|
Question:
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
Answer:
|
5
template/testdata/llama2-chat.gotmpl/system-user-assistant-user
vendored
Normal file
5
template/testdata/llama2-chat.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[INST] <<SYS>>
|
||||||
|
You are a helpful assistant.
|
||||||
|
<</SYS>>
|
||||||
|
|
||||||
|
Hello, how are you? [/INST] I'm doing great. How can I help you today?</s><s>[INST] I'd like to show off how chat templating works! [/INST]
|
3
template/testdata/llama2-chat.gotmpl/user
vendored
Normal file
3
template/testdata/llama2-chat.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[INST] <<SYS>><</SYS>>
|
||||||
|
|
||||||
|
Hello, how are you? [/INST]
|
3
template/testdata/llama2-chat.gotmpl/user-assistant-user
vendored
Normal file
3
template/testdata/llama2-chat.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[INST] <<SYS>><</SYS>>
|
||||||
|
|
||||||
|
Hello, how are you? [/INST] I'm doing great. How can I help you today?</s><s>[INST] I'd like to show off how chat templating works! [/INST]
|
10
template/testdata/llama3-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
10
template/testdata/llama3-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<|start_header_id|>system<|end_header_id|>
|
||||||
|
|
||||||
|
You are a helpful assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>
|
||||||
|
|
||||||
|
Hello, how are you?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
|
I'm doing great. How can I help you today?<|eot_id|><|start_header_id|>user<|end_header_id|>
|
||||||
|
|
||||||
|
I'd like to show off how chat templating works!<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
4
template/testdata/llama3-instruct.gotmpl/user
vendored
Normal file
4
template/testdata/llama3-instruct.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<|start_header_id|>user<|end_header_id|>
|
||||||
|
|
||||||
|
Hello, how are you?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
8
template/testdata/llama3-instruct.gotmpl/user-assistant-user
vendored
Normal file
8
template/testdata/llama3-instruct.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<|start_header_id|>user<|end_header_id|>
|
||||||
|
|
||||||
|
Hello, how are you?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
|
I'm doing great. How can I help you today?<|eot_id|><|start_header_id|>user<|end_header_id|>
|
||||||
|
|
||||||
|
I'd like to show off how chat templating works!<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
12
template/testdata/magicoder.gotmpl/system-user-assistant-user
vendored
Normal file
12
template/testdata/magicoder.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
You are a helpful assistant.
|
||||||
|
|
||||||
|
@@ Instruction
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
@@ Response
|
||||||
|
I'm doing great. How can I help you today?
|
||||||
|
|
||||||
|
@@ Instruction
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
@@ Response
|
4
template/testdata/magicoder.gotmpl/user
vendored
Normal file
4
template/testdata/magicoder.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
@@ Instruction
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
@@ Response
|
10
template/testdata/magicoder.gotmpl/user-assistant-user
vendored
Normal file
10
template/testdata/magicoder.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
@@ Instruction
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
@@ Response
|
||||||
|
I'm doing great. How can I help you today?
|
||||||
|
|
||||||
|
@@ Instruction
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
@@ Response
|
2
template/testdata/mistral-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
2
template/testdata/mistral-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[INST] Hello, how are you?[/INST] I'm doing great. How can I help you today?</s>[INST] You are a helpful assistant.
|
||||||
|
I'd like to show off how chat templating works![/INST]
|
1
template/testdata/mistral-instruct.gotmpl/user
vendored
Normal file
1
template/testdata/mistral-instruct.gotmpl/user
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[INST] Hello, how are you?[/INST]
|
1
template/testdata/mistral-instruct.gotmpl/user-assistant-user
vendored
Normal file
1
template/testdata/mistral-instruct.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[INST] Hello, how are you?[/INST] I'm doing great. How can I help you today?</s>[INST] I'd like to show off how chat templating works![/INST]
|
1
template/testdata/openchat.gotmpl/system-user-assistant-user
vendored
Normal file
1
template/testdata/openchat.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
GPT Correct System: You are a helpful assistant.<|end_of_turn|>GPT Correct User: Hello, how are you?<|end_of_turn|>GPT Correct Assistant: I'm doing great. How can I help you today?<|end_of_turn|>GPT Correct User: I'd like to show off how chat templating works!<|end_of_turn|>GPT Correct Assistant:
|
1
template/testdata/openchat.gotmpl/user
vendored
Normal file
1
template/testdata/openchat.gotmpl/user
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
GPT Correct User: Hello, how are you?<|end_of_turn|>GPT Correct Assistant:
|
1
template/testdata/openchat.gotmpl/user-assistant-user
vendored
Normal file
1
template/testdata/openchat.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
GPT Correct User: Hello, how are you?<|end_of_turn|>GPT Correct Assistant: I'm doing great. How can I help you today?<|end_of_turn|>GPT Correct User: I'd like to show off how chat templating works!<|end_of_turn|>GPT Correct Assistant:
|
9
template/testdata/phi-3.gotmpl/system-user-assistant-user
vendored
Normal file
9
template/testdata/phi-3.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<|system|>
|
||||||
|
You are a helpful assistant.<|end|>
|
||||||
|
<|user|>
|
||||||
|
Hello, how are you?<|end|>
|
||||||
|
<|assistant|>
|
||||||
|
I'm doing great. How can I help you today?<|end|>
|
||||||
|
<|user|>
|
||||||
|
I'd like to show off how chat templating works!<|end|>
|
||||||
|
<|assistant|>
|
3
template/testdata/phi-3.gotmpl/user
vendored
Normal file
3
template/testdata/phi-3.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<|user|>
|
||||||
|
Hello, how are you?<|end|>
|
||||||
|
<|assistant|>
|
7
template/testdata/phi-3.gotmpl/user-assistant-user
vendored
Normal file
7
template/testdata/phi-3.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<|user|>
|
||||||
|
Hello, how are you?<|end|>
|
||||||
|
<|assistant|>
|
||||||
|
I'm doing great. How can I help you today?<|end|>
|
||||||
|
<|user|>
|
||||||
|
I'd like to show off how chat templating works!<|end|>
|
||||||
|
<|assistant|>
|
13
template/testdata/solar-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
13
template/testdata/solar-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
### System:
|
||||||
|
You are a helpful assistant.
|
||||||
|
|
||||||
|
### User:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Assistant:
|
||||||
|
I'm doing great. How can I help you today?</s>
|
||||||
|
|
||||||
|
### User:
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
### Assistant:
|
4
template/testdata/solar-instruct.gotmpl/user
vendored
Normal file
4
template/testdata/solar-instruct.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
### User:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Assistant:
|
10
template/testdata/solar-instruct.gotmpl/user-assistant-user
vendored
Normal file
10
template/testdata/solar-instruct.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
### User:
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Assistant:
|
||||||
|
I'm doing great. How can I help you today?</s>
|
||||||
|
|
||||||
|
### User:
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
### Assistant:
|
12
template/testdata/starcoder2-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
12
template/testdata/starcoder2-instruct.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
You are a helpful assistant.
|
||||||
|
|
||||||
|
### Instruction
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Response
|
||||||
|
I'm doing great. How can I help you today?<|endoftext|>
|
||||||
|
|
||||||
|
### Instruction
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
### Response
|
4
template/testdata/starcoder2-instruct.gotmpl/user
vendored
Normal file
4
template/testdata/starcoder2-instruct.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
### Instruction
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Response
|
10
template/testdata/starcoder2-instruct.gotmpl/user-assistant-user
vendored
Normal file
10
template/testdata/starcoder2-instruct.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
### Instruction
|
||||||
|
Hello, how are you?
|
||||||
|
|
||||||
|
### Response
|
||||||
|
I'm doing great. How can I help you today?<|endoftext|>
|
||||||
|
|
||||||
|
### Instruction
|
||||||
|
I'd like to show off how chat templating works!
|
||||||
|
|
||||||
|
### Response
|
6
template/testdata/vicuna.gotmpl/system-user-assistant-user
vendored
Normal file
6
template/testdata/vicuna.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
You are a helpful assistant.
|
||||||
|
|
||||||
|
USER: Hello, how are you?
|
||||||
|
ASSISTANT: I'm doing great. How can I help you today?</s>
|
||||||
|
USER: I'd like to show off how chat templating works!
|
||||||
|
ASSISTANT:
|
2
template/testdata/vicuna.gotmpl/user
vendored
Normal file
2
template/testdata/vicuna.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
USER: Hello, how are you?
|
||||||
|
ASSISTANT:
|
4
template/testdata/vicuna.gotmpl/user-assistant-user
vendored
Normal file
4
template/testdata/vicuna.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
USER: Hello, how are you?
|
||||||
|
ASSISTANT: I'm doing great. How can I help you today?</s>
|
||||||
|
USER: I'd like to show off how chat templating works!
|
||||||
|
ASSISTANT:
|
9
template/testdata/zephyr.gotmpl/system-user-assistant-user
vendored
Normal file
9
template/testdata/zephyr.gotmpl/system-user-assistant-user
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<|system|>
|
||||||
|
You are a helpful assistant.</s>
|
||||||
|
<|user|>
|
||||||
|
Hello, how are you?</s>
|
||||||
|
<|assistant|>
|
||||||
|
I'm doing great. How can I help you today?</s>
|
||||||
|
<|user|>
|
||||||
|
I'd like to show off how chat templating works!</s>
|
||||||
|
<|assistant|>
|
3
template/testdata/zephyr.gotmpl/user
vendored
Normal file
3
template/testdata/zephyr.gotmpl/user
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<|user|>
|
||||||
|
Hello, how are you?</s>
|
||||||
|
<|assistant|>
|
7
template/testdata/zephyr.gotmpl/user-assistant-user
vendored
Normal file
7
template/testdata/zephyr.gotmpl/user-assistant-user
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<|user|>
|
||||||
|
Hello, how are you?</s>
|
||||||
|
<|assistant|>
|
||||||
|
I'm doing great. How can I help you today?</s>
|
||||||
|
<|user|>
|
||||||
|
I'd like to show off how chat templating works!</s>
|
||||||
|
<|assistant|>
|
|
@ -1,3 +1,14 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}{{ .System }}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}
|
||||||
|
{{- if eq .Role "user" }}USER: {{ .Content }}
|
||||||
|
{{ else if eq .Role "assistant" }}ASSISTANT: {{ .Content }}</s>
|
||||||
|
{{ end }}
|
||||||
|
{{- end }}ASSISTANT:
|
||||||
|
{{- else }}
|
||||||
{{ if .System }}{{ .System }}
|
{{ if .System }}{{ .System }}
|
||||||
{{ end }}{{ if .Prompt }}USER: {{ .Prompt }}
|
{{ end }}{{ if .Prompt }}USER: {{ .Prompt }}
|
||||||
{{ end }}ASSISTANT: {{ .Response }}
|
{{ end }}ASSISTANT: {{ .Response }}
|
||||||
|
{{- end }}
|
|
@ -1,6 +1,15 @@
|
||||||
|
{{- if .Messages }}
|
||||||
|
{{- if .System }}<|system|>
|
||||||
|
{{ .System }}</s>
|
||||||
|
{{ end }}
|
||||||
|
{{- range .Messages }}<|{{ .Role }}|>
|
||||||
|
{{ .Content }}</s>
|
||||||
|
{{ end }}<|assistant|>
|
||||||
|
{{ else }}
|
||||||
{{ if .System }}<|system|>
|
{{ if .System }}<|system|>
|
||||||
{{ .System }}</s>
|
{{ .System }}</s>
|
||||||
{{ end }}{{ if .Prompt }}<|user|>
|
{{ end }}{{ if .Prompt }}<|user|>
|
||||||
{{ .Prompt }}</s>
|
{{ .Prompt }}</s>
|
||||||
{{ end }}<|assistant|>
|
{{ end }}<|assistant|>
|
||||||
{{ .Response }}</s>
|
{{ .Response }}</s>
|
||||||
|
{{- end }}
|
Loading…
Add table
Reference in a new issue