Skip to content

Commit

Permalink
feat: add trimsuffix (#1528)
Browse files Browse the repository at this point in the history
  • Loading branch information
mudler authored Jan 1, 2024
1 parent fd48cb6 commit 85e2767
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
5 changes: 4 additions & 1 deletion api/backend/llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func Finetune(config config.Config, input, prediction string) string {
for _, c := range config.TrimSpace {
prediction = strings.TrimSpace(strings.TrimPrefix(prediction, c))
}
return prediction

for _, c := range config.TrimSuffix {
prediction = strings.TrimSpace(strings.TrimSuffix(prediction, c))
}
return prediction
}
22 changes: 12 additions & 10 deletions api/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,18 @@ type LLMConfig struct {
StopWords []string `yaml:"stopwords"`
Cutstrings []string `yaml:"cutstrings"`
TrimSpace []string `yaml:"trimspace"`
ContextSize int `yaml:"context_size"`
NUMA bool `yaml:"numa"`
LoraAdapter string `yaml:"lora_adapter"`
LoraBase string `yaml:"lora_base"`
LoraScale float32 `yaml:"lora_scale"`
NoMulMatQ bool `yaml:"no_mulmatq"`
DraftModel string `yaml:"draft_model"`
NDraft int32 `yaml:"n_draft"`
Quantization string `yaml:"quantization"`
MMProj string `yaml:"mmproj"`
TrimSuffix []string `yaml:"trimsuffix"`

ContextSize int `yaml:"context_size"`
NUMA bool `yaml:"numa"`
LoraAdapter string `yaml:"lora_adapter"`
LoraBase string `yaml:"lora_base"`
LoraScale float32 `yaml:"lora_scale"`
NoMulMatQ bool `yaml:"no_mulmatq"`
DraftModel string `yaml:"draft_model"`
NDraft int32 `yaml:"n_draft"`
Quantization string `yaml:"quantization"`
MMProj string `yaml:"mmproj"`

RopeScaling string `yaml:"rope_scaling"`
YarnExtFactor float32 `yaml:"yarn_ext_factor"`
Expand Down
2 changes: 2 additions & 0 deletions examples/configurations/phi-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ context_size: 2048
f16: true
gpu_layers: 90
mmap: true
trimsuffix:
- "\n"
parameters:
model: huggingface://TheBloke/phi-2-GGUF/phi-2.Q8_0.gguf
temperature: 0.2
Expand Down

0 comments on commit 85e2767

Please sign in to comment.