feat(guesser): identify gemma models (#2561)

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-06-13 19:12:37 +02:00 committed by GitHub
parent 7b205510f9
commit 8f952d90b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ package config
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"strings"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
@ -18,6 +19,7 @@ const (
Phi3 Phi3
ChatML ChatML
Mistral03 Mistral03
Gemma
) )
type settingsConfig struct { type settingsConfig struct {
@ -27,6 +29,14 @@ type settingsConfig struct {
// default settings to adopt with a given model family // default settings to adopt with a given model family
var defaultsSettings map[familyType]settingsConfig = map[familyType]settingsConfig{ var defaultsSettings map[familyType]settingsConfig = map[familyType]settingsConfig{
Gemma: {
StopWords: []string{"<|im_end|>", "<end_of_turn>", "<start_of_turn>"},
TemplateConfig: TemplateConfig{
Chat: "{{.Input }}\n<|start_of_turn|>model\n",
ChatMessage: "<|start_of_turn|>{{if eq .RoleName \"assistant\" }}model{{else}}{{ .RoleName }}{{end}}\n{{ if .Content -}}\n{{.Content -}}\n{{ end -}}<|end_of_turn|>",
Completion: "{{.Input}}",
},
},
LLaMa3: { LLaMa3: {
StopWords: []string{"<|eot_id|>"}, StopWords: []string{"<|eot_id|>"},
TemplateConfig: TemplateConfig{ TemplateConfig: TemplateConfig{
@ -197,8 +207,11 @@ func identifyFamily(f *gguf.GGUFFile) familyType {
commandR := arch == "command-r" && eosTokenID == 255001 commandR := arch == "command-r" && eosTokenID == 255001
qwen2 := arch == "qwen2" qwen2 := arch == "qwen2"
phi3 := arch == "phi-3" phi3 := arch == "phi-3"
gemma := strings.HasPrefix(f.Model().Name, "gemma")
switch { switch {
case gemma:
return Gemma
case llama3: case llama3:
return LLaMa3 return LLaMa3
case commandR: case commandR: