-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[Announcement] Changing model type of Barthez #9422
Comments
Applied the change |
Hi @patrickvonplaten. Sorry for the late reply. Actually I tested the model with
Maybe we only need to change We still have the problem of the tokenizer when using AutoTokenizer:
Is it possible to force the api to import and use |
Hey @moussaKam, Thanks for your answer! Yeah the |
Regarding the error with |
Here's a snippet: text_sentence = "Paris est la capitale de la <mask>"
import torch
from transformers import (
AutoTokenizer,
BartForConditionalGeneration
)
barthez_tokenizer = AutoTokenizer.from_pretrained("moussaKam/barthez")
barthez_model = BartForConditionalGeneration.from_pretrained("moussaKam/barthez")
input_ids = torch.tensor(
[barthez_tokenizer.encode(text_sentence, add_special_tokens=True)]
)
mask_idx = torch.where(input_ids == barthez_tokenizer.mask_token_id)[1].tolist()[0]
predict = barthez_model.forward(input_ids)[0]
barthez_tokenizer.decode(predict[:, mask_idx, :].topk(5).indices[0])
The expected output (if we use BarthezTokenizer instead of AutoTokenizer):
|
Ok, @LysandreJik found a nice fix for the tokenizer. Regarding the model, I think from now on we should use |
However, there seems to be an issue remaining with the
but outputs the following on
It also mentions the following:
|
My bad, changing from |
Yeah, Barthez is the only model that is not longer compatible with Bart looking forward - we have to stick to MBart. But the model architecture corresponds 1-to-1 to MBart, so I think it's fine. Hope it's ok for you @moussaKam |
It's OK @patrickvonplaten if BARThez works well with 'France culture francophonie gastronomie mode' if we use |
Ah yeah, so instead of => so the model classes to use in the future are If you could verify that this is actually the case on master now, that would be super nice |
yes the output is reasonable with However we still have one last (I hope) problem when using from transformers import pipeline
pbase = pipeline(task="fill-mask", model="moussaKam/barthez")
src_text = ["Paris est la capitale de la <mask>"]
results = [x["token_str"] for x in pbase(src_text)]
We got the same error when using the the inference api. |
Ah yeah, that's something unrelated to the Bart Split PR I think. Do you mind opening a new issue where you can copy paste your code example from above? Feel free to tag me on it :-) |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
We are currently undergoing some major refactoring of Bart-like models as shown in: #9343.
After the refactoring, the Barthez models would not work anymore with the
AutoModel
andAutoModelForSeq2SeqLM
classes because Barthez actually corresponds more to the mbart model structure than to the Bart structure (compare to PR in #9343), but hasbart
andBartForConditionalGeneration
defined as their default models.In order to make the Barthez models work after merging the PR, the model type needs to be changed online to
mbart
for those models: https://huggingface.co/models?search=barthez . Since MBart is identical to Bart previous to merging the above PR the change won't affect older versions.I want to do the change soon, just wanted to ping you @moussaKam. Please do let me know if you have are not happy with it or have any questions
The text was updated successfully, but these errors were encountered: