Skip to content

KTO refactoring #4786

@albertvillanova

Description

@albertvillanova

Systematically refactor KTOTrainer to align with modern trainer architecture patterns, improving maintainability, reducing complexity, and adding missing features.

Problem

KTOTrainer currently has complex code with several architectural issues.

Refactoring Plan

1: Foundation & Infrastructure

Establish modern patterns without breaking functionality

2: Dataset Processing Modernization

Adopt standard trainers' clean preprocessing patterns

3: Reference Model Handling

Simplify ref model management

4: Loss Computation & Forward Pass

Reduce duplication in loss computation

5: Metrics & Logging

Match standard metrics system

6: Evaluation & Generation

Modern evaluation features

7: Documentation

Complete, clear documentation

Phase 8: Advanced Features

Feature parity with standard trainers

Phase 9: Testing

Production ready

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions