nat.plugins.ragas.rag_evaluator.utils#
Functions#
|
Convert NaN or None to 0.0 for safe arithmetic/serialization. |
|
Extract scalar score from a ragas metric result object. |
|
Build kwargs payload for |
|
Run one metric and return raw ragas |
Module Contents#
- extract_metric_score(
- metric_result: ragas.metrics.result.MetricResult,
Extract scalar score from a ragas metric result object.
- build_metric_kwargs(sample: object) dict[str, str | list[str]]#
Build kwargs payload for
metric.ascore(**kwargs)from a ragas sample.
- async score_metric_result(
- metric: ragas.metrics.base.SimpleBaseMetric,
- sample: object,
Run one metric and return raw ragas
MetricResult.We first build a superset of possible sample fields, then filter kwargs by the concrete
metric.ascore(...)signature so each metric only receives supported args.Examples:
AnswerAccuracy(self, user_input, response, reference)forwardsuser_input, response, reference.AnswerCorrectness(self, user_input, response, reference)forwardsuser_input, response, reference.AnswerRelevancy(self, user_input, response)forwardsuser_input, response.BleuScore(self, reference, response)forwardsreference, response.ResponseGroundedness(self, response, retrieved_contexts)forwardsresponse, retrieved_contexts.