Skip to content
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
4 changes: 2 additions & 2 deletions eval/questions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 9 additions & 3 deletions eval/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"]:
Expand Down
5 changes: 3 additions & 2 deletions floatchat/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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…')",
}


Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading