Add dynamic_temperature_low parameter (#5198)

This commit is contained in:
oobabooga 2024-01-07 17:03:47 -03:00 committed by GitHub
parent b8a0b3f925
commit 0d07b3a6a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 30 additions and 88 deletions

View file

@ -1,17 +0,0 @@
# dynatemp_with_range
This extension makes it possible to set the minimum and maximum temperatures for dynamic temperature explicitly.
For instance, you can directly set
```
min_T = 0.1
max_T = 3
```
instead of having to convert that to
```
T = 1.55
dynatemp = 1.45
```

View file

@ -1,51 +0,0 @@
import gradio as gr
params = {
"activate": True,
"minimum_temperature": 0.1,
"maximum_temperature": 2,
}
def convert_to_dynatemp():
temperature = 0.5 * (params["minimum_temperature"] + params["maximum_temperature"])
dynatemp = params["maximum_temperature"] - temperature
return temperature, dynatemp
def state_modifier(state):
"""
Modifies the state variable, which is a dictionary containing the input
values in the UI like sliders and checkboxes.
"""
if params["activate"]:
temperature, dynatemp = convert_to_dynatemp()
state["temperature"] = temperature
state["dynatemp"] = dynatemp
return state
def generate_info():
temperature, dynatemp = convert_to_dynatemp()
return f"The combination above is equivalent to: T={temperature:.2f}, dynatemp={dynatemp:.2f}"
def ui():
activate = gr.Checkbox(value=params['activate'], label='Activate Dynamic Temperature Range', info='When checked, the default temperature/dynatemp parameters are ignored and the parameters below are used instead.')
with gr.Row():
minimum_temperature = gr.Slider(0, 5, step=0.01, label="Minimum temperature", value=params["minimum_temperature"], interactive=True)
maximum_temperature = gr.Slider(0, 5, step=0.01, label="Maximum temperature", value=params["maximum_temperature"], interactive=True)
info = gr.HTML(generate_info())
activate.change(lambda x: params.update({"activate": x}), activate, None)
minimum_temperature.change(
lambda x: params.update({"minimum_temperature": x}), minimum_temperature, None).then(
generate_info, None, info, show_progress=False)
maximum_temperature.change(
lambda x: params.update({"maximum_temperature": x}), maximum_temperature, None).then(
generate_info, None, info, show_progress=False)

View file

@ -8,7 +8,8 @@ from pydantic import BaseModel, Field
class GenerationOptions(BaseModel):
preset: str | None = Field(default=None, description="The name of a file under text-generation-webui/presets (without the .yaml extension). The sampling parameters that get overwritten by this option are the keys in the default_preset() function in modules/presets.py.")
min_p: float = 0
dynatemp: float = 0
dynamic_temperature: bool = False
dynamic_temperature_low: float = 0.1
top_k: int = 0
repetition_penalty: float = 1
repetition_penalty_range: int = 1024