OpenNMT Forum

How can I get some hidden states of model(such as self-attention matrix) during translation

Dear developer
I found translating api only return scores and predictions, but I want the model to return some hidden states, such as self-attention matrix, how can I achieve it?

Is my statement is not clear enough? I don’t know how to get the hidden states of the decoder while translating. can anyone helps me?

Some flags like -attn_debug or -align_debug might help you, but if you want some specific states you’ll probably have to dive in the code to get what you want.
See onmt.decoders.