Skip to content

Wrong prefix for logs in KTOTrainer #1631

@bartoszzuk

Description

@bartoszzuk

The implementation of log method in KTOTrainer uses wrong prefix eval/ instead of eval_ (similar with train metrics).
This results in names of metrics not being properly processed by logging callbacks (I tested on WandbCallback). The problem is specifically with function rewrite_logs, which expects correct prefixes. This results in metric names in wandb like train/train/rewards/margins or train/eval/rewards/margins (see picture below). If you would like I can submit a pull request for this issue since the fix should be pretty trivial?

def rewrite_logs(d):
    new_d = {}
    eval_prefix = "eval_"
    eval_prefix_len = len(eval_prefix)
    test_prefix = "test_"
    test_prefix_len = len(test_prefix)
    for k, v in d.items():
        if k.startswith(eval_prefix):
            new_d["eval/" + k[eval_prefix_len:]] = v
        elif k.startswith(test_prefix):
            new_d["test/" + k[test_prefix_len:]] = v
        else:
            new_d["train/" + k] = v
    return new_d

Screenshot from 2024-05-08 16-23-54

Metadata

Metadata

Assignees

No one assigned

    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