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

fairseq翻译模型的推理 #3

Open
dearchill opened this issue Sep 28, 2021 · 1 comment
Open

fairseq翻译模型的推理 #3

dearchill opened this issue Sep 28, 2021 · 1 comment

Comments

@dearchill
Copy link

你好,我在说明文档里看到fairseq框架下gpt-2的使用方法,但没有找到transformer结构的翻译模型的推理方法。我参照说明

Replace the original transformer.py in Fairseq with our transformer.py and reinstall the Fairseq, that is all !

在使用fairseq-generate时报错,说是找不到transformer arch,我发现项目提供的transformer.py文件里没有模型结构注册的地方,只有decoder和embedding等相关的部分,找不到encoder相关的部分。所以我保留了原始的transformer文件,把项目提供的transformer作为新文件,然后把项目extra/fairseq/sequence_generator.py覆盖了原fairseq目录下的sequence_generator(我没理解错的话这里的sequence_generator.py是重写的generator),然后在运行推理时报错:
File "/examples/NMT/fairseq/fairseq/sequence_generator.py", line 811, in forward_decoder
decoder_out = model.decoder.forward(tokens, encoder_out=encoder_out, first_pass=first_pass)
TypeError: forward() got an unexpected keyword argument 'first_pass'

看起来是由于项目重写的EETTransformerDecoder与原来的TransformerDecoder参数不一致导致。
所以想要请教一下有没有什么好的方法来对fairseq训练的翻译模型推理加速吗?

@dingjingzhen
Copy link
Collaborator

请问你这个模型是标准的transformer模型(seq2seq)吗?fairseq的版本是哪一个,目前我们只支持了gpt2和bert,我们正在搞seq2seq模型,可能过几天就能支持了。刚建了个VX群,你可以加一下交流群,我帮忙具体看一下
a5c1117c8beb95e9908b628e8877af2

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