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

Add GPT2ForTokenClassification #13290

Merged

Conversation

tucan9389
Copy link
Contributor

@tucan9389 tucan9389 commented Aug 27, 2021

What does this PR do?

  • Add GPT2ForTokenClassification class for GPT2 upstream and NER downstream task

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@patrickvonplaten, @LysandreJik
@sgugger, @patil-suraj

@tucan9389 tucan9389 marked this pull request as ready for review August 27, 2021 07:20
@tucan9389 tucan9389 changed the title WIP: Add GPT2ForTokenClassification Add GPT2ForTokenClassification Aug 27, 2021
@tucan9389
Copy link
Contributor Author

Fixed all test failures and all passed.

@@ -449,6 +449,42 @@ class SequenceClassifierOutputWithPast(ModelOutput):
attentions: Optional[Tuple[torch.FloatTensor]] = None


@dataclass
class TokenClassifierOutputWithPast(ModelOutput):
Copy link
Contributor

Choose a reason for hiding this comment

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

Think we can just reuse TokenClassifierOutput no? Don't think it makes sense to use past for token classification. Would one ever do more than one forward pass for token classification? If it's just one forward pass then I think we could force use_cache=False in GPT2ForTokenClassification.

What do you think @tucan9389 ? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@patrickvonplaten
Thanks for your comment.
Oh, I agree with that. I'll change to TokenClassifierOutput.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks a lot for adding this model!

@tucan9389
Copy link
Contributor Author

@sgugger Thanks for approving.

@patrickvonplaten I just fixed some errors that occurred in run_tests_torch CI test and all tests were passed.

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Very nice! Thanks for you work here @tucan9389

@patrickvonplaten patrickvonplaten merged commit 41c5594 into huggingface:master Aug 31, 2021
@tucan9389 tucan9389 deleted the add-gpt2-token-classiifcation branch August 31, 2021 15:06
@tucan9389 tucan9389 mentioned this pull request Nov 24, 2021
3 tasks
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.

4 participants