Open mqy9787 opened 2 years ago
I am using the mass translation model based on fairseq to apply it to the Django server.Therefore, in the translation phase, I try to use the translate method for reference: https://github.com/pytorch/fairseq/tree/main/examples/translation#example-usage-torchhub
from fairseq.models.xtransformer import XTransformerModel zh2en = XTransformerModel.from_pretrained( '/work/qymeng5/MASS_test/model', checkpoint_file='model.pt', data_name_or_path='/work/qymeng5/MASS_test/vocabulary', #Vocabulary path bpe='subword_nmt', bpe_codes='/work/qymeng5/MASS_test/bpe/all.zh.bpe.codes' #Chinese BPE path )
ff=zh2en.translate('你好 世界') print('ff',ff)
But running this code will report an error. Is it because mass doesn't implement the translate method, or is it my code problem?
The error occurred:‘Generator’ object has no attribute ‘translate’
I am using the mass translation model based on fairseq to apply it to the Django server.Therefore, in the translation phase, I try to use the translate method for reference: https://github.com/pytorch/fairseq/tree/main/examples/translation#example-usage-torchhub
from fairseq.models.xtransformer import XTransformerModel zh2en = XTransformerModel.from_pretrained( '/work/qymeng5/MASS_test/model', checkpoint_file='model.pt', data_name_or_path='/work/qymeng5/MASS_test/vocabulary', #Vocabulary path bpe='subword_nmt', bpe_codes='/work/qymeng5/MASS_test/bpe/all.zh.bpe.codes' #Chinese BPE path )
ff=zh2en.translate('你好 世界') print('ff',ff)
But running this code will report an error. Is it because mass doesn't implement the translate method, or is it my code problem?