Skip to content

feat: Phase 10 - LLM-as-Judge Metrics (NLI-based scoring)#27

Merged
himanshu231204 merged 1 commit into
mainfrom
feature/phase10-llm-as-judge
Jul 11, 2026
Merged

feat: Phase 10 - LLM-as-Judge Metrics (NLI-based scoring)#27
himanshu231204 merged 1 commit into
mainfrom
feature/phase10-llm-as-judge

Conversation

@himanshu231204

Copy link
Copy Markdown
Contributor

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/)

  • NLIJudge — DeBERTa-based Natural Language Inference for claim verification
  • ClaimExtractor — Splits answers into atomic factual claims
  • EvidenceFinder — Matches claims to supporting context via NLI scoring

Upgraded Metrics

  • Faithfulness — Now uses NLI fallback (Ragas → NLI → word overlap)
  • AnswerRelevancy — Now uses NLI fallback (Ragas → NLI → word overlap)

Generic LLM Judge

  • LLMJudgeMetric — Flexible metric for custom quality criteria with predefined templates

Testing

  • 36 new unit tests for NLI scoring (all passing)
  • 11 new integration tests for NLI-based metrics (all passing)
  • All 134 existing tests continue to pass

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 evidence

Dependencies

The
li optional dependency group was already defined in pyproject.toml:

  • ransformers>=4.30.0
  • orch>=2.0.0

Related

  • Closes #Phase 10 from TASKS.md
  • Enables NLI-based scoring for production-grade RAG evaluation

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
@himanshu231204 himanshu231204 self-assigned this Jul 11, 2026
@himanshu231204 himanshu231204 merged commit 045a6c4 into main Jul 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant