microsoft / MASS

MASS: Masked Sequence to Sequence Pre-training for Language Generation
https://arxiv.org/pdf/1905.02450.pdf
Other
1.11k stars 206 forks source link

Does mass implement the translate method? #179

Open mqy9787 opened 2 years ago

mqy9787 commented 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?

mqy9787 commented 2 years ago

The error occurred:‘Generator’ object has no attribute ‘translate’