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

Add context to image_critique_metrics and photorealism_critique_metrics #1649

Merged
merged 1 commit into from
Jun 6, 2023
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
7 changes: 4 additions & 3 deletions src/helm/benchmark/metrics/images/image_critique_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from helm.benchmark.adaptation.request_state import RequestState
from helm.benchmark.adaptation.scenario_state import ScenarioState
from helm.benchmark.adaptation.adapter_spec import AdapterSpec
from helm.benchmark.metrics.metric import Metric, MetricResult
from helm.benchmark.metrics.metric_name import MetricName
from helm.benchmark.metrics.metric import Metric, MetricResult, add_context
from helm.benchmark.metrics.metric_name import MetricContext, MetricName
from helm.benchmark.metrics.metric_service import MetricService
from helm.benchmark.metrics.statistic import Stat, merge_stat
from helm.common.critique_request import CritiqueTaskTemplate, CritiqueQuestionTemplate, CritiqueRequest, QuestionType
Expand Down Expand Up @@ -116,14 +116,15 @@ def evaluate(

all_stats: Dict[MetricName, Stat] = {}
for request_state in request_states:
context = MetricContext.from_instance(request_state.instance)
stats = self.evaluate_generation(
scenario_state.adapter_spec,
request_state,
metric_service,
eval_cache_path,
)
for stat in stats:
merge_stat(all_stats, stat)
merge_stat(all_stats, add_context(stat, context))

return MetricResult(aggregated_stats=list(all_stats.values()), per_instance_stats=[])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from helm.benchmark.adaptation.request_state import RequestState
from helm.benchmark.adaptation.scenario_state import ScenarioState
from helm.benchmark.adaptation.adapter_spec import AdapterSpec
from helm.benchmark.metrics.metric import Metric, MetricResult
from helm.benchmark.metrics.metric_name import MetricName
from helm.benchmark.metrics.metric import Metric, MetricResult, add_context
from helm.benchmark.metrics.metric_name import MetricContext, MetricName
from helm.benchmark.metrics.metric_service import MetricService
from helm.benchmark.metrics.statistic import Stat, merge_stat
from helm.benchmark.scenarios.scenario import Reference
Expand Down Expand Up @@ -67,14 +67,15 @@ def evaluate(

all_stats: Dict[MetricName, Stat] = {}
for request_state in request_states:
context = MetricContext.from_instance(request_state.instance)
stats = self.evaluate_generation(
scenario_state.adapter_spec,
request_state,
metric_service,
eval_cache_path,
)
for stat in stats:
merge_stat(all_stats, stat)
merge_stat(all_stats, add_context(stat, context))

return MetricResult(aggregated_stats=list(all_stats.values()), per_instance_stats=[])

Expand Down