Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mask vs sequence #5565

Merged
merged 8 commits into from
Apr 15, 2020
Merged

Mask vs sequence #5565

merged 8 commits into from
Apr 15, 2020

Conversation

evgeniiaraz
Copy link
Contributor

@evgeniiaraz evgeniiaraz commented Apr 2, 2020

Proposed changes:

  • store sequence length instead of mask; compute mask when needed;

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

@evgeniiaraz evgeniiaraz requested a review from tabergma April 2, 2020 13:21
Copy link
Contributor

@tabergma tabergma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far 👍. Left some comments.

Did you saw any performance improvements?

@evgeniiaraz
Copy link
Contributor Author

I haven't seen performance improvements F1-accuracy-wise (it's the same), and I wouldn't expect that because we're essentially doing the same thing. Would need to check memory / time!
I think I've addressed previous comments.

Copy link
Contributor

@tabergma tabergma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for improving this!

Sorry, I meant performance = time/memory. F1 score should not change. Would be great is we could to a quick comparison time wise at least. I think we are fine, but we should make sure that we don't merge something that slows things down.

@@ -1255,10 +1251,12 @@ def _create_sequence(

def _create_all_labels(self) -> Tuple[tf.Tensor, tf.Tensor]:
all_label_ids = self.tf_label_data[LABEL_IDS][0]

label_lengths = tf.cast(self.tf_label_data[LABEL_SEQ_LENGTH][0], dtype=tf.int32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a helper method for this? Something like sequence_length_for? This logic is repeated all over the place.

@@ -1352,13 +1350,19 @@ def _calculate_entity_loss(

return loss, f1

def _compute_mask(self, sequence_lengths: tf.Tensor) -> tf.Tensor:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be static.

@evgeniiaraz
Copy link
Contributor Author

Timewise it is the same as the previous way of doing it.

@evgeniiaraz evgeniiaraz merged commit 993893a into 1.9.x Apr 15, 2020
@tmbo tmbo deleted the mask-vs-sequence branch May 1, 2020 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants