Skip to content

Commit

Permalink
Fix breakage caused by #2172 (#2194)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwgoldman authored Jan 9, 2024
1 parent 7a3190f commit 02982a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/helm/benchmark/metrics/basic_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,14 @@ def compute_logprob_and_length(request_state: RequestState, window_service: Wind
raise ValueError(f"Unknown adapter method: {adapter_spec.method}")

stats: List[Stat] = []
for request_state in reference_request_states:
stats.extend(
compute_request_state_metrics(self.efficiency_metric, adapter_spec, request_state, metric_service)
)

general_metrics: Dict[MetricName, Stat] = {}
for request_state in reference_request_states:
for stat in compute_request_state_metrics(
self.efficiency_metric, adapter_spec, request_state, metric_service
):
merge_stat(general_metrics, stat)
stats.extend(general_metrics.values())
max_prob = np.max(scipy.special.softmax(reference_scores))

# Multiple references may attain the same maximal score; in such cases,
Expand Down
4 changes: 3 additions & 1 deletion src/helm/benchmark/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ def compute_worst_case_metrics(self, per_instance_stats: Dict[Instance, List[Sta
for stat in stats: # go through all the perturbations of the instance and merge relevant stats
perturbation = stat.name.perturbation
if perturbation is None:
assert original_stat is None # we should only have one original stat
assert (
original_stat is None
), f"For {metric_name} got both {original_stat} and {stat}" # we should only have one original stat
original_stat = stat
else:
if perturbation.robustness:
Expand Down

0 comments on commit 02982a4

Please sign in to comment.