-
Notifications
You must be signed in to change notification settings - Fork 31.9k
[Doctest] Fix Blenderbot doctest
#21297
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
Conversation
- add correct expected value
|
The documentation is not available anymore as the PR was closed or merged. |
sgugger
left a comment
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 the fix!
|
Actually, as discussed with @ydshieh offline, there seems to be a discrepency between from transformers import BlenderbotTokenizer, BlenderbotTokenizerFast, BlenderbotForConditionalGeneration, AutoTokenizer
mname = "facebook/blenderbot-400M-distill"
model = BlenderbotForConditionalGeneration.from_pretrained(mname)
tokenizer = BlenderbotTokenizer.from_pretrained(mname)
tokenizer_fast = BlenderbotTokenizerFast.from_pretrained(mname)
def generate(tokenizer):
UTTERANCE = "My friends are cool but they eat too many carbs."
inputs = tokenizer([UTTERANCE], return_tensors="pt")
NEXT_UTTERANCE = (
"My friends are cool but they eat too many carbs.</s> <s>That's unfortunate. "
"Are they trying to lose weight or are they just trying to be healthier?</s> "
"<s> I'm not sure."
)
inputs = tokenizer([NEXT_UTTERANCE], return_tensors="pt")
next_reply_ids = model.generate(**inputs)
print("Bot: ", tokenizer.batch_decode(next_reply_ids, skip_special_tokens=True)[0])
generate(tokenizer)
>>> Bot: That's too bad. Have you tried encouraging them to change their eating habits?
generate(tokenizer_fast)
>>> Bot: I see. Well, it's good that they're trying to change their eating habits.I am not sure if this is a known bug or intended. Maybe the changes I proposed is not the correct fix here |
|
Thanks for digging deeper @younesbelkada! Could you check what's the difference between the fast and slow tokenizer from the checkpoint used in this doc example? And compare the difference of Another similar issue (but not related to this one) |
|
I think it's good as we want to default to fast tokenizers (which is the reason we switched to AutoTokenizer) so the fix is the right one in my opinion. |
|
I agree - but just thinking if we should find out what's going wrong and potentially fix the inconsistency between these 2 tokenizers (or something in our codebase). The fix is good for me, and you can merge @younesbelkada ! |
|
Thanks everyone! |
What does this PR do?
This PR fixes the doctest
transformers.models.blenderbot.modeling_blenderbot.BlenderbotForConditionalGeneration.forward. Link to failing job is here: https://github.com/huggingface/transformers/actions/runs/4002271138/jobs/6869333719Updating the prediction with the correct result seems to be the correct fix. I am usure whether this was tested before so I cannot compare for now.
One thing that I suspect is that we get different results across different PT versions, but not sure
cc @ydshieh