Skip to content

Commit d508573

Browse files
authored
Merge pull request abetlen#328 from spirilis/mirostat
Added mirostat support for completions, chat completions API
2 parents aad4b17 + 9b1c9e9 commit d508573

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

llama_cpp/server/app.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,27 @@ def get_settings():
191191
description="Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.",
192192
)
193193

194+
mirostat_mode_field = Field(
195+
default=0,
196+
ge=0,
197+
le=2,
198+
description="Enable Mirostat constant-perplexity algorithm of the specified version (1 or 2; 0 = disabled)"
199+
)
200+
201+
mirostat_tau_field = Field(
202+
default=5.0,
203+
ge=0.0,
204+
le=10.0,
205+
description="Mirostat target entropy, i.e. the target perplexity - lower values produce focused and coherent text, larger values produce more diverse and less coherent text"
206+
)
207+
208+
mirostat_eta_field = Field(
209+
default=0.1,
210+
ge=0.001,
211+
le=1.0,
212+
description="Mirostat learning rate"
213+
)
214+
194215

195216
class CreateCompletionRequest(BaseModel):
196217
prompt: Union[str, List[str]] = Field(
@@ -203,6 +224,9 @@ class CreateCompletionRequest(BaseModel):
203224
max_tokens: int = max_tokens_field
204225
temperature: float = temperature_field
205226
top_p: float = top_p_field
227+
mirostat_mode: int = mirostat_mode_field
228+
mirostat_tau: float = mirostat_tau_field
229+
mirostat_eta: float = mirostat_eta_field
206230
echo: bool = Field(
207231
default=False,
208232
description="Whether to echo the prompt in the generated text. Useful for chatbots.",
@@ -332,6 +356,9 @@ class CreateChatCompletionRequest(BaseModel):
332356
max_tokens: int = max_tokens_field
333357
temperature: float = temperature_field
334358
top_p: float = top_p_field
359+
mirostat_mode: int = mirostat_mode_field
360+
mirostat_tau: float = mirostat_tau_field
361+
mirostat_eta: float = mirostat_eta_field
335362
stop: Optional[List[str]] = stop_field
336363
stream: bool = stream_field
337364
presence_penalty: Optional[float] = presence_penalty_field

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy