Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added quadratic sampling #56

Merged
merged 4 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions backends/exllamav2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@ def check_unsupported_settings(self, **kwargs):
"installed ExLlamaV2 version."
)

if (unwrap(kwargs.get("smoothing_factor"), 0.0)) > 0.0 and not hasattr(
ExLlamaV2Sampler.Settings, "smoothing_factor"
):
logger.warning(
"Smoothing factor is not supported by the currently "
"installed ExLlamaV2 version."
)

def generate(self, prompt: str, **kwargs):
"""Generate a response to a prompt"""
generation = list(self.generate_gen(prompt, **kwargs))
Expand Down Expand Up @@ -593,6 +601,7 @@ def generate_gen(self, prompt: str, **kwargs):
# Apply settings
gen_settings.temperature = unwrap(kwargs.get("temperature"), 1.0)
gen_settings.temperature_last = unwrap(kwargs.get("temperature_last"), False)
gen_settings.smoothing_factor = unwrap(kwargs.get("smoothing_factor"), 0.0)
gen_settings.top_k = unwrap(kwargs.get("top_k"), 0)
gen_settings.top_p = unwrap(kwargs.get("top_p"), 1.0)
gen_settings.top_a = unwrap(kwargs.get("top_a"), 0.0)
Expand Down
5 changes: 5 additions & 0 deletions common/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class SamplerParams(BaseModel):
examples=[1.0],
)

smoothing_factor: Optional[float] = Field(
default_factor=lambda: get_default_sampler_value("smoothing_factor", 0.0),
)

top_k: Optional[int] = Field(
default_factory=lambda: get_default_sampler_value("top_k", 0)
)
Expand Down Expand Up @@ -173,6 +177,7 @@ def to_gen_params(self):
"min_temp": self.min_temp,
"max_temp": self.max_temp,
"temp_exponent": self.temp_exponent,
"smoothing_factor": self.smoothing_factor,
"top_k": self.top_k,
"top_p": self.top_p,
"top_a": self.top_a,
Expand Down
3 changes: 3 additions & 0 deletions sampler_overrides/sample_preset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ max_temp:
temp_exponent:
override: 0.0
force: false
smoothing_factor:
override: 0.0
force: false

# MARK: Alphabet soup
top_k:
Expand Down
Loading