feat(scoring): add NEL-NMP integration contracts (Approach 3)#924
Closed
wprazuch wants to merge 1 commit into
Closed
feat(scoring): add NEL-NMP integration contracts (Approach 3)#924wprazuch wants to merge 1 commit into
wprazuch wants to merge 1 commit into
Conversation
Defines the abstract interface between NEL and downstream metric
providers (e.g., NMP's nemo_evaluator_sdk) in a new module:
src/nemo_evaluator/scoring/contracts.py (~250 LOC).
Provides:
- Metric protocols (runtime_checkable, structural):
* Metric -- core object-style metric contract (type, metric,
compute_scores, score_names)
* CorpusMetric -- corpus-level aggregation
* MetricWithSecrets -- secret resolution protocol
* MetricWithPreflight -- one-time preflight setup
- Pydantic result types (no heavy deps -- no pyarrow, no pandas):
* MetricScore, MetricResult
* ScoreStats, RubricScoreValue, RubricScoreStat
- SecretRefLike Protocol (abstract secret reference)
- SecretResolver type alias
- metric_as_scorer() helper: bridges object-style Metric to NEL's
function-style (ScorerInput) -> dict scorer protocol
Design rationale (Approach 3):
- NMP's concrete metric implementations (BLEU, ROUGE, F1, RAGAS,
LLMJudge, etc.) stay in nemo_evaluator_sdk with their external deps
(sacrebleu, rouge_score, openai, ragas).
- NEL owns only the contract surface. NMP SDK will be updated in a
follow-up PR to depend on NEL for these types, dropping its own
copies and becoming thinner.
- Dependency direction is strictly one-way: SDK -> NEL. NEL never
imports from any provider.
- Contracts are dep-light: pure Pydantic models + typing.Protocol,
no pyarrow/pandas/openai/etc. leaking into NEL.
Verified:
- 14 new unit tests pass
- SDK's ExactMatchMetric structurally satisfies the Metric Protocol
with zero code changes (isinstance check passes)
- All 162 SDK + contracts tests pass together
This commit is stacked on wprazuch/sdk-onboarding-approach1 so the
contracts land alongside the verbatim SDK copy for easier review. The
follow-up plan is:
1. Merge Approach 1 (verbatim copy) to dev/0.3.0
2. Merge this PR (contracts) to dev/0.3.0
3. Open a matching PR on NMP's nemo_evaluator_sdk to depend on NEL's
contracts and drop its redundant abstraction copies
Signed-off-by: Wojciech Prazuch <wprazuch@nvidia.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
Defines the abstract interface between NEL and downstream metric providers (e.g., NMP's nemo_evaluator_sdk) in a new module: src/nemo_evaluator/scoring/contracts.py (~250 LOC).
Provides:
Design rationale (Approach 3):
Verified:
This commit is stacked on wprazuch/sdk-onboarding-approach1 so the contracts land alongside the verbatim SDK copy for easier review. The follow-up plan is: