From bcb2c7b25ea8c3d93ad923831c5f71a01da38595 Mon Sep 17 00:00:00 2001 From: nan Date: Wed, 2 Sep 2026 16:04:39 +0800 Subject: [PATCH] fix: include all evaluation score components --- VLABench/evaluation/utils.py | 9 +++++-- tests/test_evaluation_utils.py | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/test_evaluation_utils.py diff --git a/VLABench/evaluation/utils.py b/VLABench/evaluation/utils.py index 0f5fef6..4715135 100644 --- a/VLABench/evaluation/utils.py +++ b/VLABench/evaluation/utils.py @@ -328,7 +328,12 @@ def get_final_score(standard_skill_sequence, model_skill_sequence, dependency): "skill_with_entity_match_score": 0.1, "exact_match_score": 0.1 } - total_score = sum(score_weight[key] * value for key, value in skill_entity_scores.items()) + all_scores = { + **skill_entity_scores, + **skill_with_entity_scores, + "exact_match_score": exact_match_score, + } + total_score = sum(score_weight[key] * all_scores[key] for key in score_weight) return { "skill_match_score": skill_entity_scores["skill_match_score"], @@ -336,4 +341,4 @@ def get_final_score(standard_skill_sequence, model_skill_sequence, dependency): "skill_with_entity_match_score": skill_with_entity_scores["skill_with_entity_match_score"], "exact_match_score": exact_match_score, "total_score": total_score - } \ No newline at end of file + } diff --git a/tests/test_evaluation_utils.py b/tests/test_evaluation_utils.py new file mode 100644 index 0000000..c7ecf83 --- /dev/null +++ b/tests/test_evaluation_utils.py @@ -0,0 +1,47 @@ +from importlib.util import module_from_spec, spec_from_file_location +from pathlib import Path + + +_UTILS_PATH = Path(__file__).parents[1] / "VLABench" / "evaluation" / "utils.py" +_SPEC = spec_from_file_location("vlabench_evaluation_utils", _UTILS_PATH) +utils = module_from_spec(_SPEC) +assert _SPEC.loader is not None +_SPEC.loader.exec_module(utils) + + +def test_get_final_score_includes_all_weighted_metrics(monkeypatch): + monkeypatch.setattr( + utils, + "calculate_skill_and_entity_scores", + lambda standard, model: {"skill_match_score": 100.0, "entity_match_score": 0.0}, + ) + monkeypatch.setattr( + utils, + "calculate_skill_with_entity_scores", + lambda standard, model: {"skill_with_entity_match_score": 50.0}, + ) + monkeypatch.setattr(utils, "get_exact_match", lambda standard, model, dependency: 0.0) + + result = utils.get_final_score([], [], "Sequential") + + assert result["skill_match_score"] == 100.0 + assert result["entity_match_score"] == 0.0 + assert result["skill_with_entity_match_score"] == 50.0 + assert result["exact_match_score"] == 0.0 + assert result["total_score"] == 45.0 + + +def test_get_final_score_reaches_100_when_every_metric_is_perfect(monkeypatch): + monkeypatch.setattr( + utils, + "calculate_skill_and_entity_scores", + lambda standard, model: {"skill_match_score": 100.0, "entity_match_score": 100.0}, + ) + monkeypatch.setattr( + utils, + "calculate_skill_with_entity_scores", + lambda standard, model: {"skill_with_entity_match_score": 100.0}, + ) + monkeypatch.setattr(utils, "get_exact_match", lambda standard, model, dependency: 100.0) + + assert utils.get_final_score([], [], "Sequential")["total_score"] == 100.0