From 9509853b4ef54cd39c69c35656a01876f8bcc369 Mon Sep 17 00:00:00 2001 From: Arun Brahma Date: Fri, 20 Dec 2024 01:14:36 +0530 Subject: [PATCH] fix: update error handling in Faithfulness metric to return 0.0 instead of np.nan on failure --- src/ragas/metrics/_faithfulness.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ragas/metrics/_faithfulness.py b/src/ragas/metrics/_faithfulness.py index 5cf1229a7..d45a97dd4 100644 --- a/src/ragas/metrics/_faithfulness.py +++ b/src/ragas/metrics/_faithfulness.py @@ -262,7 +262,8 @@ async def _ascore(self, row: t.Dict, callbacks: Callbacks) -> float: statements_simplified = await self._create_statements(row, callbacks) if statements_simplified is None: - return np.nan + logger.warning("Failed to create statements from the answer.") + return 0.0 # Return 0.0 instead of np.nan # unwrap the statements statements = []