Skip to content

Commit f5fa6f1

Browse files
committed
feat: add trimmsuffix
1 parent f068efe commit f5fa6f1

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

api/backend/llm.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ func Finetune(config config.Config, input, prediction string) string {
159159
for _, c := range config.TrimSpace {
160160
prediction = strings.TrimSpace(strings.TrimPrefix(prediction, c))
161161
}
162-
return prediction
163162

163+
for _, c := range config.TrimSuffix {
164+
prediction = strings.TrimSpace(strings.TrimSuffix(prediction, c))
165+
}
166+
return prediction
164167
}

api/config/config.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,18 @@ type LLMConfig struct {
103103
StopWords []string `yaml:"stopwords"`
104104
Cutstrings []string `yaml:"cutstrings"`
105105
TrimSpace []string `yaml:"trimspace"`
106-
ContextSize int `yaml:"context_size"`
107-
NUMA bool `yaml:"numa"`
108-
LoraAdapter string `yaml:"lora_adapter"`
109-
LoraBase string `yaml:"lora_base"`
110-
LoraScale float32 `yaml:"lora_scale"`
111-
NoMulMatQ bool `yaml:"no_mulmatq"`
112-
DraftModel string `yaml:"draft_model"`
113-
NDraft int32 `yaml:"n_draft"`
114-
Quantization string `yaml:"quantization"`
115-
MMProj string `yaml:"mmproj"`
106+
TrimSuffix []string `yaml:"trimsuffix"`
107+
108+
ContextSize int `yaml:"context_size"`
109+
NUMA bool `yaml:"numa"`
110+
LoraAdapter string `yaml:"lora_adapter"`
111+
LoraBase string `yaml:"lora_base"`
112+
LoraScale float32 `yaml:"lora_scale"`
113+
NoMulMatQ bool `yaml:"no_mulmatq"`
114+
DraftModel string `yaml:"draft_model"`
115+
NDraft int32 `yaml:"n_draft"`
116+
Quantization string `yaml:"quantization"`
117+
MMProj string `yaml:"mmproj"`
116118

117119
RopeScaling string `yaml:"rope_scaling"`
118120
YarnExtFactor float32 `yaml:"yarn_ext_factor"`

examples/configurations/phi-2.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ context_size: 2048
33
f16: true
44
gpu_layers: 90
55
mmap: true
6+
trimsuffix:
7+
- "\n"
68
parameters:
79
model: huggingface://TheBloke/phi-2-GGUF/phi-2.Q8_0.gguf
810
temperature: 0.2

0 commit comments

Comments
 (0)