Skip to content

Does mass implement the translate method? #179

@mqy9787

Description

@mqy9787

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions