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

pytorch加载simbert问题 #12

Closed
Nipi64310 opened this issue Apr 12, 2021 · 2 comments
Closed

pytorch加载simbert问题 #12

Nipi64310 opened this issue Apr 12, 2021 · 2 comments

Comments

@Nipi64310
Copy link

hello 苏神 请问pytorch加载simbert问题。

直接用transformers的包加载,维度会不一致
image

看起来tf的权重是embedding部分多了一个linear层,torch版本没有这一层[bert/encoder/embedding_hidden_mapping_in/]
image

为什么开源权重多了这部分,是不是,torch版本的model的embedding部分加上这个linear,然后加载即可。

@Nipi64310
Copy link
Author

torch版本的权重的 embedding的layernorm部分,size是d.state_dict()['embeddings.LayerNorm.weight'].size()
torch.Size([312])
开源的tf权重部分,size是 128

sorry, 上面2个图贴错了,实际上一个是tiny 312,一个是small 384的,出现的情况是一样的。

@bojone
Copy link

bojone commented May 24, 2021

small版和tiny版的embedding层像albert一样用了低秩分解,base版本正常。应该是这个转换脚本可以考虑到低秩分解。

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

No branches or pull requests

2 participants