-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
TF: TFMarianMTModel final logits bias as a layer #18833
Conversation
The documentation is not available anymore as the PR was closed or merged. |
@gante Thanks a lot. It looks like it works well! However, there is one thing I don't understand quite well. (Pdb) [x.name for x in model.non_trainable_weights]
['final_logits_bias:0'] and this is good as it makes loading correctly. But I was thinking I will see Is it true that when we use (I set a breakpoint at in |
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.
Looks good to me, as it works. But I left a question.
Thanks a lot @gante
@ydshieh hah, I had the same question but I tried, it worked, and I forgot to dig deeper to understand why :D After some digging, I found that it is poorly documented -- variables created with This implies that initializing I'm adding a link to this comment in the code, for future reference. |
Thanks a lot @gante , you are the best! |
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.
Looks good to me!
* bias as a layer * alias the bias (hah, it rhymes) * add comment with info
What does this PR do?
Fixes #18802
As stated in the issue above,
final_logits_bias
inTFMarianMTModel
are not being loaded atfrom_pretrained(...)
time. The PT model has this variable defined, and thus the outputs of the model in the two frameworks are very different (>1e-1).Actually, these weights are also not being stored when the TF version is saved, for the same reason -- only layers are stored/loaded with the functions we are using (
.save_weights
and.load_weights
), and this bias weight is not inside a layer.As a solution, this PR moves the bias to a layer and creates an alias for it, resulting in no interface changes. After this change, the models from
Helsinki-NLP
can be converted with thept-to-tf
CLI, passing all the quality checks.