figure-non-autoregressive.tex 3.19 KB
Newer Older
孟霞 committed
1 2 3 4 5 6
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}

%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
孟霞 committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
	\tikzstyle{word} = [font=\scriptsize]
\node[rounded corners=3pt, fill=red!20, drop shadow, minimum width=10em,minimum height=4em,draw]  (encoder) at (0,0) {Transformer 编码器    };
\node[draw,anchor=west, rounded corners=2pt, fill=orange!20,minimum width=2.5cm,minimum height=2em] (attention) at ([xshift=0.8cm]encoder.east) {注意力模块};
\node[anchor=west, rounded corners=3pt, fill=blue!20, drop shadow, minimum width=10em,minimum height=4em,draw] (decoder) at ([xshift=0.8cm]attention.east) {Transformer 解码器};

\node[anchor=north,word] (en1) at ([yshift=-1.3em,xshift=-3em]encoder.south) {hello};
\node[anchor=north,word] (en2) at ([yshift=-1.6em,xshift=-1em]encoder.south) {,};
\node[anchor=north,word] (en3) at ([yshift=-1.3em,xshift=1em]encoder.south) {world};
\node[anchor=north,word] (en4) at ([yshift=-1.3em,xshift=3em]encoder.south) {!};

\node[anchor=north,word] (de1) at ([yshift=-1.3em,xshift=-3em]decoder.south) {1};
\node[anchor=north,word] (de2) at ([yshift=-1.3em,xshift=-1em]decoder.south) {2};
\node[anchor=north,word] (de3) at ([yshift=-1.3em,xshift=1 em]decoder.south) {3};
\node[anchor=north,word] (de4) at ([yshift=-1.3em,xshift=3em]decoder.south) {4};


\node[anchor=south,word] (out1) at ([yshift=1.3em,xshift=-3em]decoder.north) {你好};
\node[anchor=south,word] (out2) at ([yshift=1.3em,xshift=-1em]decoder.north) {};
\node[anchor=south,word] (out3) at ([yshift=1.3em,xshift=1em]decoder.north) {世界};
\node[anchor=south,word] (out4) at ([yshift=1.3em,xshift=3em]decoder.north) {};


\draw[->, thick] ([yshift=0.1em]en1.north) -- ([xshift=-3em,yshift=-0.1em]encoder.south);
\draw[->, thick] ([yshift=0.3em]en2.north) -- ([xshift=-1em,yshift=-0.1em]encoder.south);
\draw[->, thick] ([yshift=0.1em]en3.north) -- ([xshift=1em,yshift=-0.1em]encoder.south);
\draw[->, thick] ([yshift=0.1em]en4.north) -- ([xshift=3em,yshift=-0.1em]encoder.south);

\draw[->,thick] ([yshift=0.1em]de1.north) -- ([xshift=-3em]decoder.south);
\draw[->, thick] ([yshift=0.1em]de2.north) -- ([xshift=-1em]decoder.south);
\draw[->, thick] ([yshift=0.1em]de3.north) -- ([xshift=1em]decoder.south);
\draw[->, thick] ([yshift=0.1em]de4.north) -- ([xshift=3em]decoder.south);

\draw[->, thick] ([xshift=-3em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out1.south);
\draw[->, thick] ([xshift=-1em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out2.south);
\draw[->, thick] ([xshift=1em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out3.south);
\draw[->, thick] ([xshift=3em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out4.south);


\draw[->,line width=1.5pt] (encoder.east) -- (attention.west);
\draw[->,line width=1.5pt] (attention.east) -- (decoder.west);

\draw[decorate,decoration={brace, mirror},ublue, very thick] ([xshift=0.5em,yshift=-0.4em]de1.-135) -- node[font=\scriptsize,text=black,yshift=-1em]{预测译文长度 \& 计算位置编码}([xshift=-0.5em,yshift=-0.4em]de4.-45);
孟霞 committed
49 50 51 52 53 54 55 56 57 58 59 60 61

%\begin{pgfonlayer}{background}
%{
%\node[rectangle,draw=ublue, inner sep=0mm] [fit =(original1)(ht1)(mt1)(ht1-4)] {};
%}
%\end{pgfonlayer}


\end{tikzpicture}