Code structuring for text classification with hf bert-uncase

Hi,
I haven’t gone through the notebook, just checked the module you sent.

  1. No need to define the loss module as it is already defined and used in hf model itself.
    Since you don’t use it anywhere I assume it’s just a leftover code.

  2. For metrics I would suggest using TorchMetrics as it play great with Lighting and it makes computing the metrics easy in distributed training. With your current implementation there might be a problem if the last batch is shorter than the other batches.

  3. Yes if you want to do the inference you have to define the predict function.

2 Likes