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
Fixing question-answering with long contexts #13873
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing, nice new tests!
@@ -330,26 +338,41 @@ def preprocess(self, example, padding="do_not_pad", doc_stride=128, max_question | |||
qas_id=None, | |||
) | |||
) | |||
return {"features": features, "example": example} | |||
|
|||
shallow = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shallow for the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a better name, I just tried to disassemble the feature
before passing it on for _forward
as it makes it benefit automatically from no_grad
and to(device)
from forward
(otherwise _forward
had to take care of it).
Reusing features
is good enough? Didn't find a better name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like features personally (and I use example/sample when I want to make the distinction: one sample gives several features).
* Tmp. * Fixing BC for question answering with long context. * Capping model_max_length to avoid tf overflow. * Bad workaround bugged roberta. * Fixing name.
* Tmp. * Fixing BC for question answering with long context. * Capping model_max_length to avoid tf overflow. * Bad workaround bugged roberta. * Fixing name.
* Tmp. * Fixing BC for question answering with long context. * Capping model_max_length to avoid tf overflow. * Bad workaround bugged roberta. * Fixing name.
Having a similar issue where I used a QA model from transformers, tweaked the model in label studio making some annotations and then tried to load the model back again. The model is pulling out the correct answers but seemingly hadnle_impossible_answers isn't working because it gives an answer for every questions even when the question is irrelevant.. What's even weirder is that it doesn't do this in label studio's interface so seemingly this handle_impossible_answers is working on that side. My contexts I pass through the pipeline are also quite long Made sure I have the most up to date transformers model, and the models were saved out with save_pretrained
The answers that I get out of here have an answer for every question, even when it doesn't need to be answered. I've tried loading the models multiple ways - the only way I got handle_impossible_answers to work as intended is if the tokenizer wasn't the AutoTokenizer that I had used here. But then the answers it gave me were complete garbage. Anybody else run into this issue with AutoTokenizer?? |
The only was I can think the tokenizer could be involved would be if it doesn't include EOS/BOS. For null answer to come out, the score has to be the highest when the start and end logits are the first one (which should be a BOS/CLS token). Did you finetune your model on such null answers ? Maybe the finetuning just made that output impossible for the model to produce ? |
Fixes #13811
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
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.