figure-example-of-beam-search.tex 6.71 KB
Newer Older
1 2 3
\begin{tikzpicture}	
	\tikzstyle{unit} = [inner sep=1pt,align=center,minimum width=3.5em,minimum height=2em,font=\large]
		
4 5
	\node[fill=red!40,inner sep=2pt,minimum width=5em](vocab)at(0,0){\color{white}{\small\bfnew{词表}}};
	\node[fill=red!20,anchor=north,align=left,inner sep=3pt,minimum width=5em](words)at(vocab.south){There\\[-0.5ex]Here\\[-0.5ex]is\\[-0.5ex]one\\[-0.5ex]an\\[-0.5ex]appple};
6
	\node[fill=blue!40,anchor=north,align=left,inner sep=2pt,minimum width=5em](spe)at(words.south){\color{white}{\small\bfnew{特殊符号}}};
7 8 9 10
	\node[fill=blue!10,anchor=north,align=left,inner sep=3pt,minimum width=5em](eos)at(spe.south){$<$sos$>$\\[-0.5ex]$<$eos$>$};

%	\node[anchor=north,minimum width=1.8em,minimum height=1em,fill=blue!10] (l1) at ([yshift=-1em]eos.south){};
%	\node[anchor=north,minimum width=1.8em,minimum height=1em,fill=red!10] (l2) at ([yshift=-0.5em]l1.south){};
11
		
12
	\node[anchor=north,unit] (w1) at ([xshift=0em,yshift=-1.8em]eos.south){$w_1$};
13
	\node[anchor=north,unit,fill=blue!10] (n11) at ([yshift=-0.5em]w1.south){$<$sos$>$};
14
		
15
	\node[anchor=west,unit,fill=red!20,opacity=0.3] (n24) at ([xshift=6.5em,yshift=4.3em]n11.east){an};
16
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt24) at (n24.east) {\small{{\color{white} \textbf{-1.4}}}};
17
	\node[anchor=south,unit,fill=red!20] (n23) at ([yshift=0.1em]n24.north){one};
18
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt23) at (n23.east) {\small{{\color{white} \textbf{-0.6}}}};
19
	\node[anchor=south,unit,fill=red!20] (n22) at ([yshift=0.1em]n23.north){Here};
20
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt22) at (n22.east) {\small{{\color{white} \textbf{-0.3}}}};
21
	\node[anchor=south,unit,fill=red!20] (n21) at ([yshift=0.1em]n22.north){There};
22 23 24
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt21) at (n21.east) {\small{{\color{white} \textbf{-0.2}}}};
		
		
25
	\node[anchor=north,unit,fill=red!20,opacity=0.3] (n25) at ([yshift=-0.1em]n24.south){is};
26
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt25) at (n25.east) {\small{{\color{white} \textbf{-2.2}}}};
27
	\node[anchor=north,unit,fill=red!20,opacity=0.3] (n26) at ([yshift=-0.1em]n25.south){apple};
28
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt26) at (n26.east) {\small{{\color{white} \textbf{-2.6}}}};
29
	\node[anchor=north,unit,fill=blue!10,opacity=0.3] (n27) at ([yshift=-0.1em]n26.south){$<$eos$>$};
30
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt27) at (n27.east) {\small{{\color{white} \textbf{-7.2}}}};
单韦乔 committed
31
	\node[anchor=south,unit] (w2) at ([yshift=0.5em]n21.north){$w_2$};
32
		
33
	\node[anchor=west,unit,fill=red!20] (n31) at ([yshift=4.7em,xshift=8em]n21.east){is};
34
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt31) at (n31.east) {\small{{\color{white} \textbf{-0.1}}}};
35
	\node[anchor=north,unit,fill=blue!10] (n32) at ([yshift=-0.1em]n31.south){$<$eos$>$};
36
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt32) at (n32.east) {\small{{\color{white} \textbf{-0.6}}}};
37
	\node[anchor=north,unit,fill=red!20,opacity=0.3] (n33) at ([yshift=-0.1em]n32.south){an};
38
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt33) at (n33.east) {\small{{\color{white} \textbf{-2.4}}}};
39
	\node[anchor=north,unit,fill=red!20,opacity=0.3] (n34) at ([yshift=-0.1em]n33.south){one};
40
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt34) at (n34.east) {\small{{\color{white} \textbf{-2.6}}}};
41
	\node[anchor=north,unit,fill=red!20,opacity=0.3] (n35) at ([yshift=-0.1em]n34.south){Here};
42
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt35) at (n35.east) {\small{{\color{white} \textbf{-2.9}}}};
43
	\node[anchor=north,unit,fill=red!20,opacity=0.3] (n36) at ([yshift=-0.1em]n35.south){apple};
44
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt36) at (n36.east) {\small{{\color{white} \textbf{-3.2}}}};
45
	\node[anchor=north,unit,fill=red!20,opacity=0.3] (n37) at ([yshift=-0.1em]n36.south){There};
46 47
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt37) at (n37.east) {\small{{\color{white} \textbf{-4.1}}}};
		
48
	\node[anchor=north,unit,fill=red!20] (n41) at ([yshift=-0.1em]n37.south){is};
49
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt41) at (n41.east) {\small{{\color{white} \textbf{-0.1}}}};
50
	\node[anchor=north,unit,fill=red!20,opacity=0.3,minimum width=3.5em,minimum height=2.5em] (n51) at ([yshift=-0.1em]n41.south){};
51
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.5em,fill=black,opacity=0.3] (pt51) at (n51.east) {\small{{\color{white} \textbf{$<$-0.7}}}};
52
	\node[anchor=south,unit] (w3) at ([yshift=0.5em]n31.north){$w_3$};
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
		
	\draw[->,ublue,very thick] (n11.east) -- (n21.west);
	\draw[->,ublue,very thick] (n11.east) -- (n22.west);
	\draw[->,ublue,very thick] (n11.east) -- (n23.west);
	\draw[->,ublue!20,very thick] (n11.east) -- (n24.west);
	\draw[->,ublue!20,very thick] (n11.east) -- (n25.west);
	\draw[->,ublue!20,very thick] (n11.east) -- (n26.west);
	\draw[->,ublue!20,very thick] (n11.east) -- (n27.west);
	
	\draw[->,ublue!20,very thick] (pt21.south) -- (n33.west);
	\draw[->,ublue!20,very thick] (pt21.south) -- (n34.west);
	\draw[->,ublue!20,very thick] (pt21.south) -- (n35.west);
	\draw[->,ublue!20,very thick] (pt21.south) -- (n36.west);
	\draw[->,ublue!20,very thick] (pt21.south) -- (n37.west);
	\draw[->,ublue,very thick] (pt21.south) -- (n31.west);
	\draw[->,ublue,very thick] (pt21.south) -- (n32.west);
		
	\draw[->,ublue!20,very thick] (pt22.south) -- (n51.west);
	\draw[->,ublue,very thick] (pt22.south) -- (n41.west);
	\draw[->,ublue!20,very thick] (pt23.south) -- (n51.west);
		
	\draw[decorate,decoration={brace},red,very thick] (pt24.south east) -- (pt27.south west);
单韦乔 committed
75
	\node[inner sep=0pt] at ([yshift=-2em,xshift=2em]pt25.east){剪枝};
76
	\draw[decorate,decoration={brace},red,very thick] (pt33.south east) -- (pt37.south west);
单韦乔 committed
77 78
	\node[inner sep=0pt] at ([xshift=2em,yshift=-1em]pt35.east){剪枝};
	\node[inner sep=0pt] at ([yshift=-1.5em,xshift=2em]pt51.east){剪枝};
79 80 81 82 83 84 85 86 87
		
	\draw[->,ublue,very thick] (pt31.south) -- ([yshift=0.6em,xshift=0.6em]pt31.south);
	\draw[->,ublue,very thick] (pt31.south) -- ([xshift=0.7em]pt31.south);
	\draw[->,ublue,very thick] (pt31.south) -- ([yshift=-0.6em,xshift=0.6em]pt31.south);

	\draw[->,ublue,very thick] (pt41.south) -- ([yshift=0.6em,xshift=0.6em]pt41.south);
	\draw[->,ublue,very thick] (pt41.south) -- ([xshift=0.7em]pt41.south);
	\draw[->,ublue,very thick] (pt41.south) -- ([yshift=-0.6em,xshift=0.6em]pt41.south);
\end{tikzpicture}