Skip to content

Conversation

@ArneBinder
Copy link
Owner

@ArneBinder ArneBinder commented Apr 21, 2025

Move all remaining logic that is specific to the relation_encoder_decoder into BinaryRelationEncoderDecoder, i.e., the creation of constraints and parsing of partial / erroneous encodings.

This PR:

  • adds the interface methods to AnnotationEncoderDecoder:
    • build_decoding_constraints
    • parse
  • adds implements to BinaryRelationEncoderDecoder
  • in PointerNetworkTaskModuleForEnd2EndRE:
    • removes build_constraints but uses self.relation_encoder_decoder.build_decoding_constraints (in ._build_constraint) instead
    • removes decode_relations but uses self.relation_encoder_decoder.parse instead

Note that the implementations of BinaryRelationEncoderDecoder.build_decoding_constraints and .parse are not complete, they do not cover all options for mode and do not work with arbitrary head_encoder_decoder / tail_encoder_decoder. But they cover the same amount of features that were implemented until now.

This is a first step for a simplified version of #63. Especially, it is not breaking. Remaining steps would be:

  • implement MultiSpanEncoderDecoder,
  • adjust _post_prepare to use it as relation_encoder_decoder (if the layer of document_type with span_layer_name is of type LabeledMultiSpan), and
  • adjust cmp_src_rel (relation sorting) to work with LabeledMultiSpan.
  • (optional: add reversed relations logic)

This will also allow to use this taskmodule as a blueprint for pointer based setups that handle any annotation structures. This will require to overwrite:

  • _post_prepare,
  • encode_annotations, and
  • decode_annotations.

@ArneBinder ArneBinder added the enhancement New feature or request label Apr 21, 2025
@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2025

Codecov Report

Attention: Patch coverage is 95.93496% with 5 lines in your changes missing coverage. Please review.

Project coverage is 95.85%. Comparing base (aba3467) to head (ececb53).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ules/pointer_network/annotation_encoder_decoder.py 96.05% 3 Missing ⚠️
...ules/taskmodules/pointer_network_for_end2end_re.py 95.55% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
- Coverage   95.88%   95.85%   -0.03%     
==========================================
  Files          68       68              
  Lines        6071     6107      +36     
==========================================
+ Hits         5821     5854      +33     
- Misses        250      253       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArneBinder ArneBinder changed the title pointer network taskmodule: calculate constraints in annotation encoder decoder PointerNetworkTaskModuleForEnd2EndRE: outsource remaining encoder-decoder specific logic Apr 21, 2025
@ArneBinder ArneBinder merged commit 9175192 into main Apr 21, 2025
2 checks passed
@ArneBinder ArneBinder deleted the pointer_tm/constraints_from_encoder_decoder branch April 21, 2025 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants