interactivate.py can not generate translation result
The commond as follows: python interactive.py data-bin/wmt14_en_de --path checkpoints/transformer/checkpoint_best.pt --beam 5 --remove-bpe --source-lang en --target-lang de however the interactivate.py can not generate translation result I want. The result as follows: Namespace(beam=5, buffer_size=1, cpu=False, data=['/dnn4_added/zhangxiaolei/back_translation/fair-temp/fairseq//data-bin/wmt14_en_de'], diverse_beam_groups=1, diverse_beam_strength=0.5, fp16=False, fp16_init_scale=128, fp16_scale_window=None, gen_subset='test', left_pad_source='True', left_pad_target='False', lenpen=1, log_format=None, log_interval=1000, max_len_a=0, max_len_b=200, max_sentences=1, max_source_positions=1024, max_target_positions=1024, max_tokens=None, min_len=1, model_overrides='{}', nbest=1, no_beamable_mm=False, no_early_stop=False, no_progress_bar=False, num_shards=1, path='/dnn4_added/zhangxiaolei/back_translation/fair-temp/fairseq//checkpoints/transformer/checkpoint_best.pt', prefix_size=0, print_alignment=False, quiet=False, raw_text=False, remove_bpe='@@ ', replace_unk=None, sampling=False, sampling_temperature=1, sampling_topk=-1, score_reference=False, seed=1, shard_id=0, skip_invalid_size_inputs_valid_test=False, source_lang='en', target_lang='de', task='translation', unkpen=0, unnormalized=False, upsample_primary=1) | [en] dictionary: 40360 types | [de] dictionary: 42720 types | loading model(s) from /dnn4_added/zhangxiaolei/back_translation/fair-temp/fairseq//checkpoints/transformer/checkpoint_best.pt | Type the input sentence and press return: Two sets of lights so close to one another : intentional or just a silly error ? O Two sets of lights so close to one another : intentional or just a silly error ? H -3.237684726715088 , , , , , P -3.1607 -3.1607 -3.1607 -3.1607 -3.1607 -3.6224 Yesterday , Gutacht 's Mayor gave a clear answer to this question . O Yesterday , Gutacht 's Mayor gave a clear answer to this question . H -3.237684726715088 , , , , , P -3.1607 -3.1607 -3.1607 -3.1607 -3.1607 -3.6224
The questions:
- I use the interactivate.py to translate the sequence I input , however only H line and P line are printed out ,where is the result
I uses the generate.py without –reference-score : python generate.py $TEXT/data-bin/wmt14_en_de --path $TEXT/checkpoints/transformer/checkpoint_best.pt --beam 5 --remove-bpe --source-lang en --target-lang de --gen-subset test output as follows:
S-1910 Just five minutes before kick @-@ off , the Capo climbed onto his podium - and the tension that had been almost tangible up until that point , lifted with a large shout , as Dickel asked for a shout from each section of fans as usual .
T-1910 Erst fünf Minuten vor dem Anpfiff erklomm der Capo sein Podest - und die bis dahin geradezu mit Händen greifbare Anspannung entlud sich in einem lauten Schrei , als Dickel wie gewohnt die Stimmung auf den Rängen im Stadion abfragte .
H-1910 -3.2376880645751953 , , , , ,
P-1910 -3.1608 -3.1608 -3.1608 -3.1608 -3.1608 -3.6224
| Translated 3003 sentences (18018 tokens) in 6.4s (469.52 sentences/s, 2817.09 tokens/s)
| Generate test with beam=5: BLEU4 = 0.00, 24.8/0.0/0.0/0.0 (BP=0.037, ratio=0.233, syslen=15015, reflen=64506)
Question: 2. The T line is from the test.de file ,which come reference file not the translation result. How to set the command can I get my models translation result
I will respond here instead of in your personal email, so if people have similar issues in the future, they can search and find my response.
From the output you pasted, there is no problem with interactive.py. Since interactive.py is interactive, there is no "target" line. Otherwise, O represents your input, H the hypothesis, and P the token level log probabilities. This corresponds to the output you see from generate.py.
The issue is that your model does not seem to be well trained. As you can see from the output of both interactive.py and generate.py, the Hypothesis line is just commas. This indicates some sort of bad training.
I would look into it in the following steps: 1- if you download one of our pretrained models and run the provided generation commands, does that work? 2- please look at the training log of your model and make sure the loss is decreasing, etc.
thanks.
Also if you trained your model with BPE, then you need to apply BPE to your input before passing it to interactive.py.
Hi I am using a pretrained model English (en) to French (fr) based on fconv . Model is loaded through interactive.py the sentence to be given is said to be raw input. Is it Moses tokenized (normalize punctuation , clean corpus level clean the practical sentence, remove non-printing char , tokenizer ) and then BPE applied OR is it just BPE applied and when I get hypothesis I need to do the reverse like remove bpe (but is already given as command line argumrnt and hence I suppose explicitly is not needed) and detokenize using moses . suppose I give :: O hi how are you H -0.8601110577583313 hi comment êtes @-@ vous P -0.9665 -2.3938 -1.1932 -0.1428 -0.0566 -0.4077
Where Am I going Wrong? @huihuifan How to run inference @myleott using this (https://github.com/pytorch/fairseq/blob/master/fairseq/models/fairseq_incremental_decoder.py)
preprocessing is detailed here: https://github.com/pytorch/fairseq/tree/master/examples/translation
please see the section on english-french.
You do not need to run the fairseq_incremental_decoder.py script yourself. The fconv model inherits from the incremental decoder class and decoding is already incremental if you run generate.py or interactive.py.
Thank you
But the type of preprocessing for English to French based on scaling neural translation model is not given In order to replicate the results, since the dataset en-de is already applied bpe and preprocessed on a joined dictionary. #202 solved to an extent but are the results replicated?
And please state is their an easy way to state architecture as transformer base without specifying base args expilcitly as in https://github.com/pytorch/fairseq/blob/master/fairseq/models/transformer.py where for en-fr task base architecture calling this model ( transformer_wmt_en_de) would it be sufficient?
Since in big architectures dropouts are varied according to tasks (de , fr) Similarly for the base even are there any variants according to language or one would suffice? @huihuifan
can you please provide pre-trained models of scaling neural translation on fp16 @myleott
@gvskalyan, pretrained models are available here: https://github.com/pytorch/fairseq#translation. Those models were trained with FP16.
To preprocess the en-fr data, please follow the instructions here, adding --joined-dictionary: https://github.com/pytorch/fairseq/tree/master/examples/translation#prepare-wmt14en2frsh
The corresponding training command for 128 GPUs:
python train.py data-bin/wmt14_en_fr_joined \
--arch transformer_vaswani_wmt_en_fr_big --share-all-embeddings \
--optimizer adam --adam-betas '(0.9, 0.98)' --clip-norm 0.0 \
--lr-scheduler inverse_sqrt --warmup-init-lr 1e-07 --warmup-updates 4000 \
--lr 0.0007 --min-lr 1e-09 \
--dropout 0.1 --weight-decay 0.0 --criterion label_smoothed_cross_entropy --label-smoothing 0.1 \
--max-tokens 5120 \
--fp16 --max-update 80000
If using fewer GPUs or smaller --max-tokens, then please set the --update-freq accordingly.
Re: Transformer base, you can use transformer_wmt_en_de and for Transformer big use transformer_vaswani_wmt_en_de_big. You can see all the architecture definitions here: https://github.com/pytorch/fairseq/blob/master/fairseq/models/transformer.py#L835-L915.
While these architectures work fairly well for many datasets, they are not universal. For smaller datasets you'll often need to use a smaller model to avoid overfitting. Similarly you may need to tune dropout and learning rate.
How good is the export to caffe2 via ONNX to a fairseq 32/16 bit trained model on a CPU device using https://github.com/pytorch/translate Is the inference a lot faster compared to pytorch models @myleott , If yes then by what times (approx.), say for a batch of large batch size on an average
@huihuifan hi I want to translate source senquence without reference after preprocessing source sentense with --only-source.. however python generate.py data-bin --path checkpoints/transformer/checkpoint_best.pt --batch-size 128 --beam 5 --remove-bpe --source-lang en error FileNotFoundError: [Errno 2] No such file or directory: 'data-bin/dict.jp.txt I want to know which param should be set .
@zll0000 there is some issue here. Preprocessing with --only-source is for language modeling. If you have a source sequence without reference, you can use interactive decoding. But the specific error you see here is because there is no directory called data-bin with your dict.jp.txt file in it...
@huihuifan thank you !!I see
Hello @huihuifan @myleott, I guess the hypothesis are generated according to the line length thus changing the original line number order. I want to know if there is any option to generate the hypothesis in the original line sequence, i.e the output should be in the folowing sequence
S-1
T-1
H-1
S-2
T-2
H-2 ... and so on.
@masonreznov Hi, it is probably too late for the answer but it might help somebody:
OUTPUT = "result.txt" grep ^H $OUTPUT | sed 's/^H-//g' | sort -k1,1n | cut -f 3 | sed 's/ ##//g' > hyp.txt grep ^T $OUTPUT | sed 's/^T-//g' | sort -k1,1n | cut -f 2 | sed 's/ ##//g' > ref.txt