OpenNMT-tf replace_unknown_target does not work


(hanky) #1

Hi,
From what I read is that if replace_unknown_target is true and a source word is out of vocabulary, the network will copy this value in target.
But this case does not valid on my model. It still returns words that exists in train-vocab
I’m using opennmt-defaults.yml with replace_unknown_target: true added in params section.
I’m using OpenNMT-tf 5 with tensoflow 1.8.
model_type during train and eval is NMTSmall
Does anything wrong with my configuration? Or did I miss something?

Best regards,
henky


(Guillaume Klein) #2

Hello,

Maybe you misread the documentation:

Replace unknown target tokens by the original source token with the highest attention

It looks at OOV target tokens, not source.


(hanky) #3

Thanks @guillaumekln,
My case is that I want to keep name, address and others in source sentence exists in target sentence. Is this option will enable me to do that? Can I just set unk for that piece in tgt-train.val ?


(Guillaume Klein) #4

This is a recurring question around here but it is not an easy task. replace_unknown_target can partially do that if the produced target token is actually OOV and the attention returned by the model is “correct”.

A more robust approach would be to replace all entities with some sort of placeholder tokens, and use an external alignment tool as post-processing to replace them with their original value.


(hanky) #5

Thank you @guillaumekln
That is very helpful of you.


(hanky) #6

Hi @guillaumekln,
On this external alignment tool you said, is that mean that src-train/val, tgt-train/val passed to the trainer is the aligned file? Which also means src-train and tgt-train passed to vocab builder is this aligned file.

regards,
henky