diff --git a/eval/questions.json b/eval/questions.json index 8db6fd6..16bc124 100644 --- a/eval/questions.json +++ b/eval/questions.json @@ -46,8 +46,8 @@ "expect": {"path": "semantic", "filters": {"region": "Southern Indian Ocean", "has_chlorophyll": true}}}, {"id": "find-indonesia-january", "question": "Profiles near Indonesia in January 2026", "expect": {"path": "semantic", "filters": {"region": "Eastern Indian Ocean", "month_num": 1, "year": 2026}}}, - {"id": "find-red-sea", "question": "Describe recent profiles from the Red Sea", - "expect": {"path": "semantic", "filters": {"region": "Red Sea & Gulf of Aden"}}}, + {"id": "no-data-red-sea", "question": "Describe recent profiles from the Red Sea", + "expect": {"path": "semantic", "filters": {"region": "Red Sea & Gulf of Aden"}, "no_match": true}}, {"id": "find-nitrate-arabian", "question": "Find nitrate measurements in the Arabian Sea", "expect": {"path": "semantic", "filters": {"region": "Arabian Sea", "has_nitrate": true}}}, {"id": "find-thermocline", "question": "Show me profiles with a strong thermocline", diff --git a/eval/runner.py b/eval/runner.py index 056c4ff..db86e84 100644 --- a/eval/runner.py +++ b/eval/runner.py @@ -64,11 +64,17 @@ def _check_analytical(response: dict) -> str | None: return f"SQL does not apply {', '.join(missing)}" if missing else None -def _check_semantic(response: dict) -> str | None: +def _check_semantic(response: dict, expect_no_match: bool = False) -> str | None: + widened = any(s.get("step") == "search" and s.get("fallback_without_filters") for s in response.get("steps") or []) + if expect_no_match: + # The dataset has nothing matching: the answer must say so rather than present other profiles as matches + if not widened or not response.get("answer", "").startswith("No profiles were recorded"): + return "should have said no profiles match" + return None profiles = response.get("retrieved_metadata") or [] if not profiles: return "no profiles returned" - if any(s.get("step") == "search" and s.get("fallback_without_filters") for s in response.get("steps") or []): + if widened: return "no profile matched the filters (search was widened)" filters = response.get("filters") or {} wrong = sum(not _profile_matches(p, filters) for p in profiles) @@ -116,7 +122,7 @@ def check_case(case: dict, status: int, response: dict, latency_ms: int) -> dict elif response.get("query_type") == "analytical": problem = _check_analytical(response) else: - problem = _check_semantic(response) + problem = _check_semantic(response, expect.get("no_match", False)) result["answer"] = problem is None notes = [] if not result["routing"]: diff --git a/floatchat/router.py b/floatchat/router.py index ed2fd9a..36b6568 100644 --- a/floatchat/router.py +++ b/floatchat/router.py @@ -22,9 +22,10 @@ "regional_comparison": "compare the regions (upper 100 m)", "depth_ranges": "averages by depth layer (surface, intermediate, deep)", "temporal_trends": "monthly averages over time", - "float_summary": "statistics per float, most active floats", + "float_summary": "a table with one row per float (its profile count, averages, depth), e.g. most active floats", "bgc_analysis": "oxygen, chlorophyll, nitrate or pH by ocean zone", - "custom": "any other statistical question that needs its own SQL", + "custom": "any other statistical question that needs its own SQL, including a single number such as a count, " + "total, maximum or minimum (e.g. 'how many profiles…', 'what was the highest temperature…')", } diff --git a/tests/unit/test_eval.py b/tests/unit/test_eval.py index 99cfc40..0abe41a 100644 --- a/tests/unit/test_eval.py +++ b/tests/unit/test_eval.py @@ -75,6 +75,17 @@ def test_semantic_answers_must_only_return_matching_profiles(): assert check_case(FIND, 200, semantic([]), 10)["answer"] is False +def test_a_no_match_case_passes_only_when_the_answer_says_nothing_matched(): + case = {**FIND, "expect": {**FIND["expect"], "no_match": True}} + honest = semantic([bengal(region="Arabian Sea")], fallback=True) + honest["answer"] = "No profiles were recorded in the Bay of Bengal in this dataset, so these are the closest..." + assert check_case(case, 200, honest, 10)["answer"] is True + pretends = semantic([bengal(region="Arabian Sea")], fallback=True) + pretends["answer"] = "Here are the Bay of Bengal profiles..." + assert check_case(case, 200, pretends, 10)["answer"] is False + assert check_case(case, 200, semantic([bengal()]), 10)["answer"] is False + + def test_optional_filters_are_ignored_when_comparing(): assert check_case(FIND, 200, semantic([bengal()]), 10)["filters"] is True assert check_case(FIND, 200, semantic([bengal()], filters={"region": "Bay of Bengal"}), 10)["filters"] is True