Skip to content

Align KTO with DPO: Fix KTO compute_metrics type hint (EvalLoopOutputEvalPrediction)#6253

Merged
qgallouedec merged 5 commits into
mainfrom
fix-kto-compute-metrics-type
Jul 3, 2026
Merged

Align KTO with DPO: Fix KTO compute_metrics type hint (EvalLoopOutputEvalPrediction)#6253
qgallouedec merged 5 commits into
mainfrom
fix-kto-compute-metrics-type

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Jul 2, 2026

Copy link
Copy Markdown
Member

Part of the effort to align KTOTrainer (experimental) with DPOTrainer. #4786

KTOTrainer.__init__ typed compute_metrics as Callable[[EvalLoopOutput], dict], which was both wrong (the Trainer passes an EvalPrediction to compute_metrics, not an EvalLoopOutput) and inconsistent with the trainer's own docstring, which already documents it as EvalPrediction. Switched the annotation and the import to EvalPrediction, matching DPOTrainer.

No behavior change (type-annotation only).


Note

Low Risk
Type-annotation-only change in experimental KTO trainer; no logic, data, or API behavior is modified.

Overview
Aligns experimental KTOTrainer with DPOTrainer by correcting the compute_metrics typing only.

The import and __init__ annotation now use EvalPrediction instead of EvalLoopOutput, matching what Hugging Face Trainer actually passes into compute_metrics and what the class docstring already described. No runtime or training behavior changes.

Reviewed by Cursor Bugbot for commit 35a7703. Bugbot is set up for automated code reviews on this repo. Configure here.

@qgallouedec qgallouedec changed the title Fix KTO compute_metrics type hint (EvalLoopOutputEvalPrediction) Align KTO with DPO: Fix KTO compute_metrics type hint (EvalLoopOutputEvalPrediction) Jul 2, 2026
@bot-ci-comment

bot-ci-comment Bot commented Jul 2, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qgallouedec qgallouedec merged commit e0eaf58 into main Jul 3, 2026
5 checks passed
@qgallouedec qgallouedec deleted the fix-kto-compute-metrics-type branch July 3, 2026 16:16
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.

2 participants