maaf icon indicating copy to clipboard operation
maaf copied to clipboard

Visualize attention

Open huynhtruc0309 opened this issue 4 years ago • 3 comments

Thank you for your work. Can you share the code for visualizing attention?

huynhtruc0309 avatar May 13 '21 07:05 huynhtruc0309

Thanks for your interest in our work! Unfortunately the visualization code would not be easy to share. Briefly, what we did is: (1) modify the Transformer code to save the attention maps to disk, (2) run the model with this modification for each of several inputs, loading the attention map from disk after running each example. (3) For the attention map for "sleeves" for example we subtracted a "baseline" attention map obtained with many random words in the place of "sleeves".

Sorry I can't be of more help with this, at least on short notice.

emdodds avatar May 15 '21 00:05 emdodds

Dear author, Do you give options to run the model basing on each method in this table? image Thank you for your answer.

huynhtruc0309 avatar May 17 '21 11:05 huynhtruc0309

Yes, you can try these variations using the --attn_2stream_mode parameter with --model set to attention. The default xxx_xmm_xff corresponds to the second line of this table. In general you can pass in a string that will be parsed into a sequence of attention operations here.

emdodds avatar May 19 '21 04:05 emdodds