mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-12 15:27:06 +00:00
fix: check for None in SAS eval input (#7909)
* check for None in SAS input * Update releasenotes/notes/check-for-None-SAS-eval-0b982ccc1491ee83.yaml --------- Co-authored-by: David S. Batista <dsbatista@gmail.com>
This commit is contained in:
parent
f5a34d4d5c
commit
9c45203a76
@ -157,6 +157,9 @@ class SASEvaluator:
|
||||
if len(ground_truth_answers) != len(predicted_answers):
|
||||
raise ValueError("The number of predictions and labels must be the same.")
|
||||
|
||||
if any(answer is None for answer in predicted_answers):
|
||||
raise ValueError("Predicted answers must not contain None values.")
|
||||
|
||||
if len(predicted_answers) == 0:
|
||||
return {"score": 0.0, "individual_scores": [0.0]}
|
||||
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
`SASEvaluator` now raises a `ValueError` if a `None` value is contained in the `predicted_answers` input.
|
||||
@ -73,6 +73,21 @@ class TestSASEvaluator:
|
||||
with pytest.raises(ValueError):
|
||||
evaluator.run(ground_truth_answers=ground_truths, predicted_answers=predictions)
|
||||
|
||||
def test_run_with_none_in_predictions(self):
|
||||
evaluator = SASEvaluator()
|
||||
ground_truths = [
|
||||
"A construction budget of US $2.3 billion",
|
||||
"The Eiffel Tower, completed in 1889, symbolizes Paris's cultural magnificence.",
|
||||
"The Meiji Restoration in 1868 transformed Japan into a modernized world power.",
|
||||
]
|
||||
predictions = [
|
||||
"A construction budget of US $2.3 billion",
|
||||
None,
|
||||
"The Meiji Restoration in 1868 transformed Japan into a modernized world power.",
|
||||
]
|
||||
with pytest.raises(ValueError):
|
||||
evaluator.run(ground_truth_answers=ground_truths, predicted_answers=predictions)
|
||||
|
||||
def test_run_not_warmed_up(self):
|
||||
evaluator = SASEvaluator()
|
||||
ground_truths = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user