Views
No views yet
1from transformers import FSMTForConditionalGeneration, FSMTTokenizer
2mname = "allenai/wmt19-de-en-6-6-big"
3tokenizer = FSMTTokenizer.from_pretrained(mname)
4model = FSMTForConditionalGeneration.from_pretrained(mname)
5
6input = "Maschinelles Lernen ist großartig, nicht wahr?"
7input_ids = tokenizer.encode(input, return_tensors="pt")
8outputs = model.generate(input_ids)
9decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
10print(decoded) # Machine learning is great, isn't it?
11| model | transformers |
|---|---|
| wmt19-de-en-6-6-big | 39.9 |
1git clone https://github.com/huggingface/transformers
2cd transformers
3export PAIR=de-en
4export DATA_DIR=data/$PAIR
5export SAVE_DIR=data/$PAIR
6export BS=8
7export NUM_BEAMS=5
8mkdir -p $DATA_DIR
9sacrebleu -t wmt19 -l $PAIR --echo src > $DATA_DIR/val.source
10sacrebleu -t wmt19 -l $PAIR --echo ref > $DATA_DIR/val.target
11echo $PAIR
12PYTHONPATH="src:examples/seq2seq" python examples/seq2seq/run_eval.py allenai/wmt19-de-en-6-6-big $DATA_DIR/val.source $SAVE_DIR/test_translations.txt --reference_path $DATA_DIR/val.target --score_path $SAVE_DIR/test_bleu.json --bs $BS --task translation --num_beams $NUM_BEAMS@misc{kasai2020deep,
title={Deep Encoder, Shallow Decoder: Reevaluating the Speed-Quality Tradeoff in Machine Translation},
author={Jungo Kasai and Nikolaos Pappas and Hao Peng and James Cross and Noah A. Smith},
year={2020},
eprint={2006.10369},
archivePrefix={arXiv},
primaryClass={cs.CL}
}