ArneBinder / pytorch-ie

PyTorch-IE: State-of-the-art Information Extraction in PyTorch
MIT License
75 stars 7 forks source link

add `TaskModule.configure_model_metric(stage)` #392

Closed ArneBinder closed 10 months ago

ArneBinder commented 10 months ago

This adds the interface method configure_model_metric(stage: str) -> Optional[Metric] to the TaskModule class. Per default, it returns just None. Taskmodule implementations can override this to return a torchmetrics.Metric which should accept a batch of model outputs and targets. By having this method defined in the taskmodule, it is possible to use its unbatch_output and any available annotation decoding logic. Then, a PyTorchIEModel implementation can use this to easily create metrics that match the data without re-implementing any specific decoding logic.