Skip to content

Instantly share code, notes, and snippets.

@taoyds
Created March 20, 2020 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save taoyds/06ff21d20703dffa17b86afa4ea01300 to your computer and use it in GitHub Desktop.
Save taoyds/06ff21d20703dffa17b86afa4ea01300 to your computer and use it in GitHub Desktop.
from fairseq.models.transformer import TransformerModel
zh2en = TransformerModel.from_pretrained(
'/path/to/checkpoints',
checkpoint_file='checkpoint_best.pt',
data_name_or_path='data-bin/wmt17_zh_en_full',
bpe='subword_nmt',
bpe_codes='data-bin/wmt17_zh_en_full/zh.code'
)
zh2en.translate('你好 世界')
# 'Hello World'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment