-
Notifications
You must be signed in to change notification settings - Fork 679
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
加载GPT2LMHeadModel编码错误啊 #43
Comments
最新的transformer只需要输入目录,并且把名改成pytorch_model.bin |
我想问一下,怎么把里面的词向量和词取出来。。。 |
你用我图里面的代码读进模型,然后就可以使用huggingface/transformers的例子操作了 |
我读进去了,但是不知道怎么取。。我就想把那个词向量搞出来,变成word[空格]embedding的格式,不好意思啊,可能问题有点弱智。。。 |
根据huggingface/transformers的例子就好了啊:
这个repo是基于huggingface的。推荐你阅读huggingface/transformers这个库,首页就有Quick tour。 |
嗯,我知道这个,所以我如果要搞词向量出来,我就一个一个encode词么,我以为有那种直接取的操作。谢谢!! |
额 ... 我明白你的意思是。BERT是动态语言模型,token对应的emb只是浅层的,过了这12层MHA的词向量才是准确的词向量。如果你想提取出最初的token对应的emb,这个理论上是可以直接提取的,你分析一下它的nn层有哪些,把第一层截取出来就行了。我没试过哦,加油! |
好像这样就可以了。里面的29522是词的indx,如果那个vocab文件是按照indx排列的话,就可以生成我那个文件了。
|
想单独加载出来,发现报错了,咋回事 ...
The text was updated successfully, but these errors were encountered: