Decoding problem for char-based translation
Hi,
I modified the wmt_ende_characters to translate Macedonian to English (bleu-score after training was 0.526888).
The input sentence is:
Kosovskiot proces na privatizaciјa se ispituva
Then the t2t_trainer command shows some weird output:
INFO:tensorflow:Restoring parameters from t2t_train/model.ckpt-250000
INFO:tensorflow:Inference results INPUT: Mquqxumkqv"rtqegu"pc"rtkxcvk|cekӚc"ug"kurkvwxc
INFO:tensorflow:Inference results OUTPUT: Mukwak.cwave.gurk.fe.ce.sce.gurkwe.ce.ce
INFO:tensorflow:Writing decodes into test.txt.transformer.transformer_base.beam4.alpha0.6.decodes
Tested with version 1.0.5 and 1.0.7. Is this a bug?
It is a bit strange that the character-based generators in wmt.py do not use text_encoder.ByteTextEncoder() for encoding the source and target strings to vectors, but simply do a raw conversion of character ordinal values to vectors. I am working on a PR that fixes this, and at least in preliminary testing the output looks much saner.
More precisely, there is a mismatch between wmt.py and problem_hparams.py for the WMT-based character level translations. problem_hparams.py specifies ByteTextEncoding, while wmt.py doesn't (it uses straight-through character ordinals and doesn't add 2 to them for
Yes, as Villi says, this is probably a bug. Thanks for finding out Villi! We are working on a change that merges the setting for generator with problem_hparams, so it'd be harder to make these bugs, but that's not ready yet.
I can confirm that with the fix, i.e. patching wmt.py to use ByteTextEncoding in functions that call character_generator(), the output is correct (and quite impressive btw). Will post a PR for this that you can accept if you think it's useful before your change @lukaszkaiser.
That would be wonderful, yes, we welcome a PR! And great thanks for all the python3 work too :).
In fact I'm getting unbelievably good results on wmt_ende_characters. After 80.000 training steps on a single GPU with batch_size=4096 (yes, that works) and 10 evaluation steps:
metrics-wmt_ende_characters/bleu_score = 0.613493
metrics-wmt_ende_characters/neg_log_perplexity = -0.702434
metrics/accuracy = 0.819122
Am I missing something, or are these metrics correct? The output does look very good when inspecting it.
Beware that these are character-level metrics! Of course character-level accuracy is much higher than word-level one, and the same goes for neg-log-perplexity and the BLEU metric (as it's measured wrt. the integer ids provided, not with a separate tokenizer like the one in the paper). The Transformer should not get too much worse when using characters instead of tokens, so I'd hope for reasonable results. The only way to have comparable metrics is to decode the test set (but you might need to tweak ALPHA and BEAM_SIZE) and run the BLEU eval from MOSES.
Oops - of course! (But it would indeed be interesting to see proper (word-based) BLEU metrics generated from the test set for character-level vs. wordpiece vs. full word, using the same training time for all three approaches.)
@stefan-it
I modified the wmt_ende_characters to translate Macedonian to English...
How did you manage to import your own training data into wmt_ende_characters? Could you please provide some hints?
I think this is solved by PR#46 (thanks Villi!), so I'm closing this. Please reopen if you see problems.