Skip to content

Commit

Permalink
Ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
sidjha1 committed Nov 3, 2024
1 parent 0aa1321 commit edb8cc6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lotus/sem_ops/cascade_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ def importance_sampling(

return sample_indices, correction_factors


def calibrate_llm_logprobs(true_probs: list[float]) -> list[float]:
"""Transforms true probabilities to calibrate LLM proxies."""
num_quantiles = lotus.settings.cascade_num_calibration_quantiles
quantile_values = np.percentile(true_probs, np.linspace(0, 100, num_quantiles + 1))
true_probs = ((np.digitize(true_probs, quantile_values) - 1) / num_quantiles)
true_probs = (np.digitize(true_probs, quantile_values) - 1) / num_quantiles
true_probs = list(np.clip(true_probs, 0, 1))
return true_probs


def learn_cascade_thresholds(
proxy_scores: list[float],
oracle_outputs: list[bool],
Expand Down
2 changes: 1 addition & 1 deletion lotus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ def __repr__(self) -> str:

# set defaults
settings = Settings()
settings.configure(cascade_is_weight=0.5, cascade_num_calibration_quantiles=50)
settings.configure(cascade_is_weight=0.5, cascade_num_calibration_quantiles=50)

0 comments on commit edb8cc6

Please sign in to comment.