You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to log F1, precision, recall and other custom metrics while training apart from training and validation loss #243
Hi, did you find out how to do it? I have the same issue right now. I would be so happy as I am currently writing my master thesis and fine-tuning Gliner is a part of it
Hi, I have been trying to evaluate the model during training too. I used the compute__metrics parameter in the Trainer to pass a custom function that receives an EvalPred object and calculates the metrics based on it.
Unfortunately, the metrics seem to be wrong though (maybe I am transforming the attributes of EvalPred in a wrong way) as I get a much lower accuracy during training compared to the results on the test set.
Maybe the hint with the compute_metrics helps. If you figure out how to do this I would be very interested in the solution. :)
If you only want to log it you could use a Callback, but since they are read-only and are run after the Trainer metrics have been saved, they would never show up in WandB or Tensorboard.
The regex at the top is to ensure the string that model.evaluate returns is parsed into a dictionary again. Alternatively, you could directly use the compute_prf function (which returns a dict) from gliner.evaluation.evaluator, but this requires some extra preprocessing which I couldn't be bothered to do.
Activity
ChristinaPetschnig commentedon Apr 18, 2025
Hi, did you find out how to do it? I have the same issue right now. I would be so happy as I am currently writing my master thesis and fine-tuning Gliner is a part of it
iazk0 commentedon May 13, 2025
Hi, I have been trying to evaluate the model during training too. I used the
compute__metricsparameter in the Trainer to pass a custom function that receives anEvalPredobject and calculates the metrics based on it.Unfortunately, the metrics seem to be wrong though (maybe I am transforming the attributes of
EvalPredin a wrong way) as I get a much lower accuracy during training compared to the results on the test set.Maybe the hint with the
compute_metricshelps. If you figure out how to do this I would be very interested in the solution. :)TimKoornstra commentedon Jul 2, 2025
I did it like this:
And then create your
Trainerlike:If you only want to log it you could use a Callback, but since they are read-only and are run after the Trainer metrics have been saved, they would never show up in WandB or Tensorboard.
The regex at the top is to ensure the string that
model.evaluatereturns is parsed into a dictionary again. Alternatively, you could directly use thecompute_prffunction (which returns a dict) fromgliner.evaluation.evaluator, but this requires some extra preprocessing which I couldn't be bothered to do.