transformers icon indicating copy to clipboard operation
transformers copied to clipboard

Add LayoutLMv2ForRelationExtraction

Open NielsRogge opened this issue 2 years ago • 2 comments

What does this PR do?

This PR adds the relation extraction head of LayoutLMv2, which was a highly requested feature as seen in #14330 #15451 #18091

NielsRogge avatar Sep 20 '22 09:09 NielsRogge

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@sgugger I'm getting the following error from make fixup:

Checking all objects are properly documented.
Traceback (most recent call last):
  File "/home/niels/python_projects/transformers/utils/check_repo.py", line 788, in <module>
    check_repo_quality()
  File "/home/niels/python_projects/transformers/utils/check_repo.py", line 782, in check_repo_quality
    check_all_objects_are_documented()
  File "/home/niels/python_projects/transformers/utils/check_repo.py", line 693, in check_all_objects_are_documented
    raise Exception(
Exception: The following objects are in the public init so should be documented:
 - LayoutLMv2ForRelationExtraction

However, this model is added to layoutlmv2.mdx, so not sure why this error occurs.

NielsRogge avatar Sep 20 '22 09:09 NielsRogge

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Oct 20 '22 15:10 github-actions[bot]

Hey @NielsRogge , any chance that this will ever be implemented? Looking around the history of the PR and Iissues, it seems that there was a fair bit of interest

lamaeldo avatar Apr 10 '23 17:04 lamaeldo

Hi @lamaeldo,

The reason the PR wasn't merged is because models need to output fixed size tensors, to make sure things like distributed training and ONNX export work. However LayoutLMv2ForRelationExtraction outputs lists of tensors in its current implementation, due to each example in the batch having a different amount of relations. So we would need to pad them up to a fixed size such that the model outputs fixed size tensors.

Haven't looked into that yet but if you're willing to contribute, let me know!

Btw I do have a notebook on fine-tuning this model here.

NielsRogge avatar Apr 10 '23 18:04 NielsRogge