feat: Phase 10 - LLM-as-Judge Metrics (NLI-based scoring)#27
Merged
Conversation
Add NLI-based scoring module for accurate faithfulness and relevancy evaluation, replacing word-overlap fallbacks with proper Natural Language Inference using DeBERTa model. New components: - NLI module (metrics/nli/): NLIJudge, ClaimExtractor, EvidenceFinder - LLMJudgeMetric: Generic LLM-as-Judge for custom quality criteria - Upgraded Faithfulness metric with NLI fallback - Upgraded AnswerRelevancy metric with NLI fallback Tests: - 36 unit tests for NLI scoring (all passing) - 11 integration tests for NLI-based metrics (all passing) - All existing 134 tests continue to pass Dependencies: nli group already in pyproject.toml (transformers, torch)
|
|
||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest |
Comment on lines
+21
to
+28
| from openagent_eval.metrics.generation.llm_judge import ( | ||
| LLMJudgeMetric, | ||
| AsyncLLMJudgeMetric, | ||
| JudgeCriteria, | ||
| FAITHFULNESS_CRITERIA, | ||
| RELEVANCY_CRITERIA, | ||
| COMPREHENSIVENESS_CRITERIA, | ||
| ) |
| RELEVANCY_CRITERIA, | ||
| COMPREHENSIVENESS_CRITERIA, | ||
| ) | ||
| from openagent_eval.metrics.base import MetricResult |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Phase 10: LLM-as-Judge Metrics — NLI-based scoring to replace word-overlap fallbacks for faithfulness and relevancy metrics.
Changes
New NLI Module (openagent_eval/metrics/nli/)
Upgraded Metrics
Generic LLM Judge
Testing
Architecture
The NLI module follows the project's adapter pattern:
metrics/nli/ ├── __init__.py # Public API ├── judge.py # NLIJudge using DeBERTa MNLI ├── claim_extractor.py # Split answers into claims └── evidence_finder.py # Match claims to evidenceDependencies
The
li optional dependency group was already defined in pyproject.toml:
Related