Pass Arguments to custom compute_metrics in Trainer

Hi, I think this discussion could be useful for you:

In a nutshell

def prepare_compute_metrics(label_list):
    def compute_metrics(p):
        nonlocal label_list
        ...
    return compute_metrics
    
compute_metrics = prepare_compute_metrics(label_list)
1 Like