\definecolor{ublue}{rgb}{0.152,0.250,0.545} \definecolor{ugreen}{rgb}{0,0.5,0} %%% outline %------------------------------------------------------------------------- \begin{tikzpicture} \tikzstyle{word} = [draw=ugreen!20,minimum size=1.5em, fill=ugreen!40, font=\scriptsize, rounded corners=1pt] \node[rounded corners=3pt, fill=red!20, drop shadow, minimum width=11em,minimum height=4em] (encoder) at (0,0) {Transformer 编码器 }; \node[draw=blue!10,anchor=west, rounded corners=2pt, fill=blue!20,minimum width=2.5cm,minimum height=2em] (attention) at ([xshift=0.8cm]encoder.east) {注意力模块}; \node[anchor=west, rounded corners=3pt, fill=red!20, drop shadow, minimum width=12em,minimum height=4em] (decoder) at ([xshift=0.8cm]attention.east) {Transformer 解码器}; \node[anchor=north,word] (en1) at ([yshift=-1.4em,xshift=-3.6em]encoder.south) {hello}; \node[anchor=north,word] (en2) at ([yshift=-1.4em,xshift=-1.2em]encoder.south) {,}; \node[anchor=north,word] (en3) at ([yshift=-1.4em,xshift=1.2em]encoder.south) {world}; \node[anchor=north,word] (en4) at ([yshift=-1.4em,xshift=3.6em]encoder.south) {!}; \node[anchor=north,word] (de1) at ([yshift=-1.4em,xshift=-5em]decoder.south) {1}; \node[anchor=north,word] (de2) at ([yshift=-1.4em,xshift=-3em]decoder.south) {2}; \node[anchor=north,word] (de3) at ([yshift=-1.4em,xshift=-1 em]decoder.south) {3}; \node[anchor=north,word] (de4) at ([yshift=-1.4em,xshift=1em]decoder.south) {4}; \node[anchor=north,word] (de5) at ([yshift=-1.4em,xshift=3em]decoder.south) {5}; \node[anchor=north,word] (de6) at ([yshift=-1.4em,xshift=5em]decoder.south) {6}; \node[anchor=south,word] (out1) at ([yshift=1.4em,xshift=-5em]decoder.north) {你}; \node[anchor=south,word] (out2) at ([yshift=1.4em,xshift=-3em]decoder.north) {好}; \node[anchor=south,word] (out3) at ([yshift=1.4em,xshift=-1em]decoder.north) {,}; \node[anchor=south,word] (out4) at ([yshift=1.4em,xshift=1em]decoder.north) {世}; \node[anchor=south,word] (out5) at ([yshift=1.4em,xshift=3em]decoder.north) {界}; \node[anchor=south,word] (out6) at ([yshift=1.4em,xshift=5em]decoder.north) {!}; \draw[-latex, very thick,ublue] ([yshift=0.1em]en1.north) -- ([xshift=-3.6em,yshift=-0.1em]encoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]en2.north) -- ([xshift=-1.2em,yshift=-0.1em]encoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]en3.north) -- ([xshift=1.2em,yshift=-0.1em]encoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]en4.north) -- ([xshift=3.6em,yshift=-0.1em]encoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]de1.north) -- ([xshift=-5em]decoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]de2.north) -- ([xshift=-3em]decoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]de3.north) -- ([xshift=-1em]decoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]de4.north) -- ([xshift=1em]decoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]de5.north) -- ([xshift=3em]decoder.south); \draw[-latex, very thick,ublue] ([yshift=0.1em]de6.north) -- ([xshift=5em]decoder.south); \draw[-latex, very thick,ublue] ([xshift=-5em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out1.south); \draw[-latex, very thick,ublue] ([xshift=-3em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out2.south); \draw[-latex, very thick,ublue] ([xshift=-1em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out3.south); \draw[-latex, very thick,ublue] ([xshift=1em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out4.south); \draw[-latex, very thick,ublue] ([xshift=3em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out5.south); \draw[-latex, very thick,ublue] ([xshift=5em,yshift=0.1em]decoder.north) -- ([yshift=-0.1em]out6.south); \draw[-latex, very thick, ublue] (encoder.east) -- (attention.west); \draw[-latex, very thick, ublue] (attention.east) -- (decoder.west); \draw[decorate,decoration={brace, mirror},ublue, very thick] ([yshift=-0.4em]de1.-135) -- node[font=\scriptsize,text=black,yshift=-1em]{预测译文长度 \& 计算位置编码}([yshift=-0.4em]de6.-45); %\begin{pgfonlayer}{background} %{ %\node[rectangle,draw=ublue, inner sep=0mm] [fit =(original1)(ht1)(mt1)(ht1-4)] {}; %} %\end{pgfonlayer} \end{tikzpicture}