Commit 8dd39ec8 by zengxin

合并分支 'master' 到 'zengxin'

Master

查看合并请求 !150
parents 7fa9dfc5 00069028
......@@ -14,10 +14,12 @@
\node [datanode,anchor=north] (s4) at ([yshift=-4.5em]s3.south) {{ \small{语言4}}};
\node [circle,anchor=north west,inner sep=2pt,fill=blue!20] (m1) at ([xshift=0.8em,yshift=-0.5em]s1.south east) {{ \small{中间语言}}};
\draw [<->,very thick] (s1.south) -- (m1.west);
\draw [<->,very thick] (s2.north) -- (m1.west);
\draw [<->,very thick] (s3.south) -- (m1.east);
\draw [<->,very thick] (s4.north) -- (m1.east);
\draw [<->,very thick] (s1.south) -- (m1.170);
\draw [<->,very thick] (s2.north) -- (m1.190);
\draw [<->,very thick] (s3.south) -- (m1.10);
\draw [<->,very thick] (s4.north) -- (m1.-10);
\node [anchor=north] (l) at ([xshift=5em,yshift=-1em]s2.south) {\footnotesize{(a) 基于中间语言的方法}};
\end{scope}
......@@ -40,6 +42,8 @@
\draw [<->,very thick] (s1.south east) -- (s4.north west);
\draw [<->,very thick] (s2.north east) -- (s3.south west);
\node [anchor=north] (l) at ([xshift=5em,yshift=-1em]s2.south) {\footnotesize{(b) 基于转换的方法}};
\end{scope}
\end{tikzpicture}
......
......@@ -2,35 +2,30 @@
%%% 句法树(层次短语)
\begin{tikzpicture}
{\small
\begin{scope}[sibling distance=10pt, level distance = 20pt]
\begin{scope}[sibling distance=15pt, level distance = 20pt]
{\scriptsize
\Tree[.\node(n1){\textbf{zj}};
[.\node(n2){\textbf{dj}};
[.\node(n3){\textbf{np}}; \node(cw1){}; ]
[.\node(n4){\textbf{vp}};
[. \node(cw1){pp};
[. \node(cw2){}; ]
[. \node(cw3){np};
[. \node(cw4){mp};
[. \node(p1){}; ]
[. \node(p2){}; ]
]
[. \node(cw5){np}; \node(p3){}; ]
\Tree[.\node(r){IP};
[.\node(n11){NP}; [.\node(n21){PN}; [.\node(l1){};]]]
[.\node(n12){VP};
[.\node(n22){BA}; \node(l2){}; ]
[.\node(n23){IP};
[. \node(n31){NP};
[. \node(n41){QP};
[. \node(n51){CD}; \node(l3){};]
[. \node(n52){CLP}; [.\node(n61){M}; [.\node(l4){};]]]
]
[. \node(n42){NP}; [.\node(n53){NN}; [.\node(l5){};]]]
]
[. \node(cw6){vp};
[. \node(cw7){}; ]
[. \node(cw8){pp};
[. \node(cw9){}; ]
[. \node(cw10){sp};
[. \node(cw11){}; ]
[. \node(cw12){}; ]
]
[. \node(n32){VP};
[. \node(n43){VV}; \node(l6){放在};]
[. \node(n44){LCP};
[. \node(n54){NP}; [.\node(n62){NN}; [.\node(l7){};]]]
[. \node(n55){LC}; \node(l8){};]
]
]
]
]
]
[.\node(n5){\textbf{}}; ]
[.\node(n13){PU}; \node(l9){};]
]
}
\end{scope}
......
......@@ -6,7 +6,7 @@
\begin{tikzpicture}
%第一段----------------------------------------------
%原文-------------
\node [pos=0.4,left,xshift=-0.4em,yshift=2.0em] (original1) {\scriptsize{ \qquad:从前有一个小岛,上面住着快乐、悲哀、知识和爱,还有其他各种情感。一天,情感们得知}};
\node [pos=0.4,left,xshift=-0.4em,yshift=2.0em] (original1) {\scriptsize{\ \ \ \ :从前有一个小岛,上面住着快乐、悲哀、知识和爱,还有其他各种情感。一天,情感们得知}};
\node [anchor=north west] (original1-1) at ([xshift=3.5em,yshift=0.3em]original1.south west) {\scriptsize{小岛快要下沉了。于是,大家都准备船只,离开小岛,只有爱决定留下来,她想坚持到最后}};
\node [anchor=north west] (original1-2) at ([yshift=0.3em]original1-1.south west) {\scriptsize{一刻。过了几天,小岛真的要下沉了,爱想请人帮忙。}};
%机器翻译--------------
......@@ -27,53 +27,10 @@
\node [anchor=north west] (ht1-3) at ([yshift=0.4em]ht1-2.south west) {\scriptsize{{\color{red}\underline{-mined to}} persist till the last moment.A few days later, almost the whole island sunk into the sea,}};
\node [anchor=north west] (ht1-4) at ([yshift=0.4em]ht1-3.south west) {\scriptsize{and LOVE had to {\color{red}\underline{seek for help.}}}};
%第二段--------------------------------
%原文-------------
\node[anchor=north west] (original4) at ([xshift=-3.5em,yshift=-0.3em]ht1-4.south west) {\scriptsize{\qquad 文:这时,富裕乘着一艘大船经过。爱说:``富裕,你能带我走吗?''富裕 答道:``不,我的船中}};
\node[anchor=north west] (original4-1) at ([xshift=3.5em,yshift=0.3em]original4.south west) {\scriptsize{有许多金银财宝,没有你的位置。''爱看见虚荣在一艘华丽的小船上,说:``虚荣,帮帮我吧}};
\node[anchor=north west] (original4-2) at ([yshift=0.3em]original4-1.south west) {\scriptsize{!''``我帮不了你。你全身都湿透了,会弄坏我这漂亮的小船的。''悲哀来了,爱向他求助:``}};
\node[anchor=north west] (original4-3) at ([yshift=0.3em]original4-2.south west) {\scriptsize{悲哀,让我跟你去吧!''``哦,……爱,我实在太悲哀了,想自己一个人呆一会儿!''悲哀答}};
\node[anchor=north west] (original4-4) at ([yshift=0.3em]original4-3.south west) {\scriptsize{道。快乐走近爱的身边,但是她太快乐了,竟然没有听见爱在叫她!}};
%机器翻译--------------
\node [anchor=north west] (mt4) at ([xshift=-3.5em,yshift=-0.3em]original4-4.south west) {\scriptsize{机器翻译:At this time, Richness {\color{red}\underline{passed by}} in a big ship. Love said, ``Rich, can you take me away?'' Richness}};
\node [anchor=north west] (mt4-1) at ([xshift=3.5em,yshift=0.4em]mt4.south west) {\scriptsize{replied, ``No, {\color{red}\underline{there are many treasures}} of gold and silver in my ship,and there is no place for you.''}};
\node [anchor=north west] (mt4-2) at ([xshift=0em,yshift=0.3em]mt4-1.south west) {\scriptsize{ Love saw vanity in a magnificent boat and said, ``Vanity, help me!'' ``I can't help you. You are {\color{red}\underline{soak}}}};
\node [anchor=north west] (mt4-3) at ([yshift=0.4em]mt4-2.south west) {\scriptsize{{\color{red}\underline{-ed to the skin}} and will damage my beautiful boat.'' When sorrow came, love asked him for help: ``}};
\node [anchor=north west] (mt4-4) at ([yshift=0.4em]mt4-3.south west) {\scriptsize{sorrow, let me go with you!'' ``Oh,...love, I am so sad that I want to be alone for a while!'' Sadly rep}};
\node [anchor=north west] (mt4-5) at ([yshift=0.4em]mt4-4.south west) {\scriptsize{-lied. Happiness {\color{red}\underline{approached}} love, but she was too happy to hear love calling her!}};
%人工翻译---------------
\node [anchor=north west] (ht4) at ([xshift=-3.5em,yshift=0.3em]mt4-5.south west) {\scriptsize{人工翻译:At that moment, WEALTH {\color{red}\underline{was passing by}} in a big boat. Love said,``WEALTH, can you take me}};
\node [anchor=north west] (ht4-1) at ([xshift=3.5em,yshift=0.4em]ht4.south west) {\scriptsize{with you?'' WEALTH answered, ``no, {\color{red}\underline{there is a lot}} of gold and silver in my boat. There is no place}};
\node [anchor=north west] (ht4-2) at ([yshift=0.4em]ht4-1.south west) {\scriptsize{for you.'' Love saw VANITY in a beautiful boat and said, ``VANITY, help me!'' ``I can't help you.}};
\node [anchor=north west] (ht4-3) at ([yshift=0.4em]ht4-2.south west) {\scriptsize{You are {\color{red}\underline{all wet,}} and will break my pretty boat.'' Then SADNESS came. Love asked for help,``SAD}};
\node [anchor=north west] (ht4-4) at ([yshift=0.4em]ht4-3.south west) {\scriptsize{-NESS, let me go with you!'' ``Oh,...LOVE, I am so sad that I want to be alone for a while!'' ``Repli}};
\node [anchor=north west] (ht4-5) at ([yshift=0.4em]ht4-4.south west) {\scriptsize{-ed SADNESS. JOY {\color{red}\underline{came close to }} love, but she was so happy that she did not hear him call her!}};
%第三段--------------------------------
\node[anchor=north west] (original8) at ([xshift=-3.5em,yshift=-0.3em]ht4-5.south west) {\scriptsize{\qquad 文:突然,一个声音传来:``过来,爱,我带你走。''这是位长者。爱大喜过望,竟忘了问他他}};
\node[anchor=north west] (original8-1) at ([xshift=3.5em,yshift=0.3em]original8.south west) {\scriptsize{的名字。登上陆地后,长者独自走开了。爱对长者感激不尽,问另一位长者知识:``帮我的}};
\node[anchor=north west] (original8-2) at ([yshift=0.3em]original8-1.south west) {\scriptsize{那个人是谁?''``他是时间。''知识老人回答。``时间?''爱问道,``他为什么要帮我?''知识老}};
\node[anchor=north west] (original8-3) at ([yshift=0.3em]original8-2.south west) {\scriptsize{人笑道:``因为只有时间才能理解爱有多么伟大。''}};
%机器翻译--------------
\node [anchor=north west] (mt8) at ([xshift=-3.5em,yshift=0.4em]original8-3.south west) {\scriptsize{机器翻译:Suddenly, a voice {\color{red}\underline{came:}} ``Come here, love, I'll take you away.'' This is an elder. Love was {\color{red}\underline{overjoy}}}};
\node [anchor=north west] (mt8-1) at ([xshift=3.5em,yshift=0.4em]mt8.south west) {\scriptsize{{\color{red}\underline{-ed and}} forgot to ask his name. After landing on land, the elder walked away alone.Love was very}};
\node [anchor=north west] (mt8-2) at ([yshift=0.4em]mt8-1.south west) {\scriptsize{grateful to the elder and asked another elder knowledge, {\color{red}\underline{``Who is the person who helped me?''}} ``He}};
\node [anchor=north west] (mt8-3) at ([yshift=0.4em]mt8-2.south west) {\scriptsize{is time.'' The {\color{red}\underline{old intellectual}} replied. ``Time?'' Love asked,``Why did he help me?'' The old intellec}};
\node [anchor=north west] (mt8-4) at ([yshift=0.4em]mt8-3.south west) {\scriptsize{-tual laughed, ``Because only time canunderstand how great love is.''}};
%人工翻译---------------
\node [anchor=north west] (ht8) at ([xshift=-3.5em,yshift=0.4em]mt8-4.south west) {\scriptsize{人工翻译:Suddenly, a voice {\color{red}\underline{said,}} ``come, LOVE, I'll take you.'' This is an elder. LOVE was {\color{red}\underline{so over that}} she}};
\node [anchor=north west] (ht8-1) at ([xshift=3.5em,yshift=0.4em]ht8.south west) {\scriptsize{forgot to ask his name. After landing on land, the elder walked away}};
\node [anchor=north west] (ht8-2) at ([yshift=0.4em]ht8-1.south west) {\scriptsize{alone.LOVE was so grateful to the elder that she asked KNOWLEDGE, another elder, {\color{red}\underline{``who help}}}};
\node [anchor=north west] (ht8-3) at ([yshift=0.4em]ht8-2.south west) {\scriptsize{{\color{red}\underline{-ed me?''}} ``He is TIME.'' The {\color{red}\underline{old man}} replied. ``TIME?'' LOVE asked. ``why did he help me?'' The}};
\node [anchor=north west] (ht8-4) at ([yshift=0.4em]ht8-3.south west) {\scriptsize{old man smiled and said, ``Because only time can understand how great love is.''}};
\begin{pgfonlayer}{background}
{
\node[rectangle,draw=ublue, inner sep=0mm] [fit =(original1)(ht1)(mt1)(original4-4)(ht4-2)(ht8-4)(ht8)] {};
\node[rectangle,draw=ublue, inner sep=0mm] [fit =(original1)(ht1)(mt1)(ht1-4)] {};
}
\end{pgfonlayer}
......
......@@ -10,10 +10,10 @@
\begin{scope}
{
{\footnotesize
\node [anchor=south west,minimum width=15em] (source) at (0,0.57) {\textbf{source}: 我\ \ \ \ \ \ \ \ \ \ \ \ 感到\ \ \ \ 满意};
\node [anchor=south west,minimum width=15em] (source) at (0,0.57) {\textbf{源语言}: 我\ \ \ \ \ \ \ \ \ \ \ \ 感到\ \ \ \ 满意};
}
{\footnotesize
\node [anchor=south west,minimum width=15em] (target) at ([yshift=11em]source.north west) {\textbf{target}: I\ \ am\ \ \ satisfied\ \ \ with\ \ \ you};
\node [anchor=south west,minimum width=15em] (target) at ([xshift=-0.4em,yshift=11em]source.north west) {\textbf{目标语言}: I\ \ am\ \ \ satisfied\ \ \ with\ \ \ you};
}
{
\node [anchor=center,minimum width=9.6em,minimum height=1.8em,draw,rounded corners=0.3em] (hidden) at ([yshift=5em]source.north) {};
......@@ -42,9 +42,9 @@
}
{
\node [anchor=south] (enclabel) at ([xshift=-0.1em,yshift=1.4em]source.north) {\large{\textbf{Encoder}}};
\node [anchor=north] (declabel) at ([xshift=-0.1em,yshift=-1em]target.south) {\large{\textbf{Decoder}}};
\node [anchor=east,align=left] (hiddenlabel) at (hidden.west) {\scriptsize{represe-}\\\scriptsize{ntation}};
\node [anchor=south] (enclabel) at ([xshift=-0.1em,yshift=1.4em]source.north) {编码器(Encoder)};
\node [anchor=north] (declabel) at ([xshift=-0.1em,yshift=-1em]target.south) {解码器(Decoder)};
\node [anchor=east,align=left] (hiddenlabel) at (hidden.west) {\scriptsize{分布式}\\\scriptsize{表示}};
}
\end{scope}
......@@ -80,12 +80,12 @@
\end{pgfonlayer}
% input and output labels
\draw[->,thick,align=center] ([yshift=-0.8em]layer1.south)--([yshift=-0.1em]layer1.south) node [pos=0,anchor=north,inner sep=3pt] (word01) {\footnotesize{input} \footnotesize{(word)}};
\draw[->,thick,align=center] ([yshift=-0.8em]layer2.south)--([yshift=-0.1em]layer2.south) node [pos=0,anchor=north,inner sep=3pt] (word02) {\footnotesize{input} \footnotesize{(word)}};
\draw[<-,thick,align=center] ([yshift=0.8em]layer3.north)--([yshift=0.1em]layer3.north) node [pos=0,anchor=south,inner sep=0] (outputnode) {\footnotesize{output} \footnotesize{(representation)}};
\draw[->,thick,align=center] ([yshift=-0.8em]layer1.south)--([yshift=-0.1em]layer1.south) node [pos=0,anchor=north,inner sep=3pt] (word01) {\footnotesize{输入} \footnotesize{(word)}};
\draw[->,thick,align=center] ([yshift=-0.8em]layer2.south)--([yshift=-0.1em]layer2.south) node [pos=0,anchor=north,inner sep=3pt] (word02) {\footnotesize{输入} \footnotesize{(word)}};
\draw[<-,thick,align=center] ([yshift=0.8em]layer3.north)--([yshift=0.1em]layer3.north) node [pos=0,anchor=south,inner sep=0] (outputnode) {\footnotesize{表示结果} \footnotesize{(representation)}};
% layer and neuron labels
\node[anchor=west] (layerlabel3) at (layer3.east) {\footnotesize{layer}};
%\node[anchor=west] (layerlabel3) at (layer3.east) {\footnotesize{layer}};
% connections
\draw[-] (neuron01)--(neuron21); \draw[-] (neuron02)--(neuron21); \draw[-] (neuron03)--(neuron21); \draw[-] (neuron04)--(neuron21);
......@@ -103,7 +103,7 @@
\draw [->,very thick,dotted] (enclabel.east) ..controls + (east:2em) and +(west:2em).. ([yshift=-1em]netbox.west);
\node [anchor=north] (netlabel) at (netbox.south) {\footnotesize{sample network of the encoder}};
\node [anchor=north] (netlabel) at (netbox.south) {\footnotesize{编码器网络示例}};
}
\end{scope}
......
......@@ -9,14 +9,14 @@
\begin{scope}
{
{\footnotesize
\node [anchor=north west] (rule1) at (0,0) {\textbf{1: If} 源=``我'', \textbf{then} 译=``I''};
\node [anchor=north west] (rule2) at ([yshift=0.1em]rule1.south west) {\textbf{2: If} 源=``你'', \textbf{then} 译=``you''};
\node [anchor=north west] (rule3) at ([yshift=0.1em]rule2.south west) {\textbf{3: If} 源=``感到 满意'',};
\node [anchor=north west] (rule3part2) at ([yshift=0.5em]rule3.south west) {\textbf{\hspace{0.95em} then} 译=``be satisfied with''};
\node [anchor=north west] (rule4) at ([yshift=0.1em]rule3part2.south west) {\textbf{4: If} 源=``对 ... 动词[表态度]''};
\node [anchor=north west] (rule1) at (0,0) {\textbf{1: If} 源=我, \textbf{then} 译=\ I};
\node [anchor=north west] (rule2) at ([yshift=0.1em]rule1.south west) {\textbf{2: If} 源=你, \textbf{then} 译=\ you};
\node [anchor=north west] (rule3) at ([yshift=0.1em]rule2.south west) {\textbf{3: If} 源=感到\ 满意,};
\node [anchor=north west] (rule3part2) at ([yshift=0.5em]rule3.south west) {\textbf{\hspace{0.95em} then} 译=\ be satisfied with};
\node [anchor=north west] (rule4) at ([yshift=0.1em]rule3part2.south west) {\textbf{4: If} 源=对 ... 动词[表态度]};
\node [anchor=north west] (rule4part2) at ([yshift=0.5em]rule4.south west) {\textbf{\hspace{0.95em} then} 调序[动词 + 对象]};
\node [anchor=north west] (rule5) at ([yshift=0.1em]rule4part2.south west) {\textbf{5: If} 译文主语是``I''};
\node [anchor=north west] (rule5part2) at ([yshift=0.5em]rule5.south west) {\textbf{\hspace{0.95em} then} be动词为``am/was''};
\node [anchor=north west] (rule5) at ([yshift=0.1em]rule4part2.south west) {\textbf{5: If} 译文主语是\ I};
\node [anchor=north west] (rule5part2) at ([yshift=0.5em]rule5.south west) {\textbf{\hspace{0.95em} then} be动词为\ am/was};
\node [anchor=north west] (rule6) at ([yshift=0.1em]rule5part2.south west) {\textbf{6: If} 源语是主谓结构};
\node [anchor=north west] (rule6part2) at ([yshift=0.5em]rule6.south west) {\textbf{\hspace{0.95em} then} 译文为主谓结构};
\node [anchor=south west] (rulebaselabel) at (rule1.north west) {{\color{ublue} 资源:规则库}};
......
......@@ -9,12 +9,12 @@
{
\begin{scope}
{\scriptsize
\node [anchor=north west] (example1) at (0,0) {\textbf{1:} 源=``他 在 哪 ?''};
\node [anchor=north west] (example1part2) at ([yshift=0.2em]example1.south west) {\hspace{1em} 译=``Where is he ?''};
\node [anchor=north west] (example2) at ([yshift=0.1em]example1part2.south west) {\textbf{2:} 源=``我 真高兴''};
\node [anchor=north west] (example2part2) at ([yshift=0.2em]example2.south west) {\hspace{1em} 译=``I'm so happy''};
\node [anchor=north west] (example3) at ([yshift=0.1em]example2part2.south west) {\textbf{3:} 源=``出发 !''};
\node [anchor=north west] (example3part2) at ([yshift=0.2em]example3.south west) {\hspace{1em} 译=``Let's go!''};
\node [anchor=north west] (example1) at (0,0) {\textbf{1:} 源=\ \ };
\node [anchor=north west] (example1part2) at ([yshift=0.2em]example1.south west) {\hspace{1em} 译=\ Where is he};
\node [anchor=north west] (example2) at ([yshift=0.1em]example1part2.south west) {\textbf{2:} 源=\ 真高兴};
\node [anchor=north west] (example2part2) at ([yshift=0.2em]example2.south west) {\hspace{1em} 译=\ I'm so happy};
\node [anchor=north west] (example3) at ([yshift=0.1em]example2part2.south west) {\textbf{3:} 源=出发};
\node [anchor=north west] (example3part2) at ([yshift=0.2em]example3.south west) {\hspace{1em} 译=\ Let's go};
\node [anchor=north west] (example4) at ([yshift=0.1em]example3part2.south west) {\hspace{1em} ...};
\node [anchor=north west] (example5) at ([yshift=0.1em]example4.south west) {\hspace{1em}\quad};
\node [anchor=north west] (example6) at ([yshift=0.1em]example5.south west) {\hspace{1em}\quad};
......@@ -33,9 +33,9 @@
{
\begin{scope} [yshift=-1.55in]
{\scriptsize
\node [anchor=north west] (entry1) at (0,0) {\textbf{1:} What is NiuTrans ?\qquad \qquad };
\node [anchor=north west] (entry2) at ([yshift=0.0em]entry1.south west) {\textbf{2:} Are you fulfilled ?};
\node [anchor=north west] (entry3) at ([yshift=0.0em]entry2.south west) {\textbf{3:} Yes, you are right .};
\node [anchor=north west] (entry1) at (0,0) {\textbf{1:} What is NiuTrans\qquad \qquad };
\node [anchor=north west] (entry2) at ([yshift=0.0em]entry1.south west) {\textbf{2:} Are you fulfilled};
\node [anchor=north west] (entry3) at ([yshift=0.0em]entry2.south west) {\textbf{3:} You are right};
\node [anchor=north west] (entry4) at ([yshift=0.0em]entry3.south west) {\hspace{1em} ...};
\node [anchor=north west] (entry5) at ([yshift=0.1em]entry4.south west) {\hspace{1em}{\quad}};
\node [anchor=north west] (entry6) at ([xshift=11.6em,yshift=0.65em]entry5.south west) {};
......@@ -79,15 +79,16 @@
\begin{scope}[xshift=1.7in,yshift=-1.55in]
{\scriptsize
\node [anchor=north west] (ngram1) at (0,0) {$\textrm{Pr}(\textrm{I}) = 0.0001$};
\node [anchor=north west] (ngram2) at ([yshift=0.0em]ngram1.south west) {$\textrm{Pr}(\textrm{I} \to \textrm{am}) = 0.623$};
\node [anchor=north west] (ngram3) at ([yshift=0.0em]ngram2.south west) {$\textrm{Pr}(\textrm{I} \to \textrm{was}) = 0.21$};
\node [anchor=north west] (ngram2) at ([yshift=0.0em]ngram1.south west) {$\textrm{Pr}(\textrm{I}\ \textrm{am}) = 0.623$};
\node [anchor=north west] (ngram3) at ([yshift=0.0em]ngram2.south west) {$\textrm{Pr}(\textrm{I}\ \textrm{was}) = 0.21$};
\node [anchor=north west] (ngram4) at ([yshift=-0.2em]ngram3.south west) {...};
\node [anchor=north east] (ngrame) at ([yshift=-1in]phrase5.south east) {};
\node [anchor=south west] (lmlabel) at (ngram1.north west) {{\color{ublue} \small{语言模型}}};
}
\begin{pgfonlayer}{background}
{
\node[rectangle,draw=ublue, inner sep=0mm] [fit = (ngram1) (ngram2) (ngram3) (ngram4) (lmlabel)] (langaugemodel) {};
\node[rectangle,draw=ublue, inner sep=0mm] [fit = (ngram1) (ngram2) (ngram3) (ngram4) (lmlabel) (ngrame)] (langaugemodel) {};
}
\end{pgfonlayer}
......
......@@ -15,7 +15,7 @@
{
\begin{scope}[yshift=-1.0in]
\node [] (part1label) at (0,0) {\includegraphics[scale=0.10]{./Chapter1/Figures/figure-oil.jpg}};
\node [anchor=north west] (part1text) at ([xshift=-1em,yshift=0.0em]part1label.south west) {\begin{tabular}{l}{\color{red}{资源}}:可以使机器翻译\\系统运行的``汽油''\end{tabular}};
\node [anchor=north west] (part1text) at ([xshift=-1em,yshift=0.0em]part1label.south west) {\begin{tabular}{l}{\color{red}{资源}}:可以使机器翻译\\系统运行的“汽油”\end{tabular}};
\end{scope}
}
......
......@@ -14,6 +14,8 @@
\node [anchor=south] (humanscore) at (human.north) {4.7};
\draw [->,thick] ([xshift=-0.5cm]mt.south west) -- ([xshift=0.5cm]human.south east);
\draw [->,thick] ([xshift=-0.5cm]mt.south west) -- ([xshift=-0.5cm,yshift=3.2cm]mt.south west);
\node [anchor=north west] (x1) at ([xshift=0.0cm]human.south east) {\footnotesize{评价对象}};
\node [anchor=north east] (y1) at ([xshift=-0.5cm,yshift=3.2cm]mt.south west) {\footnotesize{打分}};
\node [anchor=south west, fill=blue!50, minimum width=1.1cm, minimum height=1.5cm] (mt1) at ([xshift=13.0em,yshift=-3.0em]mt.east) {{\color{white} {\small\sffamily\bfseries{机器}}}};
\node [anchor=south west, fill=red!50, minimum width=1.1cm, minimum height=2.7cm] (human1) at ([xshift=0.5cm]mt1.south east) {{\color{white} {\small\sffamily\bfseries{}}}};
......@@ -21,6 +23,8 @@
\node [anchor=south] (humanscore1) at (human1.north) {100};
\draw [->,thick] ([xshift=-0.5cm]mt1.south west) -- ([xshift=0.5cm]human1.south east);
\draw [->,thick] ([xshift=-0.5cm]mt1.south west) -- ([xshift=-0.5cm,yshift=3.2cm]mt1.south west);
\node [anchor=north west] (x1) at ([xshift=0.0cm]human1.south east) {\footnotesize{评价对象}};
\node [anchor=north east] (y1) at ([xshift=-0.5cm,yshift=3.2cm]mt1.south west) {\footnotesize{打分}};
\node[anchor=south](footname1) at ([xshift=2.1em,yshift=-2.0em]mt.south){\footnotesize{人工评价(五分制)}};
\node[anchor=south](footname2) at ([xshift=2.1em,yshift=-2.0em]mt1.south){\footnotesize{自动评价(百分制)}};
......
......@@ -10,10 +10,10 @@
\begin{scope}
{
{\footnotesize
\node [anchor=north west] (example1) at (0,0) {\textbf{1:} 源=``什么 时候 开始 ?''};
\node [anchor=north west] (example1part2) at ([yshift=0.5em]example1.south west) {\hspace{1em} 译=``When will it start ?''};
\node [anchor=north west] (example2) at ([yshift=0.1em]example1part2.south west) {\textbf{2:} 源=``我 对 他 感到 高兴''};
\node [anchor=north west] (example2part2) at ([yshift=0.5em]example2.south west) {\hspace{1em} 译=``I am happy with him''};
\node [anchor=north west] (example1) at (0,0) {\textbf{1:} 源=什么\ 时候\ 开始};
\node [anchor=north west] (example1part2) at ([yshift=0.5em]example1.south west) {\hspace{1em} 译=\ When will it start};
\node [anchor=north west] (example2) at ([yshift=0.1em]example1part2.south west) {\textbf{2:} 源=\ \ \ 感到\ 高兴};
\node [anchor=north west] (example2part2) at ([yshift=0.5em]example2.south west) {\hspace{1em} 译=\ I am happy with him};
\node [anchor=north west] (example3) at ([yshift=0.1em]example2part2.south west) {\hspace{1em} ...};
\node [anchor=south west] (examplebaselabel) at (example1.north west) {{\color{ublue} 资源1:翻译实例库}};
}
......@@ -35,14 +35,12 @@
\node [anchor=north west] (entry3) at ([yshift=0.1em]entry2.south west) {\textbf{3:} 满意 \hspace{-0.4em} $\to$ \hspace{-0.4em} satisfy \hspace{-0.12em}$\mid$\hspace{-0.12em} satisfied ... };
\node [anchor=north west] (entry4) at ([yshift=0.1em]entry3.south west) {\hspace{1em} ...};
\node [anchor=south west] (dictionarylabel) at (entry1.north west) {{\color{ublue} 资源2:翻译词典}};
\node [anchor=west,opacity=0.0] (empty) at ([yshift=-0.2em]entry3.west) {\hspace{1em} 译=``I am happy with him''};
}
}
\begin{pgfonlayer}{background}
{
\node[rectangle,draw=ublue, inner sep=0mm] [fit = (entry1) (entry2) (entry3) (entry4) (dictionarylabel) (empty)] {};
\node[rectangle,draw=ublue, inner sep=0mm] [fit = (entry1) (entry2) (entry3) (entry4) (dictionarylabel)] {};
}
\end{pgfonlayer}
......@@ -94,7 +92,7 @@
}
{
\draw[double,->,thick,ublue] (e3.south)--([yshift=-1.2em]e3.south) node[pos=0.5,right,xshift=0.2em,yshift=0.2em] (step1) {\color{red}{\tiny{`你'替换`他'}}};
\draw[double,->,thick,ublue] (e3.south)--([yshift=-1.2em]e3.south) node[pos=0.5,right,xshift=0.2em,yshift=0.2em] (step1) {\color{red}{\tiny{‘你’替换‘他’}}};
\draw[->,dotted,thick,red] ([xshift=-0.1em]entry2.east)..controls +(east:4) and +(west:4)..([yshift=-0.6em,xshift=-0.5em]e3.south) ;
}
......@@ -124,7 +122,7 @@
}
{
\draw[double,->,thick,ublue] (e3.south)--([yshift=-1.2em]e3.south) node[pos=0.5,right,xshift=0.2em,yshift=0.2em] (step1) {\color{red}{\tiny{`满意'替换`高兴'}}};
\draw[double,->,thick,ublue] (e3.south)--([yshift=-1.2em]e3.south) node[pos=0.5,right,xshift=0.2em,yshift=0.2em] (step1) {\color{red}{\tiny{‘满意’替换‘高兴’}}};
\draw[->,dotted,thick,red] ([xshift=-1.2em,yshift=-0.6em]entry3.north east)..controls +(east:2) and +(west:3)..([yshift=-0.6em,xshift=-0.5em]e3.south) ;
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
\begin{tikzpicture}
\tikzstyle{node} = [minimum height=1.0*1.2em,draw,fill=green!20]
\tikzstyle{legend} = [minimum height=1.0*1.2em,minimum width=1.0*1.2em,draw]
\tikzstyle{node2} = [minimum width=1.0*1.2em,minimum height=4.1*1.2em,draw,fill=blue!20]
\node[node,minimum width=2.8*1.2em] (node1) at (0,0) {};
\node[node,minimum width=4.0*1.2em,anchor=north west] (node2) at (node1.south west) {};
\node[node,minimum width=3.2*1.2em,anchor=north west] (node3) at (node2.south west) {};
\node[node,minimum width=3.0*1.2em,anchor=north west] (node4) at (node3.south west) {};
\node[node2,anchor = north west] (grad1) at ([xshift=1.2em]node1.north east) {};
\node[node,minimum width=3.7*1.2em,anchor=north west] (node5) at (grad1.north east) {};
\node[node,minimum width=2.8*1.2em,anchor=north west] (node6) at (node5.south west) {};
\node[node,minimum width=3.2*1.2em,anchor=north west] (node7) at (node6.south west) {};
\node[node,minimum width=4.0*1.2em,anchor=north west] (node8) at (node7.south west) {};
\node[font=\footnotesize,anchor=east] (line1) at (node1.west) {GPU1};
\node[font=\footnotesize,anchor=east] (line2) at (node2.west) {GPU2};
\node[font=\footnotesize,anchor=east] (line3) at (node3.west) {GPU3};
\node[font=\footnotesize,anchor=east] (line4) at (node4.west) {GPU4};
\node[node2,anchor = north west] (grad2) at ([xshift=0.3em]node5.north east) {};
\draw[->,thick] (-1.4em*1.2,-3.62*1.2em) -- (9em*1.2,-3.62*1.2em);
\node[node,minimum width=2.8*1.2em] (node9) at (16em,0) {};
\node[node,minimum width=4.0*1.2em,anchor=north west] (node10) at (node9.south west) {};
\node[node,minimum width=3.2*1.2em,anchor=north west] (node11) at (node10.south west) {};
\node[node,minimum width=3.0*1.2em,anchor=north west] (node12) at (node11.south west) {};
\node[node,minimum width=3.7*1.2em,anchor=north west] (node13) at (node9.north east) {};
\node[node,minimum width=2.8*1.2em,anchor=north west] (node14) at (node10.north east) {};
\node[node,minimum width=3.2*1.2em,anchor=north west] (node15) at (node11.north east) {};
\node[node,minimum width=4.0*1.2em,anchor=north west] (node16) at (node12.north east) {};
\node[node2,anchor = north west] (grad3) at ([xshift=0.5em]node13.north east) {};
\node[font=\footnotesize,anchor=east] (line1) at (node9.west) {GPU1};
\node[font=\footnotesize,anchor=east] (line2) at (node10.west) {GPU2};
\node[font=\footnotesize,anchor=east] (line3) at (node11.west) {GPU3};
\node[font=\footnotesize,anchor=east] (line4) at (node12.west) {GPU4};
\draw[->,thick] (node12.south west) -- ([xshift=3em]node16.south east);
\begin{pgfonlayer}{background}
\node [rectangle,inner sep=-0.0em,draw] [fit = (node1) (node2) (node3) (node4)] (box1) {};
\node [rectangle,inner sep=-0.0em,draw] [fit = (node5) (node6) (node7) (node8)] (box2) {};
\node [rectangle,inner sep=-0.0em,draw] [fit = (node9) (node13) (node12) (node16)] (box2) {};
\end{pgfonlayer}
\node[font=\footnotesize,anchor=north] (legend1) at ([xshift=3em]node4.south) {一步一更新};
\node[font=\footnotesize,anchor=north] (legend2) at ([xshift=2.5em]node12.south) {累积两步更新};
\node[font=\footnotesize,anchor=north] (time1) at (grad2.south) {time};
\node[font=\footnotesize,anchor=north] (time1) at (grad3.south) {time};
\node[legend] (legend3) at (2em,2em) {};
\node[font=\footnotesize,anchor=west] (idle) at (legend3.east) {:空闲};
\node[legend,anchor=west,draw,fill=green!30] (legend4) at ([xshift = 2em]idle.east) {};
\node[font=\footnotesize,anchor=west] (FB) at (legend4.east) {:前向/反向};
\node[legend,anchor=west,draw,fill=blue!30] (legend5) at ([xshift = 2em]FB.east) {};
\node[font=\footnotesize,anchor=west] (grad_sync) at (legend5.east) {:梯度更新};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\def\neuronsep{1.5}
\def\nodespace{1}
\def\picturespace{0.8}
\tikzstyle{neuronnode} = [minimum size=1.8em,circle,draw,very thick,ublue,inner sep=0pt, fill=white,align=center]
%standard
\node [neuronnode] (neuron_b) at (0,0) {\scriptsize{$b_{i}^{l}$}};
\node [neuronnode] (neuron_y3) at (0,-1*\neuronsep) {\scriptsize{$x_{3}^{l}$}};
\node [neuronnode] (neuron_y2) at (0,-2*\neuronsep) {\scriptsize{$x_{2}^{l}$}};
\node [neuronnode] (neuron_y1) at (0,-3*\neuronsep) {\scriptsize{$x_{1}^{l}$}};
\node [neuronnode] (neuron_z) at (1.2 * \nodespace,-1.5 * \neuronsep) {\scriptsize{$z_{i}^{l+1}$}};
\node [neuronnode] (neuron_y') at (2.4 * \nodespace,-1.5 * \neuronsep) {\scriptsize{$x_{i}^{l+1}$}};
\node [anchor=north,ublue] (standard) at ([yshift=-4em]neuron_z.south) {\scriptsize{standard}};
\node [ublue] (standard) at ([xshift=-1em]neuron_z.west) {\scriptsize{$\mathbf{w}_{i}^{l}$}};
\node [ublue] (standard) at ([xshift=0.6em,yshift=0.3em]neuron_z.east) {\scriptsize{$f$}};
\draw [->,line width=0.3mm] (neuron_b.east) -- (neuron_z.west);
\draw [->,line width=0.3mm] (neuron_y3.east) -- (neuron_z.west);
\draw [->,line width=0.3mm] (neuron_y2.east) -- (neuron_z.west);
\draw [->,line width=0.3mm] (neuron_y1.east) -- (neuron_z.west);
\draw [->,line width=0.3mm] (neuron_z.east) -- (neuron_y'.west);
%dropout
\node [neuronnode] (drop_neuron_b) at (5*\nodespace,0) {\scriptsize{$b_{i}^{l}$}};
\node [neuronnode] (drop_neuron_y3') at (5*\nodespace,-1*\neuronsep) {\scriptsize{$\tilde{x}_{3}^{l}$}};
\node [neuronnode] (drop_neuron_y2') at (5*\nodespace,-2*\neuronsep) {\scriptsize{$\tilde{x}_{2}^{l}$}};
\node [neuronnode] (drop_neuron_y1') at (5*\nodespace,-3*\neuronsep) {\scriptsize{$\tilde{x}_{1}^{l}$}};
\node [neuronnode] (drop_neuron_z) at (6.2 * \nodespace,-1.5 * \neuronsep) {\scriptsize{$z_{i}^{l+1}$}};
\node [neuronnode] (drop_neuron_y') at (7.4 * \nodespace,-1.5 * \neuronsep) {\scriptsize{$x_{i}^{l+1}$}};
\node [neuronnode] (drop_neuron_y3) at (3.8*\nodespace,-1*\neuronsep) {\scriptsize{$x_{3}^{l}$}};
\node [neuronnode] (drop_neuron_y2) at (3.8*\nodespace,-2*\neuronsep) {\scriptsize{$x_{2}^{l}$}};
\node [neuronnode] (drop_neuron_y1) at (3.8*\nodespace,-3*\neuronsep) {\scriptsize{$x_{1}^{l}$}};
\node [neuronnode] (drop_neuron_r3) at (4.4*\nodespace,-0.5*\neuronsep) {\scriptsize{$r_{3}^{l}$}};
\node [neuronnode] (drop_neuron_r2) at (4.4*\nodespace,-1.5*\neuronsep) {\scriptsize{$r_{2}^{l}$}};
\node [neuronnode] (drop_neuron_r1) at (4.4*\nodespace,-2.5*\neuronsep) {\scriptsize{$r_{1}^{l}$}};
\node [anchor=north,ublue] (standard) at ([yshift=-4em]drop_neuron_z.south) {\scriptsize{dropout}};
\node [ublue] (standard) at ([xshift=-1em]drop_neuron_z.west) {\scriptsize{$\mathbf{w}_{i}^{l}$}};
\node [ublue] (standard) at ([xshift=0.6em,yshift=0.3em]drop_neuron_z.east) {\scriptsize{$f$}};
%structure
\draw [->,line width=0.3mm] (drop_neuron_b.east) -- (drop_neuron_z.west);
\draw [->,line width=0.3mm] (drop_neuron_y3'.east) -- (drop_neuron_z.west);
\draw [->,line width=0.3mm] (drop_neuron_y2'.east) -- (drop_neuron_z.west);
\draw [->,line width=0.3mm] (drop_neuron_y1'.east) -- (drop_neuron_z.west);
\draw [->,line width=0.3mm] (drop_neuron_z.east) -- (drop_neuron_y'.west);
%r
\draw [->,line width=0.3mm] (drop_neuron_y3.east) -- (drop_neuron_y3'.west);
\draw [->,line width=0.3mm] (drop_neuron_y2.east) -- (drop_neuron_y2'.west);
\draw [->,line width=0.3mm] (drop_neuron_y1.east) -- (drop_neuron_y1'.west);
\draw [-,line width=0.3mm] (drop_neuron_r3.south) -- ([yshift=-1em]drop_neuron_r3.south);
\draw [-,line width=0.3mm] (drop_neuron_r2.south) -- ([yshift=-1em]drop_neuron_r2.south);
\draw [-,line width=0.3mm] (drop_neuron_r1.south) -- ([yshift=-1em]drop_neuron_r1.south);
%equ
\node [anchor=west,inner sep = 2pt] (line1) at (9*\nodespace,0) {未应用dropout:};
\node [anchor=north west,inner sep = 2pt] (line2) at (line1.south west) {$z_{i}^{l+1}=\mathbf{w}_{i}^{l} \mathbf{x}+b_{i}^{l}$};
\node [anchor=north west,inner sep = 2pt] (line3) at (line2.south west) {$x_{i}^{l+1}=f\left(x_{i}^{l}\right)$};
\node [anchor=north west,inner sep = 2pt] (line4) at (line3.south west) {应用dropout:};
\node [anchor=north west,inner sep = 2pt] (line5) at (line4.south west) {$r_{j}^{l} \sim$ Bernoulli $(1-p)$};
\node [anchor=north west,inner sep = 2pt] (line6) at (line5.south west) {$\tilde{\mathbf{x}}=\mathbf{r} * \mathbf{x}$};
\node [anchor=north west,inner sep = 2pt] (line7) at (line6.south west) {$z_{i}^{l+1}=\mathbf{w}_{i}^{l} \widetilde{\mathbf{x}}+b_{i}^{l}$};
\node [anchor=north west,inner sep = 2pt] (line8) at (line7.south west) {$x_{i}^{l+1}=f\left(z_{i}^{l}\right)$};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[scale=1]
\tikzstyle{prob} = [rectangle,fill=blue!40,text=white,inner sep=0pt,font=\scriptsize];
\tikzstyle{word} = [inner sep=0pt,font=\small];
\begin{scope}[]
% Column 1
\node [prob,minimum size=0.1cm] (prob11) at (0,0) {};
\node [prob,minimum size=0.5cm,anchor=center] (prob21) at ([yshift=-0.5cm]prob11.center) {$.7$};
\node [prob,minimum size=0.1cm,anchor=center] (prob31) at ([yshift=-0.5cm]prob21.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob41) at ([yshift=-0.5cm]prob31.center) {};
\node [prob,minimum size=0.3cm,anchor=center] (prob51) at ([yshift=-0.5cm]prob41.center) {$.2$};
\begin{pgfonlayer}{background}
\coordinate (bottomleft) at ([shift={(-0.25cm,-0.25cm)}]prob51.center);
\coordinate (topright) at ([shift={(0.25cm,0.25cm)}]prob11.center);
\node [draw,fit=(prob11) (prob21) (prob31) (prob41) (prob51) (topright) (bottomleft)] (prob1) {};
\end{pgfonlayer}
% Column 2
\node [prob,minimum size=0.1cm,anchor=center] (prob12) at ([xshift=1cm]prob11.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob22) at ([yshift=-0.5cm]prob12.center) {};
\node [prob,minimum size=0.4cm,anchor=center] (prob32) at ([yshift=-0.5cm]prob22.center) {$.4$};
\node [prob,minimum size=0.3cm,anchor=center] (prob42) at ([yshift=-0.5cm]prob32.center) {$.3$};
\node [prob,minimum size=0.1cm,anchor=center] (prob52) at ([yshift=-0.5cm]prob42.center) {};
\begin{pgfonlayer}{background}
\coordinate (bottomleft) at ([shift={(-0.25cm,-0.25cm)}]prob52.center);
\coordinate (topright) at ([shift={(0.25cm,0.25cm)}]prob12.center);
\node [draw,fit=(prob12) (prob22) (prob32) (prob42) (prob52) (topright) (bottomleft)] (prob2) {};
\end{pgfonlayer}
% Column 3
\node [prob,minimum size=0.1cm,anchor=center] (prob13) at ([xshift=1cm]prob12.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob23) at ([yshift=-0.5cm]prob13.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob33) at ([yshift=-0.5cm]prob23.center) {};
\node [prob,minimum size=0.4cm,anchor=center] (prob43) at ([yshift=-0.5cm]prob33.center) {$.6$};
\node [prob,minimum size=0.1cm,anchor=center] (prob53) at ([yshift=-0.5cm]prob43.center) {};
\begin{pgfonlayer}{background}
\coordinate (bottomleft) at ([shift={(-0.25cm,-0.25cm)}]prob53.center);
\coordinate (topright) at ([shift={(0.25cm,0.25cm)}]prob13.center);
\node [draw,fit=(prob13) (prob23) (prob33) (prob43) (prob53) (topright) (bottomleft)] (prob3) {};
\end{pgfonlayer}
% Column 4
\node [prob,minimum size=0.5cm,anchor=center] (prob14) at ([xshift=1cm]prob13.center) {$.8$};
\node [prob,minimum size=0.1cm,anchor=center] (prob24) at ([yshift=-0.5cm]prob14.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob34) at ([yshift=-0.5cm]prob24.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob44) at ([yshift=-0.5cm]prob34.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob54) at ([yshift=-0.5cm]prob44.center) {};
\begin{pgfonlayer}{background}
\coordinate (bottomleft) at ([shift={(-0.25cm,-0.25cm)}]prob54.center);
\coordinate (topright) at ([shift={(0.25cm,0.25cm)}]prob14.center);
\node [draw,fit=(prob14) (prob24) (prob34) (prob44) (prob54) (topright) (bottomleft)] (prob4) {};
\end{pgfonlayer}
% Label
\draw [decorate,decoration={brace}] ([yshift=0.1cm]prob1.north west) to node [midway,above,font=\small] {学习目标(Teacher输出)} ([yshift=0.1cm]prob4.north east);
% Vocab
\node [word,anchor=center] () at ([xshift=-0.9cm]prob11.center) {EOS};
\node [word,anchor=center] () at ([xshift=-0.9cm]prob21.center) {I};
\node [word,anchor=center] () at ([xshift=-0.9cm]prob31.center) {am};
\node [word,anchor=center] () at ([xshift=-0.9cm]prob41.center) {fine};
\node [word,anchor=center] () at ([xshift=-0.9cm]prob51.center) {good};
\draw [decorate,decoration={brace,mirror}] ([xshift=-1cm]prob1.north west) to node [midway,left,font=\small,align=center] {\\} ([xshift=-1cm]prob1.south west);
% Model
\coordinate (bottomleft) at ([yshift=-1cm]prob1.south west);
\coordinate (topright) at ([yshift=-0.5cm]prob4.south east);
\node [draw,rounded corners=3pt,fill=green!20,inner sep=0pt,fit=(bottomleft) (topright)] (model) {};
\node [word] () at (model.center) {Student};
\foreach \i in {1,2,...,4}
\draw [-latex,thick] (prob\i.south) to ([yshift=-0.5cm]prob\i.south);
% Input
\node [word,anchor=south] (input1) at ([yshift=-1.8cm]prob1.south) {EOS};
\node [word,anchor=south] (input2) at ([yshift=-1.8cm]prob2.south) {I};
\node [word,anchor=south] (input3) at ([yshift=-1.8cm]prob3.south) {am};
\node [word,anchor=south] (input4) at ([yshift=-1.8cm]prob4.south) {fine};
\foreach \i in {1,2,...,4}
\draw [-latex,thick] ([yshift=0.3cm]input\i.south) to ([yshift=0.8cm]input\i.south);
\node [word,anchor=south] (ns) at ([xshift=-1cm]input1.south) {输入:};
\node [word,anchor=north] () at ([xshift=2.1cm,yshift=-0.5cm]ns.south) {(a)\ Word-level};
\end{scope}
\begin{scope}[xshift=2.5in]
% Column 1
\node [prob,minimum size=0.1cm] (prob11) at (0,0) {};
\node [prob,minimum size=0.5cm,anchor=center] (prob21) at ([yshift=-0.5cm]prob11.center) {$1.$};
\node [prob,minimum size=0.1cm,anchor=center] (prob31) at ([yshift=-0.5cm]prob21.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob41) at ([yshift=-0.5cm]prob31.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob51) at ([yshift=-0.5cm]prob41.center) {};
\begin{pgfonlayer}{background}
\coordinate (bottomleft) at ([shift={(-0.25cm,-0.25cm)}]prob51.center);
\coordinate (topright) at ([shift={(0.25cm,0.25cm)}]prob11.center);
\node [draw,fit=(prob11) (prob21) (prob31) (prob41) (prob51) (topright) (bottomleft)] (prob1) {};
\end{pgfonlayer}
% Column 2
\node [prob,minimum size=0.1cm,anchor=center] (prob12) at ([xshift=1cm]prob11.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob22) at ([yshift=-0.5cm]prob12.center) {};
\node [prob,minimum size=0.5cm,anchor=center] (prob32) at ([yshift=-0.5cm]prob22.center) {$1.$};
\node [prob,minimum size=0.1cm,anchor=center] (prob42) at ([yshift=-0.5cm]prob32.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob52) at ([yshift=-0.5cm]prob42.center) {};
\begin{pgfonlayer}{background}
\coordinate (bottomleft) at ([shift={(-0.25cm,-0.25cm)}]prob52.center);
\coordinate (topright) at ([shift={(0.25cm,0.25cm)}]prob12.center);
\node [draw,fit=(prob12) (prob22) (prob32) (prob42) (prob52) (topright) (bottomleft)] (prob2) {};
\end{pgfonlayer}
% Column 3
\node [prob,minimum size=0.1cm,anchor=center] (prob13) at ([xshift=1cm]prob12.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob23) at ([yshift=-0.5cm]prob13.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob33) at ([yshift=-0.5cm]prob23.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob43) at ([yshift=-0.5cm]prob33.center) {};
\node [prob,minimum size=0.5cm,anchor=center] (prob53) at ([yshift=-0.5cm]prob43.center) {$1.$};
\begin{pgfonlayer}{background}
\coordinate (bottomleft) at ([shift={(-0.25cm,-0.25cm)}]prob53.center);
\coordinate (topright) at ([shift={(0.25cm,0.25cm)}]prob13.center);
\node [draw,fit=(prob13) (prob23) (prob33) (prob43) (prob53) (topright) (bottomleft)] (prob3) {};
\end{pgfonlayer}
% Column 4
\node [prob,minimum size=0.5cm,anchor=center] (prob14) at ([xshift=1cm]prob13.center) {$1.$};
\node [prob,minimum size=0.1cm,anchor=center] (prob24) at ([yshift=-0.5cm]prob14.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob34) at ([yshift=-0.5cm]prob24.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob44) at ([yshift=-0.5cm]prob34.center) {};
\node [prob,minimum size=0.1cm,anchor=center] (prob54) at ([yshift=-0.5cm]prob44.center) {};
\begin{pgfonlayer}{background}
\coordinate (bottomleft) at ([shift={(-0.25cm,-0.25cm)}]prob54.center);
\coordinate (topright) at ([shift={(0.25cm,0.25cm)}]prob14.center);
\node [draw,fit=(prob14) (prob24) (prob34) (prob44) (prob54) (topright) (bottomleft)] (prob4) {};
\end{pgfonlayer}
% Label
\draw [decorate,decoration={brace}] ([yshift=0.1cm]prob1.north west) to node [midway,above,font=\small] {学习目标(Teacher输出)} ([yshift=0.1cm]prob4.north east);
% Vocab
\node [word,anchor=center] () at ([xshift=-0.9cm]prob11.center) {EOS};
\node [word,anchor=center] () at ([xshift=-0.9cm]prob21.center) {I};
\node [word,anchor=center] () at ([xshift=-0.9cm]prob31.center) {am};
\node [word,anchor=center] () at ([xshift=-0.9cm]prob41.center) {fine};
\node [word,anchor=center] () at ([xshift=-0.9cm]prob51.center) {good};
\draw [decorate,decoration={brace,mirror}] ([xshift=-1cm]prob1.north west) to node [midway,left,font=\small,align=center] {\\} ([xshift=-1cm]prob1.south west);
% Model
\coordinate (bottomleft) at ([yshift=-1cm]prob1.south west);
\coordinate (topright) at ([yshift=-0.5cm]prob4.south east);
\node [draw,rounded corners=3pt,fill=green!20,inner sep=0pt,fit=(bottomleft) (topright)] (model) {};
\node [word] () at (model.center) {Student};
\foreach \i in {1,2,...,4}
\draw [-latex,thick] (prob\i.south) to ([yshift=-0.5cm]prob\i.south);
% Input
\node [word,anchor=south] (input1) at ([yshift=-1.8cm]prob1.south) {EOS};
\node [word,anchor=south] (input2) at ([yshift=-1.8cm]prob2.south) {I};
\node [word,anchor=south] (input3) at ([yshift=-1.8cm]prob3.south) {am};
\node [word,anchor=center] (input4) at ([xshift=1cm]input3.center) {good};
\foreach \i in {1,2,3}
\draw [-latex,thick] ([yshift=0.3cm]input\i.south) to ([yshift=0.8cm]input\i.south);
\draw [-latex,thick] ([yshift=0.36cm]input4.south) to ([yshift=0.86cm]input4.south);
\node [word,anchor=south] (ns) at ([xshift=-1cm]input1.south) {输入:};
\node [word,anchor=north] () at ([xshift=2.1cm,yshift=-0.5cm]ns.south) {(b)\ Sequence-level };
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\newlength{\YShift}
\newlength{\XShift}
\setlength{\YShift}{0.8\base}
\setlength{\XShift}{0.8\base}
\tikzstyle{modelnode} = [rectangle,draw,rounded corners=2pt,inner sep=0pt,minimum height=4.2em,minimum width=2em,font=\small,anchor=north]
\coordinate (stu01) at (0,0);
\coordinate (stu02) at ([xshift=3em]stu01);
\coordinate (stu03) at ([xshift=3em]stu02);
\coordinate (stu04) at ([xshift=3em]stu03);
\coordinate (stu05) at ([xshift=3em]stu04);
\coordinate (tea01) at ([xshift=8em]stu05);
\coordinate (tea02) at ([xshift=3em]tea01);
% iterations
\foreach \curr / \prev in {1/0,2/1,3/2}
{
% models
\node[modelnode,fill=yellow!20] (stu\curr1) at ([yshift=-2em]stu\prev1.south) {\rotatebox{90}{Student $1$}};
\node[modelnode,fill=yellow!20] (stu\curr2) at ([yshift=-2em]stu\prev2.south) {\rotatebox{90}{Student $2$}};
\node[modelnode,fill=yellow!20] (stu\curr3) at ([yshift=-2em]stu\prev3.south) {\rotatebox{90}{Student $3$}};
\node[modelnode,fill=yellow!20] (stu\curr4) at ([yshift=-2em]stu\prev4.south) {\rotatebox{90}{Student $4$}};
\node[modelnode,fill=yellow!20] (stu\curr5) at ([yshift=-2em]stu\prev5.south) {\rotatebox{90}{Student $5$}};
\node[modelnode] (tea\curr1) at ([yshift=-2em]tea\prev1.south) {\rotatebox{90}{\color{red!60} Teacher $1$}};
\node[modelnode] (tea\curr2) at ([yshift=-2em]tea\prev2.south) {\rotatebox{90}{\color{blue!60} Teacher $2$}};
% ensemble labels
\draw[-latex'] ([xshift=2pt]stu\curr5.east) to node [auto] {\small Ensemble} ([xshift=-2pt]tea\curr1.west);
}
% iteration labels
\node[font=\small,anchor=east,purple!80] (iterate1) at ([xshift=-1em]stu21.west) {\rotatebox{90}{Iteration $1$}};
\node[font=\small,anchor=east,purple!80] (iterate2) at ([xshift=-1em]stu31.west) {\rotatebox{90}{Iteration $2$}};
% distillation labels
\node[font=\small,anchor=south west] (distill1) at ([yshift=0.2em]iterate1.north west) {Distillation};
\node[font=\small,anchor=south west] (distill2) at ([yshift=0.2em]iterate2.north west) {Distillation};
% student groups
\begin{pgfonlayer}{background}
\node[rectangle,draw,very thick,red!60,densely dotted,inner sep=2pt,rounded corners=2pt,fill=red!20] [fit = (stu21) (stu22) (stu23) ] (group21) {};
\node[rectangle,draw,very thick,blue!60,densely dotted,inner sep=2pt,rounded corners=2pt,fill=blue!20] [fit = (stu24) (stu25) ] (group22) {};
\node[rectangle,draw,very thick,blue!60,densely dotted,inner sep=2pt,rounded corners=2pt,fill=blue!20] [fit = (stu31) (stu32) ] (group31) {};
\node[rectangle,draw,very thick,red!60,densely dotted,inner sep=2pt,rounded corners=2pt,fill=red!20] [fit = (stu33) (stu34) (stu35) ] (group32) {};
\end{pgfonlayer}
% distillation
\draw[-latex',red!60,very thick] (tea11.south) .. controls +(south:1.5em) and +(north:2em) .. (group21.north);
\draw[-latex',blue!60,very thick] (tea12.south) .. controls +(south:2em) and +(north:1.5em) .. (group22.north);
\draw[-latex',red!60,very thick] (tea21.south) .. controls +(south:2em) and +(north:2.5em) .. (group32.north);
\draw[-latex',blue!60,very thick] (tea22.south) .. controls +(south:2em) and +(north:1.5em) .. (group31.north);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\setlength{\base}{1.2em}
\tikzstyle{node} = [rounded corners=1pt,minimum width=1.2em,minimum height=1.2em,draw,fill=green!30!white]
\tikzstyle{node2} = [rounded corners=1pt,minimum width=1.2em,minimum height=1.2em,draw,fill=blue!30!white]
\node[node] (enc1) at (0,0) {};
\node[node] (enc2) at ([xshift = \base]enc1.east) {};
\node[node] (enc3) at ([xshift = \base]enc2.east) {};
\node[node] (enc4) at ([xshift = \base]enc3.east) {};
\node[node] (enc5) at ([xshift = \base]enc4.east) {};
\node[node] (enc6) at ([xshift = \base]enc5.east) {};
\node[] (enc7) at ([xshift = \base]enc6.east) {...};
\node[node] (enc8) at ([xshift = \base]enc7.east) {};
\node[node] (enc9) at ([xshift = \base]enc8.east) {};
\node[node] (enc10) at ([xshift = \base]enc9.east) {};
\node[font=\scriptsize,rotate=270] (src) at ([xshift = -\base]enc1.west) {src};
\draw [->] ([xshift=-0.75em]enc1.west) -- (enc1.west);
\draw [decorate,decoration={brace}] ([yshift=0.3em]enc1.north west) to node [auto,anchor=south,font=\scriptsize] {$N$x} ([yshift=0.3em]enc10.north east);
\draw [->] (enc1.east) -- (enc2.west);
\draw [->] (enc2.east) -- (enc3.west);
\draw [->] (enc3.east) -- (enc4.west);
\draw [->] (enc4.east) -- (enc5.west);
\draw [->] (enc5.east) -- (enc6.west);
\draw [->] (enc8.east) -- (enc9.west);
\draw [->] (enc9.east) -- (enc10.west);
\node[node2,anchor=north] (dec1) at ([yshift=-2em]enc1.south) {};
\node[node2,anchor=north] (dec2) at ([yshift=-2em]enc2.south) {};
\node[node2,anchor=north] (dec3) at ([yshift=-2em]enc3.south) {};
\node[node2,anchor=north] (dec4) at ([yshift=-2em]enc4.south) {};
\node[node2,anchor=north] (dec5) at ([yshift=-2em]enc5.south) {};
\node[node2,anchor=north] (dec6) at ([yshift=-2em]enc6.south) {};
\node[font=\scriptsize,rotate=270] (tgt) at ([xshift = -\base]dec1.west) {tgt};
\node[font=\scriptsize,rotate=270] (tgt) at ([xshift = \base]dec6.east) {out};
\draw [->] ([xshift=-0.75em]dec1.west) -- (dec1.west);
\draw [->] (dec6.east) -- ([xshift=0.75em]dec6.east);
\draw [decorate,decoration={brace,mirror}] ([yshift=-0.3em]dec1.south west) to node [auto,anchor=north,font=\scriptsize] {6x} ([yshift=-0.3em]dec6.south east);
\draw [->] (dec1.east) -- (dec2.west);
\draw [->] (dec2.east) -- (dec3.west);
\draw [->] (dec3.east) -- (dec4.west);
\draw [->] (dec4.east) -- (dec5.west);
\draw [->] (dec5.east) -- (dec6.west);
\node[node] (enc_legend) at ([xshift = 2\base]enc10.east) {};
\node[node2,anchor=north] (dec_legend) at ([yshift = -\base]enc_legend.south) {};
\node[font=\scriptsize,anchor=west] (line1) at (enc_legend.east) {:编码层};
\node[font=\scriptsize,anchor=west] (line1) at (dec_legend.east) {:解码层};
%\node[node] (dec1) at ([xshift=4em]enc1.east) {Decoder};
%\node[node2] (enc2) at ([xshift=4em]dec1.east) {Encoder};
%\node[node] (dec2) at ([xshift=4em]enc2.east) {Decoder};
\coordinate (c1) at ([xshift=1em]enc10.east);
\coordinate (c2) at ([yshift=-1.6em]c1.south);
\draw [->,rounded corners] (enc10.east) -- (c1) -- (c2)--([yshift=1em]dec1.north) -- (dec1.north);
\draw [->,rounded corners] (enc10.east) -- (c1) -- (c2)--([yshift=1em]dec2.north) -- (dec2.north);
\draw [->,rounded corners] (enc10.east) -- (c1) -- (c2)--([yshift=1em]dec3.north) -- (dec3.north);
\draw [->,rounded corners] (enc10.east) -- (c1) -- (c2)--([yshift=1em]dec4.north) -- (dec4.north);
\draw [->,rounded corners] (enc10.east) -- (c1) -- (c2)--([yshift=1em]dec5.north) -- (dec5.north);
\draw [->,rounded corners] (enc10.east) -- (c1) -- (c2)--([yshift=1em]dec6.north) -- (dec6.north);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\node[font=\scriptsize] (model) at (0,0) {Model Output:};
\node[anchor=north west,font=\scriptsize] (label_smooth) at ([yshift=-1.8em]model.south west) {Label Smoothing:};
\node[anchor=south west,font=\scriptsize] (one-hot) at ([yshift=2em]model.north west) {One-hot:};
%model out
\node [anchor=west,minimum width=1.2em,minimum height=0.2em,fill=ublue!80,inner sep=0pt] (model_label1) at ([xshift=1.5em,yshift=-0.5em]model.east) {};
\node [anchor=south,font=\scriptsize] (model_w1) at (model_label1.north) {$p_{1}$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.1em,fill=ublue!80,inner sep=0pt] (model_label2) at (model_label1.south east) {};
\node [anchor=south,font=\scriptsize] (model_w2) at (model_label2.north) {$p_{2}$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.7em,fill=ublue!80,inner sep=0pt] (model_label3) at (model_label2.south east) {};
\node [anchor=south,font=\scriptsize] (model_w3) at (model_label3.north) {{\color{red} $p_{3}$}};
\node [anchor=south west,minimum width=1.2em,minimum height=0.4em,fill=ublue!80,inner sep=0pt] (model_label4) at (model_label3.south east) {};
\node [anchor=south,font=\scriptsize] (model_w5) at (model_label4.north) {$p_{4}$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.1em,fill=ublue!80,inner sep=0pt] (model_label5) at (model_label4.south east) {};
\node [anchor=south,font=\scriptsize] (model_w6) at (model_label5.north) {$p_{5}$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.3em,fill=ublue!80,inner sep=0pt] (model_label6) at (model_label5.south east) {};
\node [anchor=south,font=\scriptsize] (model_w7) at (model_label6.north) {$p_{6}$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=ublue!80,inner sep=0pt] (model_label7) at (model_label6.south east) {};
\node [anchor=south,font=\scriptsize] (model_w8) at (model_label7.north) {$p_{7}$};
%no label smooth
\node [anchor=west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label1) at ([xshift=1.5em,yshift=3em]model.east) {};
\node [anchor=south,font=\scriptsize] (one_hot_w1) at (one_hot_label1.north) {$0$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label2) at (one_hot_label1.south east) {};
\node [anchor=south,font=\scriptsize] (one_hot_w2) at (one_hot_label2.north) {$0$};
\node [anchor=south west,minimum width=1.2em,minimum height=1.5em,fill=orange!50,inner sep=0pt] (one_hot_label3) at (one_hot_label2.south east) {};
\node [anchor=south,font=\scriptsize] (one_hot_w3) at (one_hot_label3.north) {{\color{red} $1$}};
\node [anchor=south west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label4) at (one_hot_label3.south east) {};
\node [anchor=south,font=\scriptsize] (one_hot_w4) at (one_hot_label4.north) {$0$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label5) at (one_hot_label4.south east) {};
\node [anchor=south,font=\scriptsize] (one_hot_w5) at (one_hot_label5.north) {$0$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label6) at (one_hot_label5.south east) {};
\node [anchor=south,font=\scriptsize] (one_hot_w6) at (one_hot_label6.north) {$0$};
\node [anchor=south west,minimum width=1.12em,minimum height=0.05em,fill=orange!50,inner sep=0pt,font=\tiny] (one_hot_label7) at (one_hot_label6.south east) {};
\node [anchor=south,font=\scriptsize] (one_hot_w7) at (one_hot_label7.north) {$0$};
%label smoothing
\node [anchor=west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label1) at ([xshift=1.5em,yshift=-3.2em]model.east) {};
\node [anchor=south,font=\scriptsize] (w1) at (label1.north) {$0.1$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label2) at (label1.south east) {};
\node [anchor=south,font=\scriptsize] (w2) at (label2.north) {$0.1$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.8em,fill=red!50,inner sep=0pt] (label3) at (label2.south east) {};
\node [anchor=south,font=\scriptsize] (w3) at (label3.north) {{\color{red} $0.4$}};
\node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label4) at (label3.south east) {};
\node [anchor=south,font=\scriptsize] (w5) at (label4.north) {$0.1$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label5) at (label4.south east) {};
\node [anchor=south,font=\scriptsize] (w6) at (label5.north) {$0.1$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label6) at (label5.south east) {};
\node [anchor=south,font=\scriptsize] (w7) at (label6.north) {$0.1$};
\node [anchor=south west,minimum width=1.2em,minimum height=0.2em,fill=red!50,inner sep=0pt] (label7) at (label6.south east) {};
\node [anchor=south,font=\scriptsize] (w8) at (label7.north) {$0.1$};
\node[font=\scriptsize] (line1) at ([xshift=9em,yshift=-1.5em]model_label7.east) {$loss =-0.3 \log p_{3}-\sum_{i=1}^{7} 0.1 \log p_{i}$};
\node[font=\scriptsize] (line2) at ([xshift=5.9em,yshift=3.5em]model_label7.east) {$loss =-\log p_{3}$};
\begin{pgfonlayer}{background}
\node [rectangle,inner sep=0.1em,rounded corners=1pt,very thick,dotted,draw=red] [fit = (one_hot_label1) (one_hot_w3) (one_hot_label7) (model_label1) (model_label7)] (box1) {};
\node [rectangle,inner sep=0.2em,rounded corners=1pt,fill=purple!10,drop shadow,draw=purple] [fit = (line2)] (box3) {};
\draw [->,dotted,very thick,red] ([yshift=-1em]box1.east) .. controls +(east:1) and +(west:1) .. (box3.west);
\node [rectangle,inner sep=0.1em,rounded corners=1pt,very thick,dotted,draw=ugreen] [fit = (label1) (label7) (model_label1) (model_label7) (model_w3)] (box2) {};
\node [rectangle,inner sep=0.2em,rounded corners=1pt,fill=green!10,drop shadow,draw=ugreen] [fit = (line1)] (box4) {};
\draw [->,dotted,very thick,ugreen] ([yshift=1em]box2.east) .. controls +(east:1) and +(west:1) .. (box4.west);
\end{pgfonlayer}
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\def\neuronsep{1}
\tikzstyle{neuronnode} = [minimum size=1.0em,circle,draw,thick,ublue,inner sep=1pt, fill=white,align=center]
%standard
\foreach \n in {1,...,4}{
\node [neuronnode] (neuron0\n) at (0,\n * \neuronsep) {};
}
\foreach \n in {1,...,4}{
\node [neuronnode] (neuron1\n) at (1.2\neuronsep ,\n * \neuronsep) {};
}
\foreach \n in {1,...,4}{
\node [neuronnode] (neuron2\n) at (2.4*\neuronsep ,\n * \neuronsep) {};
}
\node [neuronnode] (neuron3) at (3.6*\neuronsep ,2.5 * \neuronsep) {};
\foreach \n in {1,...,4}{
\foreach \m in {1,...,4}{
\draw [->] (neuron0\n.east) -- (neuron1\m.west);
}
}
\foreach \n in {1,...,4}{
\foreach \m in {1,...,4}{
\draw [->] (neuron1\n.east) -- (neuron2\m.west);
}
}
\foreach \n in {1,...,4}{
\draw [->] (neuron2\n.east) -- (neuron3.west);
}
%drop
%layer1
\foreach \n in {1,3,4}{
\node [neuronnode] (neuron4\n) at (5*\neuronsep,\n * \neuronsep) {};
}
\node [neuronnode,dashed] (neuron42) at (5*\neuronsep,2 * \neuronsep) {};
%layer1
\foreach \n in {1,2,4}{
\node [neuronnode] (neuron5\n) at (6.2*\neuronsep ,\n * \neuronsep) {};
}
\node [neuronnode,dashed] (neuron53) at (6.2*\neuronsep,3 * \neuronsep) {};
%layer3
\foreach \n in {1,4}{
\node [neuronnode] (neuron6\n) at (7.4*\neuronsep ,\n * \neuronsep) {};
}
\node [neuronnode,dashed] (neuron62) at (7.4*\neuronsep ,2 * \neuronsep) {};
\node [neuronnode,dashed] (neuron63) at (7.4*\neuronsep ,3 * \neuronsep) {};
%layer4
\node [neuronnode] (neuron7) at (8.6*\neuronsep ,2.5 * \neuronsep) {};
\foreach \n in {1,3,4}{
\foreach \m in {1,2,4}{
\draw [->] (neuron4\n.east) -- (neuron5\m.west);
}
}
\foreach \n in {1,2,4}{
\foreach \m in {1,4}{
\draw [->] (neuron5\n.east) -- (neuron6\m.west);
}
}
\foreach \n in {1,4}{
\draw [->] (neuron6\n.east) -- (neuron7.west);
}
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{sublayernode} = [rectangle,draw,thick,inner sep=3pt,rounded corners=2pt,align=center,minimum height=1.5em,minimum width=1.5em,font=\scriptsize]
\tikzstyle{inputnode} = [rectangle,inner sep=3pt,align=center,font=\scriptsize]
%\tikzstyle{circlenode} = [circle,draw,thick,minimum size=0.3\base,font=\small,inner sep=0pt]
\tikzstyle{mnode} = [circle,thick,minimum size=0.7em,font=\small,inner sep=0pt,draw]
\node[anchor=south west,inputnode] (input) at (0,0) {$x_{i}^{l}$};
\node[anchor=west,sublayernode,fill=red!10] (ln) at ([xshift=1.2em]input.east) {LN};
\node[anchor=west,sublayernode,fill=green!10] (fn) at ([xshift=1.2em]ln.east) {F};
\node[anchor=west,mnode] (m) at ([xshift=2em]fn.east) {};
\node[] (res) at ([xshift=2.4em]fn.east) {+};
\node[anchor=west,sublayernode,fill=red!10] (ln1) at ([xshift=2em]m.east) {LN};
\node[anchor=west,sublayernode,fill=green!10] (fn1) at ([xshift=1.2em]ln1.east) {F};
\node[anchor=west,mnode] (m1) at ([xshift=2em]fn1.east) {};
\node[] (res1) at ([xshift=2.4em]fn1.east) {+};
\node[anchor=west,inputnode] (output) at ([xshift=1.2em]res1.east) {$x_{i}^{l+1}$};
\node[anchor=west,inputnode] (legend1) at (6em,-1em) {(a) 标准Transformer网络};
%\coordinate (mend) at ([xshift=1em]m.west);
\draw[-latex',thick] (input)--(ln);
\draw[-latex',thick] (ln)--(fn);
\draw[-latex',thick] (fn)--(m);
%\draw[-,thick] (mend)--(res);
\coordinate (h) at ([xshift=-0.7em]ln.west);
\draw[-latex',thick,rounded corners] (h) -- ([yshift=1.35em]h.north) -- ([yshift=1em]m.north) -- (m.north);
%\coordinate (mend1) at ([xshift=1.0\hseg]m1.west);
\draw[-latex',thick] (m)--(ln1);
\draw[-latex',thick] (ln1)--(fn1);
\draw[-latex',thick] (fn1)--(m1);
%\draw[-,thick] (mend1)--(res1);
\draw[-latex',thick] (m1)--(output);
\coordinate (h1) at ([xshift=-0.7em]ln1.west);
\draw[-latex',thick,rounded corners] (h1) -- ([yshift=1.35em]h1.north) -- ([yshift=1em]m1.north) -- (m1.north);
%--------------------------------------------------------
\node[anchor=south west,inputnode] (input_2) at (0,-6em) {$x_{i}^{l}$};
\node[anchor=west,sublayernode,fill=red!10] (ln_2) at ([xshift=1.2em]input_2.east) {LN};
\node[anchor=west,sublayernode,fill=green!10] (fn_2) at ([xshift=1.2em]ln_2.east) {F};
\node[anchor=west,mnode] (m_2) at ([xshift=2em]fn_2.east) {};
\node[] (res_2) at ([xshift=2.4em]fn_2.east) {+};
\node[anchor=west,sublayernode,fill=red!10] (ln1_2) at ([xshift=2em]m_2.east) {LN};
\node[anchor=west,sublayernode,fill=green!10] (fn1_2) at ([xshift=1.2em]ln1_2.east) {F};
\node[anchor=west,mnode] (m1_2) at ([xshift=2em]fn1_2.east) {};
\node[] (res1_2) at ([xshift=2.4em]fn1_2.east) {+};
\node[anchor=west,inputnode] (output_2) at ([xshift=1.2em]res1_2.east) {$x_{i}^{l+1}$};
\node[anchor=west,inputnode] (legend2) at (2.5em,-7.5em) {(b) 引入Layer Dropout后的Transformer网络};
\node[anchor=south west,inputnode,red,font=\tiny] (mlable) at ([xshift=-2.2em,yshift=-0.6em]m_2.south) {M=1};
\node[anchor=south west,inputnode,red,font=\tiny] (mlable1) at ([xshift=-2.2em,yshift=-0.6em]m1_2.south) {M=0};
\coordinate (start_1) at ([xshift=-1.3em]m_2.west);
\coordinate (end_1) at ([xshift=-0.5em]m_2.west);
%\node[red,font=\scriptsize] (dot1) at (start_1) {$\cdot$};
\draw[-latex',thick] (input_2)--(ln_2);
\draw[-latex',thick] (ln_2)--(fn_2);
\draw[-latex',thick] (fn_2)--(start_1);
\draw[-,thick,red] (start_1)--(end_1);
\draw[-,thick] (end_1)--(m_2);
%\draw[-,thick] (mend)--(res);
\coordinate (h_2) at ([xshift=-0.7em]ln_2.west);
\draw[-latex',thick,rounded corners] (h_2) -- ([yshift=1.35em]h_2.north) -- ([yshift=1em]m_2.north) -- (m_2.north);
%\coordinate (mend1) at ([xshift=1.0\hseg]m1.west);
\coordinate (start_2) at ([xshift=-1.3em]m1_2.west);
\coordinate (end_2) at ([xshift=-0.5em]m1_2.west);
\draw[-latex',thick] (m_2)--(ln1_2);
\draw[-latex',thick] (ln1_2)--(fn1_2);
\draw[-latex',thick] (fn1_2)--(start_2);
\draw[-,thick,red] (start_2)--([yshift=0.3em]end_2);
\draw[-,thick] (end_2)--(m1_2);
%\draw[-,thick] (mend1)--(res1);
\draw[-latex',thick] (m1_2)--(output_2);
\coordinate (h1_2) at ([xshift=-0.7em]ln1_2.west);
\draw[-latex',thick,rounded corners] (h1_2) -- ([yshift=1.35em]h1_2.north) -- ([yshift=1em]m1_2.north) -- (m1_2.north);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{node} = [minimum height=1.0*1.2em,draw,fill=green!20]
\node[node,minimum width=2.0*1.2em] (sent1) at (0,0) {};
\node[node,minimum width=5.0*1.2em,anchor=north west] (sent2) at (sent1.south west) {};
\node[node,minimum width=1.0*1.2em,anchor=north west] (sent3) at (sent2.south west) {};
\node[node,minimum width=3.0*1.2em,anchor=north west] (sent4) at (sent3.south west) {};
\node[node,minimum width=4.0*1.2em] (sent5) at (14em,0) {};
\node[node,minimum width=4.5*1.2em,anchor=north west] (sent6) at (sent5.south west) {};
\node[node,minimum width=4.5*1.2em,anchor=north west] (sent7) at (sent6.south west) {};
\node[node,minimum width=5*1.2em,anchor=north west] (sent8) at (sent7.south west) {};
\node[font=\footnotesize,anchor=east] (line1) at (sent1.west) {句子1};
\node[font=\footnotesize,anchor=east] (line2) at (sent2.west) {句子2};
\node[font=\footnotesize,anchor=east] (line3) at (sent3.west) {句子3};
\node[font=\footnotesize,anchor=east] (line4) at (sent4.west) {句子4};
\node[font=\footnotesize,anchor=east] (line5) at (sent5.west) {句子1};
\node[font=\footnotesize,anchor=east] (line6) at (sent6.west) {句子2};
\node[font=\footnotesize,anchor=east] (line7) at (sent7.west) {句子3};
\node[font=\footnotesize,anchor=east] (line8) at (sent8.west) {句子4};
\begin{pgfonlayer}{background}
\node [rectangle,inner sep=-0.0em,draw] [fit = (sent1) (sent2) (sent3) (sent4)] (box1) {};
\node [rectangle,inner sep=-0.0em,draw] [fit = (sent5) (sent6) (sent7) (sent8)] (box2) {};
\end{pgfonlayer}
\node[font=\footnotesize] (node1) at ([yshift=-3.4em]sent2.south) {随机生成};
\node[font=\footnotesize] (node2) at ([yshift=-1em]sent8.south) {排序生成};
\end{tikzpicture}
\ No newline at end of file
\begin{tabular}{l l l}
\begin{tikzpicture}
\draw[->, thick] (0,0) to (3,0);
\draw[->, thick] (0,-0) to (0,2);
\node (a) at (1*0.3,6*0.2) {};
\node (b) at (2*0.3,4*0.2) {};
\node (c) at (3*0.3,3*0.2) {};
\node (d) at (4*0.3,3*0.2) {};
\node (e) at (6*0.3,4*0.2) {};
\node (f) at (7*0.3,6*0.2) {};
\node (g) at (8*0.3,8.4*0.2) {};
\node (h) at (9*0.3,9.7*0.2) {};
\fill [black] (a) circle(1pt);
\fill [black] (b) circle(1pt);
\fill [black] (c) circle(1pt);
\fill [black] (d) circle(1pt);
\fill [black] (e) circle(1pt);
\fill [black] (f) circle(1pt);
\fill [black] (g) circle(1pt);
\fill [black] (h) circle(1pt);
% y=0.73x + 2.54
\draw [thick,red] (0.5*0.3,1.81*0.2) to (10*0.3,9.84*0.2);
\node [font=\footnotesize] at (1.5,-0.5) {欠拟合};
\end{tikzpicture}
&\begin{tikzpicture}
\draw[->, thick] (0,0) to (3,0);
\draw[->, thick] (0,-0) to (0,2);
\node (a) at (1*0.3,6*0.2) {};
\node (b) at (2*0.3,4*0.2) {};
\node (c) at (3*0.3,3*0.2) {};
\node (d) at (4*0.3,3*0.2) {};
\node (e) at (6*0.3,4*0.2) {};
\node (f) at (7*0.3,6*0.2) {};
\node (g) at (8*0.3,8.4*0.2) {};
\node (h) at (9*0.3,9.7*0.2) {};
\fill [black] (a) circle(1pt);
\fill [black] (b) circle(1pt);
\fill [black] (c) circle(1pt);
\fill [black] (d) circle(1pt);
\fill [black] (e) circle(1pt);
\fill [black] (f) circle(1pt);
\fill [black] (g) circle(1pt);
\fill [black] (h) circle(1pt);
\draw [thick,red] (0.5*0.3,6.15*0.2) to [bend right] (5*0.3,3*0.2) ;
\draw [thick,red] (5*0.3,3*0.2) to [bend right] (8.5*0.3,10*0.2) ;
\node [font=\footnotesize] at (1.5,-0.5) {拟合合适};
\end{tikzpicture}
&\begin{tikzpicture}
\draw[->, thick] (0,0) to (3,0);
\draw[->, thick] (0,-0) to (0,2);
\node (a) at (1*0.3,6*0.2) {};
\node (b) at (2*0.3,4*0.2) {};
\node (c) at (3*0.3,3*0.2) {};
\node (d) at (4*0.3,3*0.2) {};
\node (e) at (6*0.3,4*0.2) {};
\node (f) at (7*0.3,6*0.2) {};
\node (g) at (8.4*0.3,8.4*0.2) {};
\node (h) at (9.4*0.3,9.7*0.2) {};
\fill [black] (a) circle(1pt);
\fill [black] (b) circle(1pt);
\fill [black] (c) circle(1pt);
\fill [black] (d) circle(1pt);
\fill [black] (e) circle(1pt);
\fill [black] (f) circle(1pt);
\fill [black] (g) circle(1pt);
\fill [black] (h) circle(1pt);
%0-a
\draw [thick,red] (0.2*0.3,4*0.2) to [bend left] (1*0.3,6*0.2) ;
% a-b
\draw [thick,red] (1*0.3,6*0.2) to [bend left] (2*0.3,3*0.2) ;
% b-c
\draw [thick,red] (2*0.3,3*0.2) to [bend right] (3*0.3,2.5*0.2) ;
% c-d
\draw [thick,red] (3*0.3,2.5*0.2) to [bend left] (3.5*0.3,4*0.2) ;
\draw [thick,red] (3.5*0.3,4*0.2) to [bend left] (4.3*0.3,2*0.2) ;
\draw [thick,red] (4.3*0.3,2*0.2) to [bend right] (5*0.3,1.5*0.2) ;
% d-e
\draw [thick,red] (5*0.3,1.5*0.2) to [bend right] (6.2*0.3,7*0.2) ;
\draw [thick,red] (6.2*0.3,7*0.2) to [bend right] (6.5*0.3,7*0.2) ;
% e-f
\draw [thick,red] (6.5*0.3,7*0.2) to [bend left] (7*0.3,5*0.2) ;
\draw [thick,red] (7*0.3,5*0.2) to [bend right] (7.5*0.3,4*0.2) ;
\draw [thick,red] (7.5*0.3,4*0.2) to [bend right] (8*0.3,4*0.2) ;
%
% f-g
\draw [thick,red] (8*0.3,4*0.2) to [bend right] (8*0.3,10*0.2) ;
\draw [thick,red] (8*0.3,10*0.2) to [bend left] (8.7*0.3,10*0.2) ;
% g-h
\draw [thick,red] (8.7*0.3,10*0.2) to [bend left] (9.7*0.3,9.4*0.2) ;
\node [font=\footnotesize] at (1.5,-0.5) {过拟合};
\end{tikzpicture} \\
\end{tabular}
\ No newline at end of file
......@@ -12,7 +12,7 @@
%----------------------------------------------------------------------------------------
% CONFIGURATIONS
%----------------------------------------------------------------------------------------
\part{机器翻译前沿}
\renewcommand\figurename{}%将figure改为图
\renewcommand\tablename{}%将figure改为图
\chapterimage{fig-NEU-4.jpg} % Chapter heading image
......@@ -27,4 +27,498 @@
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{}
\sectionnewpage
\section{正则化}\label{subsection-13.1}
\parinterval {\small\bfnew{正则化}}\index{正则化}(Regularization)\index{Regularization}是机器学习中的经典技术,通常用于缓解{\small\bfnew{过拟合问题}}\index{过拟合问题}(The Overfitting Problem)\index{Overfitting Problem}。正则化的概念源自线性代数和代数几何。在实践中,它更多的是指对{\small\bfnew{反问题}}\index{反问题}(The Inverse Problem)\index{Inverse Problem}的一种求解方式。假设输入$x$和输出$y$之间存在一种映射$f$
\begin{eqnarray}
y = f(x)
\label{eq:13-1}
\end{eqnarray}
\noindent 反问题是指:当观测到$y$时,能否求出$x$。反问题对应了很多实际问题,比如,可以把$y$看作经过美化的图片,$x$看作原始的图片,反问题就对应了图片还原。机器翻译的训练也是一种反问题,因为可以把$y$看作是正确的译文,$x$看作是输入句子或者模型参数\footnote{在训练中,如果把源语言句子看作是不变的量,这时$f$的输入只有模型参数。}
\parinterval 理想的情况下,我们希望反问题的解是{\small\bfnew{适定的}}\index{适定的}(Well-posed)\index{Well-posed}。所谓适定解,需要满足三个条件:解是存在的、解是唯一的、解是稳定的(即$y$微小的变化会导致$x$微小的变化,也被称作解连续)。所有不存在唯一稳定解的问题都被称作{\small\bfnew{不适定问题}}\index{不适定问题}(Ill-posed Problem)\index{Ill-posed Problem}。对于机器学习问题,解的存在性比较容易理解。解的唯一性大多由问题决定。比如,如果把描述问题的函数$f(\cdot)$看作一个$n\times n$矩阵$\mathbf{A}$$x$$y$都看作是$n$维向量。那么$x$不唯一的原因在于$\mathbf{A}$不满秩(非奇异矩阵)。不过,存在性和唯一性并不会对机器学习方法造成太大困扰,因为在实践中往往会找到近似的解。
\parinterval 但是,解的稳定性却给神经机器翻译带来了很大的挑战。因为神经机器翻译模型非常复杂,里面存在大量的矩阵乘法和非线性变化。这导致$f(\cdot)$往往是不稳定的,也就是说,神经机器翻译中输出$y$ 的微小变化会导致输入$x$的巨大变化。比如,在系统研发中经常会发现,即使训练样本发生很小的变化,模型训练得到的参数都会有非常明显的区别。不仅如此,神经机器翻译模型参数解的稳定性还存在两方面问题:
\begin{itemize}
\vspace{0.5em}
\item 观测数据不充分。由于语言现象的多样性,训练样本只能覆盖非常有限的翻译现象。从样本的表示空间上看,对于没有观测样本的区域,根本无法知道真实解的样子,更不用说稳定性训练了。
\vspace{0.5em}
\item 数据中存在噪声。噪声问题是稳定性训练最大的挑战之一。因为,即使是很小的噪声,也可能会导致解的巨大变化。
\vspace{0.5em}
\end{itemize}
\parinterval 以上问题体现出来的现象就是过拟合。因为训练数据有限同时存在噪声,因此模型参数会过分拟合噪声数据。而且,这样的模型参数又与真实(理想)的模型参数相差很远。正则化正是针对这个问题。有时候,正则化也被称作{\small\bfnew{降噪}}\index{降噪}(Denoising)\index{Denoising},虽然它的出发点并不只是去除噪声的影响。图\ref{fig:13-11}对比了不同函数对二维空间中一些数据点的拟合情况。在过拟合现象中,函数可以完美的拟合所有的数据点,即使有些数据点是噪声。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-underfitting-vs-overfitting}
\caption{欠拟合 vs 过拟合}
\label{fig:13-11}
\end{figure}
%----------------------------------------------
\parinterval 正则化的一种实现是在训练目标中引入一个正则项。在神经机器翻译中,引入正则项的训练目标为:
\begin{eqnarray}
\widehat{\mathbf{w}}=\argmax_{\mathbf{w}}L(\mathbf{w}) + \lambda R(\mathbf{w})
\label{eq:13-2}
\end{eqnarray}
\noindent 其中,$L(\mathbf{w})$是损失函数,$R(\mathbf{w})$是正则项,$\lambda$是正则项的系数,用于控制正则化对训练影响的程度。$R(\mathbf{w})$通常也可以被看作是一种先验,因为在数据不充分且存在噪声的情况下,可以根据一些先验知识让模型偏向正确的方向一些,而不是一味地根据受噪声影响的不准确的$L(\mathbf{w})$进行优化。相应的,引入正则化后的模型可以获得更好的{\small\bfnew{泛化}}\index{泛化}(Generalization)\index{Generalization}能力,即模型在新的未见数据上表现会更好。
\parinterval 实践中已经证明,正则化方法有助于像神经机器翻译这样复杂的模型获得稳定的模型参数。甚至有些情况下,如果不引入正则化,训练得到的翻译模型根本无法使用。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{L1/L2正则化}
\parinterval L1/L2正则化是常用的正则化方法。它们分别对应正则项是L1和L2范数的情况。具体来说,L1正则化是指
\begin{eqnarray}
R(\mathbf{w}) & = & \big| |\mathbf{w}| {\big|}_1 \\
& = &\sum_{w_i}|w_i| \nonumber
\label{eq:13-3}
\end{eqnarray}
\parinterval L2正则化是指
\begin{eqnarray}
R(\mathbf{w}) & = & (\big| |\mathbf{w}| {\big|}_2)^2 \\
& = &\sum_{w_i}{w_i}^2 \nonumber
\label{eq:13-4}
\end{eqnarray}
\parinterval 从几何的角度看,L1和L2正则项都是有物理意义的。二者都可以被看作是空间上的一个区域,比如,在二维平面上,L1范数表示一个以0点为中心的矩形,L2范数表示一个以0点为中心的圆。因此,优化问题可以被看作是在两个区域($L(\mathbf{w})$$R(\mathbf{w})$)叠加在一起所形成的区域上进行优化。由于L1和L2正则项都是在0点(坐标原点)附近形成的区域,因此优化的过程可以确保参数不会偏离0点太多。也就是说,L1和L2正则项引入了一个先验:模型的解不应该离0点太远。而L1和L2正则项实际上是在度量这个距离。
\parinterval 那为什么要用L1和L2正则项惩罚离0点远的解呢?这还要从模型复杂度谈起。实际上,对于神经机器翻译这样的模型来说,模型的容量是足够的。所谓容量可以被简单的理解为独立参数的个数 \footnote{关于模型容量,在\ref{section-13.2}节会有进一步讨论。}。也就是说,理论上存在一种模型可以完美的描述问题。但是,从目标函数拟合的角度来看,如果一个模型可以拟合很复杂的目标函数,那模型所表示的函数形态也会很复杂。这往往体现在模型中参数的值``偏大''。比如,用一个多项式函数拟合一些空间中的点,如果希望拟合得很好,各个项的系数往往是非零的。而且为了对每个点进行拟合,通常需要多项式中的某些项具有较大的系数,以获得函数在局部有较大的斜率。显然,这样的模型是很复杂的。而模型的复杂度可以用函数中的参数(比如多项式中各项的系数)的``值''进行度量,体现出来就是模型参数的范数。
\parinterval 因此,L1和L2正则项的目的是防止模型为了匹配少数(噪声)样本而导致模型的参数过大。反过来说,L1和L2正则项会鼓励那些参数值在0点附近的情况。从实践的角度看,这种方法可以很好的对统计模型的训练进行校正,得到泛化能力更强的模型。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{标签平滑}
\parinterval 神经机器翻译在每个目标语位置$j$会输出一个分布$y_j$,这个分布描述了每个目标语言单词出现的可能性。在训练时,每个目标语言位置上的答案是一个单词,也就对应了One-hot分布$\tilde{y}_j$,它仅仅在正确答案那一维为1,其它维均为0。模型训练可以被看作是一个调整模型参数让$y_j$逼近$\tilde{y}_j$的过程。但是,$\tilde{y}_j$的每一个维度是一个非0即1的目标,这样也就无法考虑类别之间的相关性。具体来说,除非模型在答案那一维输出1,否则都会得到惩罚。即使模型把一部分概率分配给与答案相近的单词(比如同义词),这个相近的单词仍被视为完全错误的预测。
\parinterval {\small\bfnew{标签平滑}}\index{标签平滑}(Label Smoothing)\index{Label Smoothing}的思想很简单\cite{Szegedy_2016_CVPR}:答案所对应的单词不应该``独享''所有的概率,其它单词应该有机会作为答案。这个观点与第二章中语言模型的平滑非常类似。在复杂模型的参数估计中,往往需要给未见或者低频事件分配一些概率,以保证模型具有更好的泛化能力。具体实现时,标签平滑使用了一个额外的分布$q$,它是在词汇表$V$ 上的一个均匀分布,即$q(k)=\frac{1}{|V|}$,其中$q(k)$表示分布的第$k$维。然后,答案分布被重新定义为$\tilde{y}_j$$q$的线性插值:
\begin{eqnarray}
y_{j}^{ls}=(1-\alpha) \cdot \tilde{y}_j + \alpha \cdot q
\label{eq:13-5}
\end{eqnarray}
\noindent 这里$\alpha$表示一个系数,用于控制分布$q$的重要性。$y_{j}^{ls}$会被作为最终的答案分布用于模型的训练。
\parinterval 标签平滑实际上定义了一种``软''标签,使得所有标签都可以分到一些概率。一方面可以缓解数据中噪声的影响,另一方面目标分布会更合理(显然,真实的分布不应该是One-hot分布)。图\ref{fig:13-12}展示了标签平滑前后的损失函数计算结果的对比。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-label-smoothing}
\caption{不使用标签平滑 vs 使用标签平滑}
\label{fig:13-12}
\end{figure}
%----------------------------------------------
\parinterval 标签平滑也可以被看作是对损失函数的一种调整,并引入了额外的先验知识(即与$q$相关的部分)。只不过这种先验知识并不是通过线性插值的方式与原始损失函数进行融合(公式\ref{eq:13-2})。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{Dropout}
\parinterval 神经机器翻译模型是一种典型的多层神经网络模型。每一层网络都包含若干神经元,负责接收前一层所有神经元的输出,并进行诸如乘法、加法等变换,并有选择的使用非线性的激活函数,最终得到当前层每个神经元的输出。从模型最终预测的角度看,每个神经元都在参与最终的预测。理想的情况下,我们希望每个神经元都能相互独立的做出``贡献''。这样的模型会更加健壮,因为即使一部分神经元不能正常工作,其它神经元仍然可以独立做出合理的预测。但是,随着每一层神经元数量的增加以及网络结构的复杂化,研究者发现神经元之间会出现{\small\bfnew{相互适应}}\index{相互适应}(Co-Adaptation)\index{Co-Adaptation}的现象。所谓相互适应是指,一个神经元对输出的贡献与同一层其它神经元的行为是相关的,也就是说这个神经元已经适应到它周围的``环境''中。
\parinterval 相互适应的好处在于神经网络可以处理更加复杂的问题,因为联合使用两个神经元要比单独使用每个神经元的表示能力强。这也类似于传统机器学习任务中往往会设计一些高阶特征,比如自然语言序列标注中对bi-gram和tri-gram的使用。不过另一方面,相互适应会导致模型变得更加``脆弱''。因为相互适应的神经元可以更好的描述训练数据中的现象,但是在测试数据上,由于很多现象是未见的,细微的扰动会导致神经元无法适应。具体体现出来就是过拟合问题。
\parinterval Dropout是解决这个问题的一种常用方法\cite{DBLP:journals/corr/abs-1207-0580}。方法很简单,在训练时随机让一部分神经元停止工作,这样每次参数更新中每个神经元周围的环境都在变化,它就不会过分适应到环境中。图\ref{fig:13-13}中给出了某一次参数训练中使用Dropout之前和之后的状态对比。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-network-with-dropout}
\caption{使用Dropout之前(左)和之后(右)神经网络状态的对比,其中虚线圆圈表示不工作的神经元,实线圆圈表示工作的神经元。}
\label{fig:13-13}
\end{figure}
%----------------------------------------------
\parinterval 具体实现时,可以设置一个参数$p\in (0,1)$。在每次参数更新所使用的前向和反向计算中,每个神经元都以概率$p$停止工作。相当于每层神经网络会有以$p$为比例的神经元被``屏蔽''掉。每一次参数更新中会随机屏蔽不同的神经元。图\ref{fig:13-14}给出了Dropout方法和传统方法计算方式的对比。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-computation-of-dropout}
\caption{使用Dropout之前(左)和之后(右)一层神经网络的计算}
\label{fig:13-14}
\end{figure}
%----------------------------------------------
\parinterval 对于新的样本,可以使用Dropout训练之后的模型对其进行推断,但是每个神经元的输出要乘以$1-p$,以保证每层神经元输出的期望和训练时是一样的。另一种常用的做法是,在训练时对每个神经元的输出乘以$\frac{1}{1-p}$,然后在推断时神经网络可以不经过任何调整就直接使用。
\parinterval Dropout方法的另一种解释是,训练中屏蔽掉一些神经元相当于从原始的神经网络中抽取出了一个子网络。这样,每次训练都在一个随机生成的子网络上进行,而不同子网络之间的参数是共享的。在推断时,则把所有的子网络集成到一起。这种思想也有一些{\small\bfnew{集成学习}}\index{集成学习}(Ensemble Learning)\index{Ensemble Learning}的味道。只不过Dropout中子模型(或子网络)是在指数级空间中采样出来的。由于Dropout可以很好的缓解复杂神经模型的过拟合问题,因此也成为了大多数神经机器翻译系统的标配。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{Layer Dropout}
\parinterval 随时网络层数的增多,相互适应也会出现在不同层之间。特别是在引入残差网络之后,不同层的输出可以进行线性组合,因此不同层之间的相互影响会更加直接。对于这个问题,也可以使用Dropout的思想对不同层进行屏蔽。比如,可以使用一个开关来控制一个层能否发挥作用,这个开关以概率$p$被随机关闭,即该层有为$p$的可能性不工作。图\ref{fig:13-15}展示了Transformer多层网络引入Layer Dropout 前后的情况。可以看到,使用Layer Dropout后,开关M会被随机打开或者关闭,以达到屏蔽某一层计算的目的。由于使用了残差网络,关闭每一层相当于``跳过''这一层网络,因此Layer Dropout并不会影响神经网络中数据流的传递。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-norm}
\caption{标准Transformer网络(a) vs 引入Layer Dropout后的Transformer网络(b)}
\label{fig:13-15}
\end{figure}
%----------------------------------------------
\parinterval Layer Dropout可以被理解为在一个深网络(即原始网络)中随机采样出一个由若干层网络构成的``浅''网络。不同``浅''网络所对应的同一层的模型参数是共享的。这也达到了对指数级子网络高效训练的目的。需要注意的是,在推断阶段,每层的输出需要乘以$1-p$,确保训练时每层输出的期望和解码是一致的。Layer Dropout可以非常有效的缓解深层网路中的过拟合问题。在\ref{subsection-13.1}节还会看到Layer Dropout可以成功地帮助我们训练Deep Transformer模型。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{增大模型容量}\label{section-13.2}
\parinterval 神经机器翻译是一种典型的多层神经网络。一方面,可以通过设计合适的网络连接方式和激活函数来捕捉复杂的翻译现象;另一方面,越来越多的可用数据让模型能够得到更有效的训练。在训练数据较为充分的情况下,设计更加``复杂''的模型成为了提升系统性能的有效手段。比如,Transformer模型有两个常用配置Transformer-Base和Transformer-Big。其中,Transformer-Big比Transformer-Base使用了更多的神经元,相应的翻译品质更优\cite{NIPS2017_7181}
\parinterval 那么是否还有类似的方法可以改善系统性能呢?答案显然是肯定的。这里,把这类方法统称为基于大容量模型的方法。在传统机器学习的观点中,神经网络的性能不仅依赖于架构设计,同样与容量密切相关。那么什么是模型的{\small\bfnew{容量}}\index{容量}(Capacity)\index{Capacity}?简单理解,容量是指神经网络的参数量,即神经元之间连接权重的个数。另一种定义是把容量看作神经网络所能表示的假设空间大小\cite{DBLP:journals/nature/LeCunBH15},也就是神经网络能表示的不同函数所构成的空间。
\parinterval 而学习一个神经网络就是要找到一个``最优''的函数,它可以准确地拟合数据。当假设空间变大时,训练系统有机会找到更好的函数,但是同时也需要依赖更多的训练样本才能完成最优函数的搜索。相反,当假设空间变小时,训练系统会更容易完成函数搜索,但是很多优质的函数可能都没有被包含在假设空间里。这也体现了一种简单的辩证思想:如果训练(搜索)的代价高,会有更大的机会找到更好的解;另一方面,如果想少花力气进行训练(搜索),那就设计一个小一些的假设空间,在小一些规模的样本集上进行训练,当然搜索到的解可能不是最好的。
\parinterval 在很多机器翻译任务中,训练数据是相对充分的。这时增加模型容量是提升性能的一种很好的选择。常见的方法有三种:
\begin{itemize}
\vspace{0.5em}
\item 增加隐藏层维度:即增加网络宽度,加强每一层网络的线性拟合能力。
\vspace{0.5em}
\item 增加网络的整体层数:即增加网络深度,利用更多的线性和非线性变换来获得更复杂的特征抽取能力。
\vspace{0.5em}
\item 增大输入层和输出层的维度:即增强模型对词表中每个词的表示能力。
\end{itemize}
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{宽网络}
\parinterval 宽网络通常指隐藏层维度更大的网络,目前在图像处理领域和自然语言处理领域被广泛地使用。第五章已经验证了包含足够多神经元的多层前馈神经网络可以无限逼近任意复杂的连续函数\cite{Hornic1989Multilayer},这也在一定程度上说明了神经网络建模中神经元数目的重要性。
\parinterval 增大隐藏层神经元的数目是网络变宽的基本方式之一。例如,图像处理领域中提出的{\small\bfnew{宽残差网络}}\index{宽残差网络}(Wide Residual Network)\index{Wide Residual Network}使用更大的卷积核来提高每次卷积计算的精度\cite{DBLP:conf/bmvc/ZagoruykoK16};神经机器翻译中,Transformer-Big模型广受研究人员的认可\cite{NIPS2017_7181},它同样是一个典型的宽网络。对比基线模型Transformer-Base,Transformer-Big通过扩大隐藏层维度与滤波器(Filter)维度,取得了显著的翻译性能提升。表\ref{tab:13-2}是相应的参数设置。
%----------------------------------------------
\begin{table}[htp]
\centering
\caption{基线网络与宽网络的参数设置}
\begin{tabular}{ l | l l}
& Transformer-Base &Transformer-Big \\ \hline
\rule{0pt}{13pt} 词向量维度 & 512 &1024 \\
\rule{0pt}{13pt} 注意力头数 &8 &16 \\
\rule{0pt}{13pt} 隐藏层维度 &512 &1024 \\
\rule{0pt}{13pt} FFN子层映射维度 &2048 &4096
\end{tabular}
\label{tab:13-2}
\end{table}
%--------------------------------------
\parinterval 值得注意的是, Transformer模型中的前馈神经网络子层将隐藏层表示映射到更高维度的空间(通过一个Filter),之后经过激活函数Relu后再映射回原来的维度大小。这个操作对翻译模型的性能有明显的正向作用。从表\ref{tab:13-2}中可以看出,Filter的维度是普通隐藏层维度的四倍。通过增大Filter大小可以有效地扩展网络的宽度,比如,有些情况下可以将Filter增大到8192甚至更大。
\parinterval 但伴随着模型变宽,网络的整体参数量会显著增长\footnote{在一个全连接神经网络中,参数的数量与各层宽度呈平方关系。}。同时,宽网络需要更长的训练时间才能达到稳定的收敛状态。此外,训练宽网络时通常需要对一些超参数进行相应的调整,例如Dropout的大小,学习率的峰值等。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{深网络}
\parinterval 虽然,理论上宽网络有能力拟合任意的函数,但是获得这种能力的代价是非常高的。在实践中,往往需要增加相当的宽度,以极大的训练代价才能换来少量的性能提升。当神经网络达到一定宽度后这种现象更为严重。``无限''增加宽度显然是不现实的。
\parinterval 因此,另一种思路是使用更深的网络以增加模型的容量。深网络是指包含更多层的神经网络。相比宽网络的参数量随着宽度呈平方增长,深网络的参数量随着深度呈线性增长。这带给深网络一个优点:在同样参数量下可以通过更多的非线性变换来对问题进行描述。这也赋予了深网络对复杂问题建模的能力。比如,在图像识别领域,很多先进的系统都是基于很深的神经网络,甚至在一些任务上最好的的结果需要1000 层以上的神经网络。
\parinterval 宽网络和深网络是增加模型表示能力的两个维度。宽网络相当于增强了模型线性变换的能力,将模型的输入在更高维度的空间上进行抽象;深网络通过引入更多的层构建了多个表示空间,通过逐层的变换,在多个表示空间上对输入进行多次抽象。二者在有些情况下甚至可以相互转换。
\parinterval 除了数学上的解释,深度神经网络也可以给分析、理解现实世界的问题提供有效的手段。很多时候,可以把一个多层神经网络看作是对一个复杂问题的拆解,每层(或每几层)是在处理一个子问题。例如,在人脸识别任务中,一个3层的神经网络中第一层主要提取低层次的简单特征,即边缘特征;第二层将简单的特征组合成更为复杂的特征,如器官特征;第三层针对第二层的输出进行进一步的抽象得到人脸的面部特征。这样,深网络通过不同层的逐层特征抽象可以在人脸识别数据集上超越人类的精度\cite{DBLP:journals/corr/HeZRS15}
\parinterval 类似的现象也出现在基于语言模型的预训练任务中。比如,研究人员通过使用{\small\bfnew{探测任务}}\index{探测任务}(Probing Task)\index{Probing Task}来分析12层的BERT模型中的不同层所表示的含义\cite{ethayarajh-2019-contextual,DBLP:conf/acl/JawaharSS19}
\begin{itemize}
\vspace{0.5em}
\item 浅层网络表示:网络的底层部分更擅长处理词串的{\small\bfnew{表面信息}}\index{表面信息}(Surface Information)\index{Surface Information},例如词性选择、词义消歧等。
\vspace{0.5em}
\item 中间层的表示:中间层部分更关注于{\small\bfnew{语法信息}}\index{语法信息}(Syntactic Information)\index{Syntactic Information}
\vspace{0.5em}
\item 顶层网络的表示:上层部分更擅长处理{\small\bfnew{语义信息}}\index{语义信息}(Semantic Information)\index{Semantic Information}
\vspace{0.5em}
\end{itemize}
\parinterval 目前在神经机器翻译领域,研究人员发现编码端的表示能力对翻译性能有较大的影响,因此加深编码网络是一种有效的改进系统的手段(如图\ref{fig:13-16} )。而且,增加编码端的深度对模型推断的速度并没有较大影响,因为整个序列可以通过GPU进行并行计算。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-increase-the-encoder}
\caption{增大神经机器翻译的编码端来增大模型的容量}
\label{fig:13-16}
\end{figure}
%----------------------------------------------
\parinterval 不过,深网络容易发生梯度消失和梯度爆炸问题。因此在使用深网络时,训练策略的选择是至关重要的。实际上,标准的Transformer模型已经是不太``浅''的神经网络,因此里面使用了残差连接来缓解梯度消失等问题。此外,为了避免过拟合,深层网络的训练也要与Dropout等正则化策略相配合,并且需要设计恰当的参数初始化方法和学习率调整策略。关于构建深层神经机器翻译的方法,本章\ref{subsection-7.5.1}节还会有进一步讨论。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{增大输入层和输出层表示能力}
\parinterval 如前所述,神经机器翻译的原始输入是单词序列,包括源语言端和目标语言端。模型中的输入层将这种离散的单词表示转换成实数向量的表示,也就是常说的{\small\bfnew{词嵌入}}\index{词嵌入}(Embedding)\index{Embedding}。从实现的角度来看,输入层其实就是从一个词嵌入矩阵中提取对应的词向量表示,这个矩阵两个维度大小分别对应着词表大小和词嵌入的维度。词嵌入的维度也代表着模型对单词刻画的能力。因此适当增加词嵌入的维度也是一种增加模型容量的手段。通常,词嵌入和隐藏层的维度是一致的,这种设计也是为了便于系统实现。
\parinterval 当然,并不是说词嵌入的维度一定越大就越好。本质上,词嵌入是要在一个多维空间上有效的区分含有不同语义的单词。如果词表较大,更大的词嵌入维度会更有意义,因为需要更多的``特征''描述更多的语义。当词表较小时,增大词嵌入维度可能不会带来增益,相反会增加系统计算的负担。另一种策略是,动态选择词嵌入维度,比如,对于高频词使用较大的词嵌入维度,而对于低频词则使用较小的词嵌入维度\cite{DBLP:conf/iclr/BaevskiA19}。这种方法可以用同样的参数量处理更大的词表。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{大模型的分布式计算}
\parinterval 伴随着模型容量的增大,复杂模型可能无法在单GPU上完成训练。比如,即使是不太复杂的Transformer-Base模型在很多任务上也需要在8张GPU进行训练。如何利用多个设备进行大模型的并行训练是一个很现实的问题。比较简单的策略是使用{\small\bfnew{数据并行}}\index{数据并行}(Data Parallelism)\index{Data Parallelism},即把一个批次分到多个GPU上进行训练,之后对多个GPU上的梯度进行汇总,并更新参数。不过,当模型规模增大到一定程度时,单GPU可能仍然无法处理。这个问题在GPU显存较小的时候会非常突出。这时需要考虑{\small\bfnew{模型并行}}\index{模型并行}(Model Parallelism)\index{Model Parallelism}。模型并行是指将模型分割成不同的部分,在不同的GPU上运行其中的一部分。例如,在训练深层LSTM模型时可以将不同层放置在不同GPU上,这种方式一定程度上能够加速模型的训练。对于更大的模型,如参数量为10亿的BERT-Large模型\cite{DBLP:conf/naacl/DevlinCLT19},同样可以使用这种策略。不过,模型并行中不同设备传输的延时会大大降低模型运行的效率,因此很多时候要考虑训练效率和模型性能之间的平衡。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{大批量训练}
\parinterval 在第六章已经介绍了神经机器翻译模型需要使用梯度下降方法进行训练。其中,一项非常重要的技术就是{\small\bfnew{小批量训练}}\index{小批量训练}(Mini-batch Training)\index{Mini-batch Training},即每次使用多个样本来获取梯度并对模型参数进行更新。这里将每次参数更新使用的多个样本集合称为批次,将样本的数量称作批次的大小。在机器翻译中,通常用批次中的源语言/目标语言单词数或者句子数来表示批次大小。理论上,过小的批次会带来训练的不稳定,而且参数更新次数会大大增加。因此,很多研究者尝试增加批次大小来提高训练的稳定性。在Transformer模型中,使用更大的批次已经被验证是有效的。这种方法也被称作大批量训练。不过,这里所谓`` 大''批量是一个相对的概念。下面就一起看一看如何使用合适的批次大小来训练神经机器翻译模型。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{为什么需要大批量训练}
\parinterval 在模型训练的过程中,训练批次的大小对模型的收敛状态有很大影响,合理选择批次的大小往往会取得事半功倍的效果。较大的批次可以保证模型每次更新时梯度是在较多的样本上计算,其梯度结果更准确,有效地缓解训练中出现的性能震荡的问题。此外,较大的批次可以让模型在更新次数更少的情况下遍历整个数据集。同时大矩阵运算在GPU上的并行度更高,提高了设备的利用率。
\parinterval 然而,批次也不是越大越好,要根据训练数据集的规模与模型的容量做出合理的选择。此外,GPU显存的大小也对批次大小有约束,因为过大的批次可能无法放入GPU显存中。另一方面,在一些场景例中,如增量式训练、领域迁移,往往需要对模型进行微调。这时,常用的做法是使用小批次并固定较小的学习率,防止现有的模型参数发生较大的偏离。
\parinterval 大多数情况下,批次的大小是指单独一块GPU上的数据量,然而考虑到利用数据并行进行分布式训练时,批次大小等于所有GPU 中批次大小的和。下面以Transformer模型为例。通常Transformer-Base模型使用4096词/GPU的批次在8张GPU上进行训练,此时真实批次大小为$4096\times 8=32768$词。伴随着模型容量的进一步增加,例如Transformer-Big模型,由于训练过程中网络的中间表示要消耗大量的GPU显存,可能会考虑减小批次的大小并使用累计梯度的方式来保证稳定的训练。累计梯度是一种大批量训练的常用手段,即按照一定频率缓存多个相邻批次的梯度后再进行参数的更新。比如,为了获取大批次,可以考虑将累计的更新频率设置为2或4。图\ref{fig:13-17}给出了累计梯度的参数更新方法,可以看到使用累积梯度的方式可以减少设备的空闲时间。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-batch-generation-method}
\caption{生成批次的方式}
\label{fig:13-17}
\end{figure}
%----------------------------------------------
\parinterval 此外,前人工作表明,使用大批量训练复杂网络结构时要配合略大一些的学习率,加快模型在梯度方向上的更新速度,进而达到更优的翻译性能\cite{DBLP:conf/wmt/OttEGA18}。例如,深层网络也需要对学习率进行适当的调整才能发挥较好的性能。表\ref{tab:13-3}展示了30层网络在不同批次大小和学习率峰值的条件下的BLEU值(WMT14 En-De)\footnote{学习率峰值是指Transformer模型训练的预热阶段,学习率所到达的最高值。}。可以发现,在固定学习率峰值的条件下增大批次大小并不能带来性能上的增益,必须同时调整学习率的峰值。也有研究团队验证了Transformer-Big模型在128张GPU上进行分布式训练时,适当的增大学习率会带来明显的BLEU提升\cite{DBLP:conf/wmt/OttEGA18}\\ \\ \\
%----------------------------------------------
\begin{table}[htp]
\centering
\caption{深层Transformer不同批次大学和学习率峰值设置下的BLEU值}
\begin{tabular}{ l | l l }
\rule{0pt}{13pt} batch & lr & BLEU \\ \hline
\rule{0pt}{13pt} 4096 & 0.01 & 29.15 \\
\rule{0pt}{13pt} 8192 & 0.01 & 29.06 \\
\rule{0pt}{13pt} 8192 & 0.02 & 29.49
\end{tabular}
\label{tab:13-3}
\end{table}
%--------------------------------------
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{如何构建批次}
\parinterval 由于不同句子之间的长度有明显的差异,这时批次所占用的显存/内存大小由其中最长句子的长度决定。通常使用{\small\bfnew{填充}}(Padding)的方式对一个批次中句长不足的部分用空白填充(见第六章)。但由于生成批次的方式不同,最终批次内的Padding数量各不相同,因此合理选择生成批次的方式也是至关重要的。通常有几种方法:
\begin{itemize}
\vspace{0.5em}
\item 随机生成:最简单的方式是从整个数据集中随机生成批次。这种方式可以有效地保证样本间的随机性,但随机生成的批次中不同句子之间的长度会有较大区别,因此Padding数量较多会导致显卡的利用率较低。
\vspace{0.5em}
\item 按句长排序:为了减少显卡利用率低的问题,可以根据源语言或者目标语言的句子长度进行排序,让相邻句长的样本更为相近(图\ref{fig:13-18} )。这样在同一个批次中不会因为句长差异过大造成设备利用率的降低。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-randomly-generation-vs-generate-by-sentence-length}
\caption{批次生成 - 随机生成 vs 按句长生成}
\label{fig:13-18}
\end{figure}
%----------------------------------------------
\vspace{0.5em}
\item 按词数构建批次:对比按照句长生成批次,按词数生成批次可以防止某些批次中句子整体长度特别长或者特别短的情况,保证不同批次之间整体的词数处于大致相同的范围,这样所得到的梯度也是可比较的。通常的做法是根据源语言词数、目标语言词数,或者源语言词数与目标语言词数的最大值等指标生成批次。
\vspace{0.5em}
\item 按课程学习的方式:考虑样本的``难度''也是生成批次的一种策略。比如,可以使用{\small\bfnew{课程学习}}\index{课程学习}(Curriculum Learning)\index{Curriculum Learning} 的思想\cite{DBLP:conf/icml/BengioLCW09},让系统先学习``简单''的样本,之后逐渐增加样本的难度,达到循序渐进的学习。具体来说,可以利用句子长度、词频等指标计算每个批次的``难度'',记为$d$。 之后,选择满足$d \leq c$的样本构建一个批次。这里,$c$表示难度的阈值,它可以随着训练的执行不断增大。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{对抗样本训练}
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{最小风险训练}
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{增强学习方法}
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{曝光偏置问题}
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{知识精炼}\label{subsection-7.5.3}
\parinterval 理想的机器翻译系统应该是品质好、速度块、存储占用少。不过现实的机器翻译系统往往需要用运行速度和存储空间来换取翻译品质,比如,\ref{subsection-7.3.2}节提到的增大模型容量的方法就是通过增加模型参数量来达到更好的函数拟合效果,但是这也导致系统变得更加笨拙。在很多场景下,这样的模型甚至无法使用。比如,Transformer-Big等``大''模型通常在专用GPU服务器上运行,在手机等受限环境下仍很难应用。
\parinterval 另一方面,直接训练``小''模型的效果往往并不理想,其翻译品质与``大''模型相比仍有比较明显的差距。比如,在Transformer中,使用一个48层的编码器要比传统的6层编码器在BLEU上高出1-2个点,而且两者翻译结果的人工评价的区别也十分明显。
\parinterval 面对小模型难以训练的问题,一种有趣的想法是把``大''模型的知识传递给``小''模型,让``小''模型可以更好的进行学习。这类似于,教小孩子学习数学,是请一个权威数学家(数据中的标准答案),还是请一个小学数学教师(``大''模型)。这就是知识精炼的基本思想。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{什么是知识精炼}
\parinterval 通常,知识精炼可以被看作是一种知识迁移的手段\cite{Hinton2015Distilling}。如果把``大''模型的知识迁移到``小''模型,这种方法的直接结果就是{\small\bfnew{模型压缩}}\index{模型压缩}(Model Compression)\index{Model Compression}。当然,理论上也可以把``小''模型的知识迁移到``大''模型,比如,将迁移后得到的``大''模型作为初始状态,之后继续训练该模型,以期望取得加速收敛的效果。不过,在实践中更多是使用``大''模型到``小''模型的迁移,这也是本节讨论的重点。
\parinterval 知识精炼基于两个假设:
\begin{itemize}
\vspace{0.5em}
\item ``知识''在模型间是可迁移的。也就是说,一个模型中蕴含的规律可以被另一个模型使用。最典型的例子就是预训练模型(见\ref{subsection-7.2.6})。使用单语数据学习到的表示模型,在双语的翻译任务中仍然可以发挥很好的作用。也就是,把单语语言模型学习到的知识迁移到双语翻译中对句子表示的任务中;
\vspace{0.5em}
\item 模型所蕴含的``知识''比原始数据中的``知识''更容易被学习到。比如,机器翻译中大量使用的回译(伪数据)方法,就把模型的输出作为数据让系统进行学习。
\vspace{0.5em}
\end{itemize}
\parinterval 这里所说的第二个假设对应了机器学习中的一大类问题\ \dash \ {\small\bfnew{学习难度}}\index{学习难度}(Learning Difficulty)\index{Learning Difficulty}。所谓难度是指:在给定一个模型的情况下,需要花费多少代价对目标任务进行学习。如果目标任务很简单,同时模型与任务很匹配,那学习难度就会降低。如果目标任务很复杂,同时模型与其匹配程度很低,那学习难度就会很大。在自然语言处理任务中,这个问题的一种表现是:在很好的数据中学习的模型的翻译质量可能仍然很差。即使训练数据是完美的,但是模型仍然无法做到完美的学习。这可能是因为建模的不合理,导致模型无法描述目标任务中复杂的规律。也就是纵然数据很好,但是模型学不到其中的``知识''。在机器翻译中这个问题体现的尤为明显。比如,在机器翻译系统$n$-best结果中挑选最好的译文(成为Oracle)作为训练样本让系统重新学习,系统仍然达不到Oracle的水平。
\parinterval 知识精炼本身也体现了一种``自学习''的思想。即利用模型(自己)的预测来教模型(自己)。这样既保证了知识可以向更轻量的模型迁移,同时也避免了模型从原始数据中学习难度大的问题。虽然``大''模型的预测中也会有错误,但是这种预测是更符合建模的假设的,因此``小''模型反倒更容易从不完美的信息中学习\footnote[15]{很多时候,``大''模型和``小''模型都是基于同一种架构,因此二者对问题的假设和模型结构都是相似的。}到更多的知识。类似于,刚开始学习围棋的人从职业九段身上可能什么也学不到,但是向一个业余初段的选手学习可能更容易入门。另外,也有研究表明:在机器翻译中,相比于``小''模型,``大''模型更容易进行优化,也更容易找到更好的模型收敛状态。因此在需要一个性能优越,存储较小的模型时,也会考虑将大模型压缩得到更轻量模型的手段\cite{DBLP:journals/corr/abs-2002-11794}
\parinterval 通常把``大''模型看作的传授知识的``教师'',被称作{\small\bfnew{教师模型}}\index{教师模型}(Teacher Model)\index{Teacher Model};把``小''模型看作是接收知识的``学生'',被称作{\small\bfnew{学生模型}}\index{学生模型}(Student Model)\index{Student Model}。比如,可以把Transformer-Big看作是教师模型,把Transformer-Base看作是学生模型。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{知识精炼的基本方法}
\parinterval 知识精炼的基本思路是让学生模型所表示的函数尽可能去拟合教师模型所表示的函数\cite{Hinton2015Distilling}。通常有两种实现方式\cite{DBLP:conf/emnlp/KimR16}
\begin{itemize}
\vspace{0.5em}
\item {\small\bfnew{基于单词的知识精炼}}\index{基于单词的知识精炼}(Word-level Knowledge Distillation)\index{Word-level Knowledge Distillation}。该方法的目标是使得学生模型的预测(分布)尽可能逼近教师模型的预测(分布)。令$\mathbf{x}=\{x_1,\ldots,x_m\}$$\mathbf{y}=\{y_1,\ldots,y_n\}$分别表示输入和输出(数据中的答案)序列,$V$表示目标语言词表,$n$表示译文序列的长度,则基于单词的知识精炼的损失函数被定义为:
\begin{eqnarray}
L_{\textrm{word}} = - \sum_{j=1}^n \sum_{y_j \in V} \textrm{P}_{\textrm{t}} (y_{\textrm{j}}|\mathbf{x})\textrm{logP}_{\textrm{s}}(y_j|\mathbf{x})
\label{eq:13-28}
\end{eqnarray}
这里, $\textrm{P}_{\textrm{s}}(y_j|\mathbf{x})$$\textrm{P}_{\textrm{t}} (y_i|\mathbf{x})$分别表示学生模型和教师模型在$j$位置的输出的概率。公式\ref{eq:13-28}实际上在最小化教师模型和学生模型输出分布之间的交叉熵。
\vspace{0.5em}
\item {\small\bfnew{基于序列的知识精炼}}\index{基于序列的知识精炼}(Sequence-level Knowledge Distillation)\index{Sequence-level Knowledge Distillation}。除了单词一级的拟合,基于序列的知识精炼希望在序列整体上进行拟合。其损失函数被定义为:
\begin{eqnarray}
L_{\textrm{seq}} = - \sum_{\textrm{y}}\textrm{P}_{\textrm{t}} (\mathbf{y}|\mathbf{x})\textrm{logP}_{\textrm{s}}(\mathbf{y}|\mathbf{x})
\label{eq:13-29}
\end{eqnarray}
公式\ref{eq:13-29}要求遍历所有可能的译文序列,并进行求和,当词表大小为$V$,序列长度为$L$时,则可能的序列的数量有$V$$L$次幂,这么多的译文将消耗大量的计算资源。因此,会考虑用教师模型的真实输出序列$\hat{\mathbf{y}}$来代替整个空间,即假设$\textrm{P}_{\textrm{t}}(\hat{\mathbf{y}}|\mathbf{x})=1$。于是,目标函数变为:
\begin{eqnarray}
L_{\textrm{seq}} = - \textrm{logP}_{\textrm{s}}(\hat{\mathbf{y}} | \mathbf{x})
\label{eq:13-30}
\end{eqnarray}
这样的损失函数带来最直接的好处是,知识精炼的流程会非常简单。因为只需要利用教师模型将训练数据(源语言)翻译一遍,之后把它的输出替换为训练数据的目标语言部分。之后,利用得到的新的双语数据训练学生模型即可,图\ref{fig:13-41}展示了简化后词级和序列级的不同,其中词级知识精炼的解码端输入为真实双语数据的目标语言,并以teacher模型输出的概率分布作为学习目标,而序列级则直接将teacher推断后得到的结果作为解码端的输入,并将解码结果的One-hot向量作为学习目标。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-difference-between-word-level-and-sequence-level-in-knowledge-distillation}
\caption{词级和序列级知识精炼的差异}
\label{fig:13-41}
\end{figure}
%-------------------------------------------
\parinterval 本质上,基于单词的知识精炼和传统的语言模型等问题的建模方式是一致的。在传统方法中,训练数据中的答案会被看作是一个One-hot分布,之后让模型去尽可能拟合这种分布。而这里,答案不再是一个One-hot分布,而是由教师模型生成的真实分布,但是损失函数的形式是一模一样的。在具体实现时,一个容易出现的问题是在词级别的知识精炼中,teacher模型的Softmax可能会生成非常尖锐的分布。这时需要考虑对分布进行平滑,提高模型的泛化能力\footnote[16]{比如,可以在Softmax函数中加入一个参数$\alpha$,如$\textrm{Softmax}(s_i)=\frac{exp(s_i/\alpha)}{\sum_j exp(s_i/\alpha)}$。这样可以通过$\alpha$控制分布的平滑程度。
}
\parinterval 除了在模型最后输出的分布上进行知识精炼,同样可以使用教师模型对学生模型的{\small\bfnew{中间层输出}}\index{中间层输出}(Hint-based Knowledge Transfer)\index{Hint-based Knowledge Transfer}{\small\bfnew{注意力分布}}\index{注意力分布}(Attention To Attention Transfer)\index{Attention To Attention Transfer}进行约束。而对翻译常用的Transformer架构,也有研究者使用更精细的精炼方式对模型各个位置的知识重新设计了知识迁移的方法\cite{DBLP:journals/corr/abs-1909-10351}
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{机器翻译中的知识精炼}
\parinterval 在神经机器翻译中,通常使用公式\ref{eq:13-30}的方法进行知识精炼,即通过教师模型构造伪数据,之后让学生模型从伪数据中学习。这样做的好处在于,系统研发人员不需要对系统进行任何修改,整个过程只需要调用教师模型和学生模型标准的训练和推断模块即可。
\parinterval 另一个问题是如何构造教师模型和学生模型。以Transformer为例,通常有两种思路:
\begin{itemize}
\vspace{0.5em}
\item 固定教师模型,通过减少模型容量的方式设计学生模型。比如,可以使用容量较大的模型作为教师模型(如:Transformer-Big或Transformer-Deep),然后通过将神经网络变``窄''、变``浅''的方式得到学生模型。我们可以用Transformer-Big做教师模型,然后把Transformer-Big的解码器变为一层网络,作为学生模型。
\vspace{0.5em}
\item 固定学生模型,通过模型集成的方式设计教师模型。可以组合多个模型生成更高质量的译文(见\ref{subsection-7.4.3}节)。比如,融合多个Transformer-Big模型(不同参数初始化方式),之后学习一个Transformer-Base模型。
\vspace{0.5em}
\end{itemize}
\parinterval 此外还可以采用迭代的知识精炼的方式。首先,通过模型集成得到较强的教师模型,再将知识迁移到不同的学生模型上,随后继续使用这些学生模型集成新的教师模型。不断的重复上述过程可以逐步提升集成模型的性能,如图\ref{fig:13-42}所示。值得注意的是,随着迭代次数的增加,集成所带来的收益也会随着子模型之间差异性的减小而减少。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter13/Figures/figure-ensemble-knowledge-distillation}
\caption{迭代式知识精炼}
\label{fig:13-42}
\end{figure}
%-------------------------------------------
\parinterval 如果倾向于使用更少的存储,更快的推理速度,则可以使用更小的学生模型。值得注意的是,对于Transformer模型来说,减少解码端的层数会给推理速度带来巨大的提升。特别是对于基于深层编码器的Transformer-Deep,适当减少解码端层数往往不会带来翻译品质的下降。可以根据不同任务的需求,选择适当大小的学生模型,来平衡存储、推断速度和模型品质之间的关系。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{可解释性}
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{小结及深入阅读}
% !Mode:: "TeX:UTF-8"
% !TEX encoding = UTF-8 Unicode
%----------------------------------------------------------------------------------------
% 机器翻译:统计建模与深度学习方法
% Machine Translation: Statistical Modeling and Deep Learning Methods
%
% Copyright 2020
% 肖桐(xiaotong@mail.neu.edu.cn) 朱靖波 (zhujingbo@mail.neu.edu.cn)
%----------------------------------------------------------------------------------------
%----------------------------------------------------------------------------------------
% CONFIGURATIONS
%----------------------------------------------------------------------------------------
\renewcommand\figurename{}%将figure改为图
\renewcommand\tablename{}%将figure改为图
\chapterimage{fig-NEU-8.jpg} % Chapter heading image
%----------------------------------------------------------------------------------------
% CHAPTER 17
%----------------------------------------------------------------------------------------
\chapter{神经机器翻译实践}
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{}
\begin{tikzpicture}
\tikzstyle{unit} = [inner sep=1pt,align=center,minimum width=3.5em,minimum height=2em,font=\large]
\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};
\node[fill=blue!40,anchor=north,align=left,inner sep=2pt,minimum width=5em](spe)at(words.south){\color{white}{\small\bfnew{特殊符号}}};
\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){};
\node[anchor=north,unit] (w1) at ([xshift=0em,yshift=-1.8em]eos.south){$w_1$};
\node[anchor=north,unit,fill=blue!10] (n11) at ([yshift=-0.5em]w1.south){$<$sos$>$};
\node[anchor=west,unit,fill=red!20,opacity=0.3] (n24) at ([xshift=6.5em,yshift=4.3em]n11.east){an};
\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}}}};
\node[anchor=south,unit,fill=red!20] (n23) at ([yshift=0.1em]n24.north){one};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt23) at (n23.east) {\small{{\color{white} \textbf{-0.6}}}};
\node[anchor=south,unit,fill=red!20] (n22) at ([yshift=0.1em]n23.north){Here};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt22) at (n22.east) {\small{{\color{white} \textbf{-0.3}}}};
\node[anchor=south,unit,fill=red!20] (n21) at ([yshift=0.1em]n22.north){There};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt21) at (n21.east) {\small{{\color{white} \textbf{-0.2}}}};
\node[anchor=north,unit,fill=red!20,opacity=0.3] (n25) at ([yshift=-0.1em]n24.south){is};
\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}}}};
\node[anchor=north,unit,fill=red!20,opacity=0.3] (n26) at ([yshift=-0.1em]n25.south){apple};
\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}}}};
\node[anchor=north,unit,fill=blue!10,opacity=0.3] (n27) at ([yshift=-0.1em]n26.south){$<$eos$>$};
\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}}}};
\node[anchor=south,unit] (w2) at ([yshift=0.5em]n21.north){$w_2$};
\node[anchor=west,unit,fill=red!20] (n31) at ([yshift=4.7em,xshift=8em]n21.east){is};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt31) at (n31.east) {\small{{\color{white} \textbf{-0.1}}}};
\node[anchor=north,unit,fill=blue!10] (n32) at ([yshift=-0.1em]n31.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt32) at (n32.east) {\small{{\color{white} \textbf{-0.6}}}};
\node[anchor=north,unit,fill=red!20,opacity=0.3] (n33) at ([yshift=-0.1em]n32.south){an};
\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}}}};
\node[anchor=north,unit,fill=red!20,opacity=0.3] (n34) at ([yshift=-0.1em]n33.south){one};
\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}}}};
\node[anchor=north,unit,fill=red!20,opacity=0.3] (n35) at ([yshift=-0.1em]n34.south){Here};
\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}}}};
\node[anchor=north,unit,fill=red!20,opacity=0.3] (n36) at ([yshift=-0.1em]n35.south){apple};
\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}}}};
\node[anchor=north,unit,fill=red!20,opacity=0.3] (n37) at ([yshift=-0.1em]n36.south){There};
\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}}}};
\node[anchor=north,unit,fill=red!20] (n41) at ([yshift=-0.1em]n37.south){is};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt41) at (n41.east) {\small{{\color{white} \textbf{-0.1}}}};
\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){};
\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}}}};
\node[anchor=south,unit] (w3) at ([yshift=0.5em]n31.north){$w_3$};
\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);
\node[inner sep=0pt] at ([yshift=-2em,xshift=2em]pt25.east){剪枝};
\draw[decorate,decoration={brace},red,very thick] (pt33.south east) -- (pt37.south west);
\node[inner sep=0pt] at ([xshift=2em,yshift=-1em]pt35.east){剪枝};
\node[inner sep=0pt] at ([yshift=-1.5em,xshift=2em]pt51.east){剪枝};
\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}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [inner sep=1pt,align=center,minimum width=3.5em,minimum height=2em,font=\large]
\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){I\\[-0.5ex]agree};
\node[fill=blue!40,anchor=north,align=left,inner sep=2pt,minimum width=5em](spe)at(words.south){\color{white}{\small\bfnew{特殊符号}}};
\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,unit] (w1) at ([xshift=2.5em,yshift=-1em]eos.south){$w_1$};
\node[anchor=north,unit,fill=red!10] (n11) at ([yshift=-0.5em]w1.south){$<$sos$>$};
\node [anchor=north west] (wtranslabel) at ([xshift=-5em,yshift=-3em]n11.south) {\small{生成顺序:}};
\draw [->,ultra thick,red,line width=1.5pt,opacity=0.7] (wtranslabel.east) -- ([xshift=1.5em]wtranslabel.east);
\node[anchor=west,unit,fill=red!20] (n22) at ([xshift=3em]n11.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt22) at (n22.east) {\small{{\color{white} \textbf{-0.4}}}};
\node[anchor=south,unit,fill=red!20] (n21) at ([yshift=5.5em]n22.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt21) at (n21.east) {\small{{\color{white} \textbf{-0.5}}}};
\node[anchor=north,unit,fill=blue!10] (n23) at ([yshift=-3em]n22.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt23) at (n23.east) {\small{{\color{white} \textbf{-2.2}}}};
\node[anchor=south,unit] (w2) at ([yshift=0.5em]n21.north){$w_2$};
\node[anchor=west,unit,fill=red!20] (n32) at ([xshift=4em]n21.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt32) at (n32.east) {\small{{\color{white} \textbf{-0.2}}}};
\node[anchor=south,unit,fill=red!20] (n31) at ([yshift=0.3em]n32.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt31) at (n31.east) {\small{{\color{white} \textbf{-1.8}}}};
\node[anchor=north,unit,fill=blue!10] (n33) at ([yshift=-0.3em]n32.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt33) at (n33.east) {\small{{\color{white} \textbf{-1.3}}}};
\node[anchor=west,unit,fill=red!20] (n35) at ([xshift=4em]n22.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt35) at (n35.east) {\small{{\color{white} \textbf{-1.5}}}};
\node[anchor=south,unit,fill=red!20] (n34) at ([yshift=0.3em]n35.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt34) at (n34.east) {\small{{\color{white} \textbf{-2.0}}}};
\node[anchor=north,unit,fill=blue!10] (n36) at ([yshift=-0.3em]n35.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt36) at (n36.east) {\small{{\color{white} \textbf{-1.3}}}};
\node[anchor=south,unit] (w3) at ([yshift=0.5em]n31.north){$w_3$};
\node[anchor=west,unit,fill=blue!10] (n41) at ([xshift=4em]n31.east){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt41) at (n41.east) {\small{{\color{white} \textbf{-0.9}}}};
\node[anchor=west,unit,fill=blue!10] (n42) at ([xshift=4em]n32.east){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt42) at (n42.east) {\small{{\color{white} \textbf{-0.8}}}};
\node[anchor=west,unit,fill=blue!10] (n43) at ([xshift=4em]n34.east){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt43) at (n43.east) {\small{{\color{white} \textbf{-1.4}}}};
\node[anchor=west,unit,fill=blue!10] (n44) at ([xshift=4em]n35.east){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt44) at (n44.east) {\small{{\color{white} \textbf{-0.1}}}};
\node[anchor=south,unit] (w4) at ([yshift=0.5em]n41.north){$w_4$};
\draw[->,ublue,very thick,dotted] (n11.east) -- (n21.west);
% \draw[->,ublue,very thick] (n11.east) -- (n22.west);
\draw[->,ublue,very thick,dotted] (n11.east) -- (n23.west);
\draw[->,ublue,very thick,dotted] (pt21.south) -- (n31.west);
\draw[->,ublue,very thick,dotted] (pt21.south) -- (n32.west);
\draw[->,ublue,very thick,dotted] (pt21.south) -- (n33.west);
\draw[->,ublue,very thick,dotted] (pt22.south) -- (n34.west);
\draw[->,ublue,very thick,dotted] (pt22.south) -- (n35.west);
% \draw[->,ublue,very thick] (pt22.south) -- (n36.west);
\draw[->,ublue,very thick,dotted] (pt31.south) -- (n41.west);
\draw[->,ublue,very thick,dotted] (pt32.south) -- (n42.west);
\draw[->,ublue,very thick,dotted] (pt34.south) -- (n43.west);
\draw[->,ublue,very thick,dotted] (pt35.south) -- (n44.west);
% \draw[->,red,ultra thick,opacity=0.7,line width=2pt]([xshift=-1em]n11.west) -- (n11.east) -- (n22.west) -- (pt22.south) -- (n36.west) -- ([xshift=1em]pt36.south);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt]([xshift=-1em]n11.west) -- (n11.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](n11.east) -- (n22.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](pt22.south) -- (n36.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](pt36.south) -- ([xshift=1em]pt36.south);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [inner sep=1pt,align=center,minimum width=3.5em,minimum height=2em,font=\large]
\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){I\\[-0.5ex]agree};
\node[fill=blue!40,anchor=north,align=left,inner sep=2pt,minimum width=5em](spe)at(words.south){\color{white}{\small\bfnew{特殊符号}}};
\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,unit] (w1) at ([xshift=2.5em,yshift=-1em]eos.south){$w_1$};
\node[anchor=north,unit,fill=blue!10] (n11) at ([yshift=-0.5em]w1.south){$<$sos$>$};
\node [anchor=north] (wtranslabel) at ([xshift=-2.5em,yshift=-3em]n11.south) {\small{生成顺序:}};
\draw [->,ultra thick,red,line width=1.5pt,opacity=0.7] (wtranslabel.east) -- ([xshift=1.5em]wtranslabel.east);
\node[anchor=west,unit,fill=red!20] (n22) at ([xshift=5em]n11.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt22) at (n22.east) {\small{{\color{white} \textbf{-0.4}}}};
\node[anchor=south,unit,fill=red!20] (n21) at ([yshift=5.5em]n22.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt21) at (n21.east) {\small{{\color{white} \textbf{-0.5}}}};
\node[anchor=north,unit,fill=blue!10] (n23) at ([yshift=-3em]n22.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt23) at (n23.east) {\small{{\color{white} \textbf{-2.2}}}};
\node[anchor=south,unit] (w2) at ([yshift=0.5em]n21.north){$w_2$};
\node[anchor=west,unit,fill=red!20] (n35) at ([xshift=6em]n22.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt35) at (n35.east) {\small{{\color{white} \textbf{-1.5}}}};
\node[anchor=south,unit,fill=red!20] (n34) at ([yshift=0.3em]n35.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt34) at (n34.east) {\small{{\color{white} \textbf{-2.0}}}};
\node[anchor=north,unit,fill=blue!10] (n36) at ([yshift=-0.3em]n35.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt36) at (n36.east) {\small{{\color{white} \textbf{-1.3}}}};
\node[anchor=south,unit] (w3) at ([yshift=0.5em]n34.north){$w_3$};
\draw[->,ublue,very thick,dotted] (n11.east) -- (n21.west);
% \draw[->,ublue,very thick,dashed] (n11.east) -- (n22.west);
\draw[->,ublue,very thick,dotted] (n11.east) -- (n23.west);
\draw[->,ublue,very thick,dotted] (pt22.south) -- (n34.west);
\draw[->,ublue,very thick,dotted] (pt22.south) -- (n35.west);
% \draw[->,ublue,very thick,dashed] (pt22.south) -- (n36.west);
% \draw[->,red,ultra thick,opacity=0.7,line width=2pt]([xshift=-1em]n11.west) -- (n11.east) -- (n22.west) -- (pt22.south) -- (n36.west) -- ([xshift=1em]pt36.south);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt]([xshift=-1em]n11.west) -- (n11.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](n11.east) -- (n22.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](pt22.south) -- (n36.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](pt36.south) -- ([xshift=1em]pt36.south);
%\begin{pgfonlayer}{background}
% \node [rectangle,inner sep=0.2em,rounded corners=3pt,very thick,dashed,fill=red!40] [fit = (n11)] (box1) {};
% \node [rectangle,inner sep=0.2em,rounded corners=3pt,dotted,fill=red!40] [fit = (n22) (pt22)] (box2) {};
% \node [rectangle,inner sep=0.2em,rounded corners=3pt,very thick,dotted,fill=red!40] [fit = (n36) (pt36)] (box3) {};
%\end{pgfonlayer}
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [inner sep=1pt,align=center,minimum width=3.5em,minimum height=2em,font=\large]
\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){I\\[-0.5ex]agree};
\node[fill=blue!40,anchor=north,align=left,inner sep=2pt,minimum width=5em](spe)at(words.south){\color{white}{\small\bfnew{特殊符号}}};
\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,unit] (w1) at ([yshift=-1.5em]eos.south){$w_1$};
\node[anchor=north,unit,fill=blue!10] (n11) at ([yshift=-0.5em]w1.south){$<$sos$>$};
\node[anchor=west,unit,fill=red!20] (n22) at ([xshift=2.5em]n11.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt22) at (n22.east) {\small{{\color{white} \textbf{-0.4}}}};
\node[anchor=south,unit,fill=red!20] (n21) at ([yshift=5.5em]n22.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt21) at (n21.east) {\small{{\color{white} \textbf{-0.5}}}};
\node[anchor=north,unit,fill=blue!10] (n23) at ([yshift=-3em]n22.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt23) at (n23.east) {\small{{\color{white} \textbf{-2.2}}}};
\node[anchor=south,unit] (w2) at ([yshift=0.5em]n21.north){$w_2$};
\node[anchor=west,unit,fill=ugreen!20,minimum width=4.3em] (n32) at ([xshift=3em]n21.east){agree};
\node[anchor=south,unit,fill=ugreen!20,minimum width=4.3em] (n31) at ([yshift=0.3em]n32.north){I};
\node[anchor=north,unit,fill=ugreen!20,minimum width=4.3em] (n33) at ([yshift=-0.3em]n32.south){$<$eos$>$};
\node[anchor=west,unit,fill=red!20] (n35) at ([xshift=3em]n22.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt35) at (n35.east) {\small{{\color{white} \textbf{-1.5}}}};
\node[anchor=south,unit,fill=red!20] (n34) at ([yshift=0.3em]n35.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt34) at (n34.east) {\small{{\color{white} \textbf{-2.0}}}};
\node[anchor=north,unit,fill=blue!10] (n36) at ([yshift=-0.3em]n35.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt36) at (n36.east) {\small{{\color{white} \textbf{-1.3}}}};
\node[anchor=south,unit] (w3) at ([yshift=0.5em]n31.north){$w_3$};
\node[anchor=west,unit] (s1) at ([xshift=1em]n32.east){score($<$sos$>$\ I)\ =\ {\red {-0.5}}};
\node[anchor=north west,unit] (s2) at ([yshift=-3em]s1.south west){score($<$sos$>$\ agree\ I)\ =\ -2.4};
\node[anchor=north west,unit] (s3) at ([yshift=-0.3em]s2.south west){score($<$sos$>$\ agree\ agree)\ =\ -1.9};
\node[anchor=north west,unit] (s4) at ([yshift=-0.3em]s3.south west){score($<$sos$>$\ agree\ $<$eos$>$)\ =\ -1.7};
\node[anchor=north west,unit] (s5) at ([yshift=-1em]s4.south west){score($<$sos$>$\ $<$eos$>$)\ =\ -2.2};
\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,very thick,dashed] (pt21.south) -- (n31.west);
\draw[->,ublue,very thick,dashed] (pt21.south) -- (n32.west);
\draw[->,ublue,very thick,dashed] (pt21.south) -- (n33.west);
\draw[->,ublue,very thick] (pt22.south) -- (n34.west);
\draw[->,ublue,very thick] (pt22.south) -- (n35.west);
\draw[->,ublue,very thick] (pt22.south) -- (n36.west);
\end{tikzpicture}
\ No newline at end of file
......@@ -11,16 +11,16 @@
\begin{tikzpicture}
\node [anchor=west] (label1) at (0,0) {总词数:$6 + 8 + 5 = 20$};
\node [anchor=north west] (p1) at (label1.south west) {$\textrm{P}(\textrm{“很”})=1/20=0.05$};
\node [anchor=north west] (p2) at (p1.south west) {$\textrm{P}(\textrm{“。”})=3/20=0.15$};
\node [anchor=north west] (p3) at (p2.south west) {$\textrm{P}(\textrm{“确实”})=1/20=0.05$};
\node [anchor=north west] (p1) at (label1.south west) {$\funp{P}(\textrm{})=1/20=0.05$};
\node [anchor=north west] (p2) at (p1.south west) {$\funp{P}(\textrm{})=3/20=0.15$};
\node [anchor=north west] (p3) at (p2.south west) {$\funp{P}(\textrm{确实})=1/20=0.05$};
\node [anchor=north west] (label11) at ([xshift=18.0em,yshift=1.63em]label1.south west) {更多数据-总词数:100K $\sim$ 1M};
\node [anchor=north west] (p12) at (label11.south west) {$\textrm{P}(\textrm{“很”})=0.000010$};
\node [anchor=north west] (p22) at (p12.south west) {$\textrm{P}(\textrm{“。”})=0.001812$};
\node [anchor=north west] (p32) at (p22.south west) {$\textrm{P}(\textrm{“确实”})=0.000001$};
\node [anchor=north west] (p12) at (label11.south west) {$\funp{P}(\textrm{})=0.000010$};
\node [anchor=north west] (p22) at (p12.south west) {$\funp{P}(\textrm{})=0.001812$};
\node [anchor=north west] (p32) at (p22.south west) {$\funp{P}(\textrm{确实})=0.000001$};
......
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\begin{tikzpicture}%画图中的属性如xshift应该是通用的,前面的关键字如xlabel规定了修改的部分
\begin{tikzpicture}
\begin{axis}[
width=10cm, height=4.5cm,
symbolic x coords={未抽取词,do,want,what,am,people,look},%自定义x坐标
xtick=data,%自定义x坐标
symbolic x coords={未抽取词,do,want,what,am,people,look},
xtick=data,
ytick={0,0.05,0.1,0.15,0.2,0.25},
xlabel={低概率词汇},
ylabel={词汇概率},
legend pos=outer north east,%图标位置
legend pos=outer north east,
xlabel style={align=right,xshift=5.3cm,yshift=0.8cm,font=\footnotesize},
ylabel style={rotate=-90,yshift=2cm,xshift=1cm,font=\footnotesize},
y tick style={opacity=0},%隐藏y轴刻度线
x tick style={opacity=0},%隐藏x轴刻度线
y tick style={opacity=0},
x tick style={opacity=0},
x tick label style={anchor=base,font=\footnotesize,yshift=-0.5cm},
y tick label style={font=\footnotesize,/pgf/number format/.cd,fixed,precision=2},%y轴精度,不用科学表示
y axis line style={opacity=0},%隐藏y轴
tick align=inside,%原本的横行线
ymajorgrids,%显示横行网格线
axis x line*=bottom,%显示x轴坐标汉字(应该是对齐)
major grid style={dotted,draw=ublue},%横行线颜色
axis on top,%网格线位于顶层
legend style={anchor=north west,font=\footnotesize},%图标格式
y tick label style={font=\footnotesize,/pgf/number format/.cd,fixed,precision=2},
y axis line style={opacity=0},
tick align=inside,
ymajorgrids,
axis x line*=bottom,
major grid style={dotted,draw=ublue},
axis on top,
legend style={anchor=north west,font=\footnotesize},
ymin=0,
ymax=0.25]
\addplot [ybar,bar shift=-2mm,bar width=4mm,fill=blue!40,draw=blue!40,area legend] coordinates{(未抽取词,0) (do,0.05) (want,0.05) (what,0.05) (am,0.1) (people,0.15) (look,0.2)};%area legend图例显示长方形颜色
\addplot [ybar,bar shift=-2mm,bar width=4mm,fill=blue!40,draw=blue!40,area legend] coordinates{(未抽取词,0) (do,0.05) (want,0.05) (what,0.05) (am,0.1) (people,0.15) (look,0.2)};
\addplot [ybar,bar shift=2mm,bar width=4mm,fill=red!40,draw=red!40,area legend] coordinates{(未抽取词,0.03) (do,0.062) (want,0.062) (what,0.062) (am,0.09) (people,0.122) (look,0.138)};
\legend{未平滑,平滑后}%右上图例
\legend{未平滑,平滑后}
\end{axis}
\end{tikzpicture}
......
\begin{tikzpicture}
\tikzstyle{unit} = [inner sep=1pt,align=center,minimum width=3.5em,minimum height=2em,font=\large]
\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){I\\[-0.5ex]agree};
\node[fill=blue!40,anchor=north,align=left,inner sep=2pt,minimum width=5em](spe)at(words.south){\color{white}{\small\bfnew{特殊符号}}};
\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,unit] (w1) at ([xshift=2.5em,yshift=-1em]eos.south){$w_1$};
\node[anchor=north,unit,fill=blue!10] (n11) at ([yshift=-0.5em]w1.south){$<$sos$>$};
\node [anchor=north west,unit] (wtranslabel) at ([xshift=-5em,yshift=-3em]n11.south) {\small{生成顺序:}};
\draw [->,ultra thick,red,line width=1.5pt,opacity=0.7] (wtranslabel.east) -- ([xshift=1.5em]wtranslabel.east);
\node[anchor=west,unit,fill=red!20] (n22) at ([xshift=3em]n11.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt22) at (n22.east) {\small{{\color{white} \textbf{-0.4}}}};
\node[anchor=south,unit,fill=red!20] (n21) at ([yshift=5.5em]n22.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt21) at (n21.east) {\small{{\color{white} \textbf{-0.5}}}};
\node[anchor=north,unit,fill=blue!10] (n23) at ([yshift=-3em]n22.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt23) at (n23.east) {\small{{\color{white} \textbf{-2.2}}}};
\node[anchor=south,unit] (w2) at ([yshift=0.5em]n21.north){$w_2$};
\node[anchor=west,unit,fill=red!20] (n32) at ([xshift=4em]n21.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt32) at (n32.east) {\small{{\color{white} \textbf{-0.2}}}};
\node[anchor=south,unit,fill=red!20] (n31) at ([yshift=0.3em]n32.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt31) at (n31.east) {\small{{\color{white} \textbf{-1.8}}}};
\node[anchor=north,unit,fill=blue!10] (n33) at ([yshift=-0.3em]n32.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt33) at (n33.east) {\small{{\color{white} \textbf{-1.3}}}};
\node[anchor=west,unit,fill=red!20] (n35) at ([xshift=4em]n22.east){agree};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt35) at (n35.east) {\small{{\color{white} \textbf{-1.5}}}};
\node[anchor=south,unit,fill=red!20] (n34) at ([yshift=0.3em]n35.north){I};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt34) at (n34.east) {\small{{\color{white} \textbf{-2.0}}}};
\node[anchor=north,unit,fill=blue!10] (n36) at ([yshift=-0.3em]n35.south){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt36) at (n36.east) {\small{{\color{white} \textbf{-1.3}}}};
\node[anchor=south,unit] (w3) at ([yshift=0.5em]n31.north){$w_3$};
\node[anchor=west,unit,fill=blue!10] (n41) at ([xshift=4em]n31.east){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt41) at (n41.east) {\small{{\color{white} \textbf{-0.9}}}};
\node[anchor=west,unit,fill=blue!10] (n42) at ([xshift=4em]n32.east){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt42) at (n42.east) {\small{{\color{white} \textbf{-0.8}}}};
\node[anchor=west,unit,fill=blue!10] (n43) at ([xshift=4em]n34.east){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt43) at (n43.east) {\small{{\color{white} \textbf{-1.4}}}};
\node[anchor=west,unit,fill=blue!10] (n44) at ([xshift=4em]n35.east){$<$eos$>$};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt44) at (n44.east) {\small{{\color{white} \textbf{-0.1}}}};
\node[anchor=south,unit] (w4) at ([yshift=0.5em]n41.north){$w_4$};
% \draw[->,ublue,very thick] (n11.east) -- (n21.west);
\draw[->,ublue,very thick,dotted] (n11.east) -- (n22.west);
\draw[->,ublue,very thick,dotted] (n11.east) -- (n23.west);
\draw[->,ublue,very thick,dotted] (pt21.south) -- (n31.west);
% \draw[->,ublue,very thick] (pt21.south) -- (n32.west);
\draw[->,ublue,very thick,dotted] (pt21.south) -- (n33.west);
\draw[->,ublue,very thick,dotted] (pt22.south) -- (n34.west);
\draw[->,ublue,very thick,dotted] (pt22.south) -- (n35.west);
\draw[->,ublue,very thick,dotted] (pt22.south) -- (n36.west);
\draw[->,ublue,very thick,dotted] (pt31.south) -- (n41.west);
% \draw[->,ublue,very thick] (pt32.south) -- (n42.west);
\draw[->,ublue,very thick,dotted] (pt34.south) -- (n43.west);
\draw[->,ublue,very thick,dotted] (pt35.south) -- (n44.west);
% \draw[->,red,ultra thick,opacity=0.7,line width=2pt]([xshift=-1em]n11.west) -- (n11.west) -- ([xshift=0.5em,yshift=-0.5em]n11.west) -- ([xshift=-0.5em,yshift=-0.5em]n11.east) -- (n11.east) -- (n21.west) -- ([xshift=0.5em,yshift=-0.5em]n21.west) -- ([xshift=-0.5em,yshift=-0.5em]n21.east) -- (n21.east) -- (n32.west) -- ([xshift=0.5em,yshift=-0.5em]n32.west) -- ([xshift=0.5em,yshift=-0.5em]n32.east) -- (n32.east) -- (n42.west) -- ([xshift=0.5em,yshift=-0.5em]n42.west) -- ([xshift=-0.5em,yshift=-0.5em]n42.east) -- (n42.east) -- ([xshift=1em]pt42.south);
% \draw[->,red,ultra thick,opacity=0.7,line width=2pt]([xshift=-1em,yshift=-0.5em]n11.west) -- ([yshift=-0.5em]n11.east) -- (n11.east) -- ([xshift=-0.3em,yshift=-0.5em]n21.west) -- ([xshift=0.5em,yshift=-0.5em]n21.west) -- ([xshift=-0.5em,yshift=-0.5em]n21.east) -- (n21.east) -- (n32.west) -- ([xshift=0.5em,yshift=-0.5em]n32.west) -- ([xshift=-0.5em,yshift=-0.5em]n32.east) -- (n32.east) -- (n42.west) -- ([xshift=0.5em,yshift=-0.5em]n42.west) -- ([xshift=-0.5em,yshift=-0.5em]n42.east) -- (n42.east) -- ([xshift=1em]pt42.south);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt]([xshift=-1em]n11.west) -- (n11.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](n11.east) -- (n21.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](pt21.south) -- (n32.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](pt32.south) -- (n42.west);
\draw[->,red,ultra thick,opacity=0.7,line width=2pt](pt42.south) -- ([xshift=1em]pt42.south);
\end{tikzpicture}
\ No newline at end of file
......@@ -3,8 +3,8 @@
\begin{axis}[
width=12cm,
height=4cm,
xlabel={{$\textrm{P}(x)$}},
ylabel={{$\textrm{I}(x)$}},
xlabel={{$\funp{P}(x)$}},
ylabel={{$\funp{I}(x)$}},
ylabel style={yshift=-1.5em,font=\footnotesize},
xlabel style={yshift=0.3em,font=\footnotesize},
xtick={0,0.2,...,1.0},
......@@ -23,7 +23,7 @@ xticklabel style={font=\small}, %坐标轴字体大小
yticklabel style={font=\small}
]
\addplot[draw=ublue,samples=100,thick] {-log2(x)};
\legend{\footnotesize{$\textrm{I}(x) = -\log \textrm{P}(x)$}}
\legend{\footnotesize{$\funp{I}(x) = -\log \funp{P}(x)$}}
\end{axis}
\end{tikzpicture}
......
\begin{tikzpicture}
\tikzstyle{unit} = [inner sep=1pt,align=center,minimum width=3.5em,minimum height=2em]
\tikzstyle{word} = [inner sep=1pt,align=center,minimum width=3.5em,minimum height=2em]
%,text=red,orange!20
\node[anchor=west,unit] (w1) at (0,0){{$w_1$}};
\node[anchor=north,unit,fill=orange!20] (n11) at ([yshift=-0.8em]w1.south){$<$sos$>$};
\node[anchor=north,unit,fill=orange!20] (n12) at ([yshift=-1.5em]n11.south){$<$sos$>$};
\node[anchor=north,unit,fill=orange!20] (n13) at ([yshift=-1.5em]n12.south){$<$sos$>$};
\node[anchor=north,unit,fill=orange!20] (n14) at ([yshift=-1.5em]n13.south){$<$sos$>$};
\node[anchor=east,unit] (step1) at ([xshift=-1em]n11.west){Step1:};
\node[anchor=east,unit] (step2) at ([xshift=-1em]n12.west){Step2:};
\node[anchor=east,unit] (step3) at ([xshift=-1em]n13.west){Step3:};
\node[anchor=east,unit] (step4) at ([xshift=-1em]n14.west){Step4:};
\node[anchor=west,unit] (w2) at ([xshift=1.5em]w1.east){$w_2$};
\node[anchor=north,unit] (n21) at ([yshift=-0.8em]w2.south){};
\node[anchor=north,word,fill=orange!20] (n22) at ([yshift=-1.5em]n21.south){I};
\node[anchor=north,word,fill=orange!20] (n23) at ([yshift=-1.5em]n22.south){I};
\node[anchor=north,word,fill=orange!20] (n24) at ([yshift=-1.5em]n23.south){I};
\node[anchor=west,unit] (w3) at ([xshift=1.5em]w2.east){$w_3$};
\node[anchor=north,unit] (n31) at ([yshift=-0.8em]w3.south){};
\node[anchor=north,unit] (n32) at ([yshift=-1.5em]n31.south){};
\node[anchor=north,word,fill=orange!20] (n33) at ([yshift=-1.5em]n32.south){agree};
\node[anchor=north,word,fill=orange!20] (n34) at ([yshift=-1.5em]n33.south){agree};
\node[anchor=west,unit] (w4) at ([xshift=1.5em]w3.east){$w_4$};
\node[anchor=north,unit] (n41) at ([yshift=-0.8em]w4.south){};
\node[anchor=north,unit] (n42) at ([yshift=-1.5em]n41.south){};
\node[anchor=north,unit] (n43) at ([yshift=-1.5em]n42.south){};
\node[anchor=north,unit,fill=orange!20] (n44) at ([yshift=-1.5em]n43.south){$<$eos$>$};
\begin{pgfonlayer}{background}
\node [draw=red,very thick,rectangle,inner sep=2.5pt,rounded corners=2pt,dashed] [fit = (n12)] (box1) {};
\node [draw=red,very thick,rectangle,inner sep=2.5pt,rounded corners=2pt,dashed] [fit = (n13)(n23)] (box2) {};
\node [draw=red,very thick,rectangle,inner sep=2.5pt,rounded corners=2pt,dashed] [fit = (n14)(n24)(n34)] (box3) {};
\end{pgfonlayer}
\draw[-latex,red,thick] (box1.south).. controls +(300:0.45) and +(240:0.45) .. (n22.south);
\draw[-latex,red,thick] (box2.south).. controls +(290:0.45) and +(250:0.45) .. (n33.south);
\draw[-latex,red,thick] (box3.south).. controls +(280:0.5) and +(260:0.5) .. (n44.south);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [inner sep=1pt,align=center,minimum width=4em,minimum height=2em,font=\large]
\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){I\\[-0.5ex]agree};
\node[fill=blue!40,anchor=north,align=left,inner sep=2pt,minimum width=5em](spe)at(words.south){\color{white}{\small\bfnew{特殊符号}}};
\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,unit] (w1) at ([xshift=2.5em,yshift=-1em]eos.south){$w_1$};
\node[anchor=north,unit,fill=blue!10] (n11) at ([yshift=-0.5em]w1.south){{{$<$sos$>$}}};
\node[anchor=west,unit,fill=red!20] (n22) at ([xshift=3em]n11.east){{{agree}}};
\node[anchor=south,unit,fill=red!20] (n21) at ([yshift=5.5em]n22.north){{{I}}};
\node[anchor=north,unit,fill=blue!10] (n23) at ([yshift=-3em]n22.south){{{$<$eos$>$}}};
\node[anchor=south,unit] (w2) at ([yshift=0.5em]n21.north){$w_2$};
\node[anchor=west,unit,fill=red!20] (n32) at ([xshift=3em]n21.east){{{agree}}};
\node[anchor=south,unit,fill=red!20] (n31) at ([yshift=0.3em]n32.north){{{I}}};
\node[anchor=north,unit,fill=blue!10] (n33) at ([yshift=-0.3em]n32.south){{{$<$eos$>$}}};
\node[anchor=west,unit,fill=red!20] (n35) at ([xshift=3em]n22.east){{{agree}}};
\node[anchor=south,unit,fill=red!20] (n34) at ([yshift=0.3em]n35.north){{{I}}};
\node[anchor=north,unit,fill=blue!10] (n36) at ([yshift=-0.3em]n35.south){{{$<$eos$>$}}};
\node[anchor=south,unit] (w3) at ([yshift=0.5em]n31.north){$w_3$};
\node[anchor=west,unit,fill=blue!10] (n41) at ([xshift=3em]n31.east){{{$<$eos$>$}}};
\node[anchor=west,unit,fill=blue!10] (n42) at ([xshift=3em]n32.east){{{$<$eos$>$}}};
\node[anchor=west,unit,fill=blue!10] (n43) at ([xshift=3em]n34.east){{{$<$eos$>$}}};
\node[anchor=west,unit,fill=blue!10] (n44) at ([xshift=3em]n35.east){{{$<$eos$>$}}};
\node[anchor=south,unit] (w4) at ([yshift=0.5em]n41.north){$w_4$};
\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,very thick] (n21.east) -- (n31.west);
\draw[->,ublue,very thick] (n21.east) -- (n32.west);
\draw[->,ublue,very thick] (n21.east) -- (n33.west);
\draw[->,ublue,very thick] (n22.east) -- (n34.west);
\draw[->,ublue,very thick] (n22.east) -- (n35.west);
\draw[->,ublue,very thick] (n22.east) -- (n36.west);
\draw[->,ublue,very thick] (n31.east) -- (n41.west);
\draw[->,ublue,very thick] (n32.east) -- (n42.west);
\draw[->,ublue,very thick] (n34.east) -- (n43.west);
\draw[->,ublue,very thick] (n35.east) -- (n44.west);
\end{tikzpicture}
......@@ -13,7 +13,7 @@
\node [draw,thick,minimum size=10pt] at (\i,0) {1};
}
}
\node [anchor=west] at (33em,0) {$\textrm{P}(\text{1}) = 5/30$};
\node [anchor=west] at (33em,0) {$\funp{P}(\text{1}) = 5/30$};
\end{scope}
\begin{scope}[yshift=-2.5em]
......@@ -22,7 +22,7 @@
\node [draw,thick,minimum size=10pt] at (\i,0) {{\color{red} 2}};
}
}
\node [anchor=west] at (33em,0) {$\textrm{P}(\text{2}) = 4/30$};
\node [anchor=west] at (33em,0) {$\funp{P}(\text{2}) = 4/30$};
\end{scope}
\begin{scope}[yshift=-5.0em]
......@@ -31,7 +31,7 @@
\node [draw,thick,minimum size=10pt] at (\i,0) {{\color{ublue} 3}};
}
}
\node [anchor=west] at (33em,0) {$\textrm{P}(\text{3}) = 6/30$};
\node [anchor=west] at (33em,0) {$\funp{P}(\text{3}) = 6/30$};
\end{scope}
\begin{scope}[yshift=-7.5em]
......@@ -40,7 +40,7 @@
\node [draw,thick,minimum size=10pt] at (\i,0) {{\color{ugreen} 4}};
}
}
\node [anchor=west] at (33em,0) {$\textrm{P}(\text{4}) = 12/30$};
\node [anchor=west] at (33em,0) {$\funp{P}(\text{4}) = 12/30$};
\end{scope}
\begin{scope}[yshift=-10.0em]
......@@ -49,7 +49,7 @@
\node [draw,thick,minimum size=10pt] at (\i,0) {{\color{purple} 5}};
}
}
\node [anchor=west] at (33em,0) {$\textrm{P}(\text{5}) = 2/30$};
\node [anchor=west] at (33em,0) {$\funp{P}(\text{5}) = 2/30$};
\end{scope}
\begin{scope}[yshift=-12.5em]
......@@ -58,7 +58,7 @@
\node [draw,thick,minimum size=10pt] at (\i,0) {{\color{orange} 6}};
}
}
\node [anchor=west] at (33em,0) {$\textrm{P}(\text{6}) = 1/30$};
\node [anchor=west] at (33em,0) {$\funp{P}(\text{6}) = 1/30$};
\end{scope}
\end{tikzpicture}
......
......@@ -3,12 +3,12 @@
\begin{axis}[
width=11cm,
height=5.5cm,
xlabel={某语料库中的词汇},
xlabel={WikiText-103上的词表},
ylabel={词汇出现总次数},
xlabel style={xshift=6.2cm,yshift=0.8cm,font=\footnotesize},
xlabel style={xshift=4.2cm,yshift=0.4cm,font=\footnotesize},
ylabel style={rotate=-90,yshift=2.8cm,xshift=1.2cm,font=\footnotesize},
xticklabel style={opacity=0},
ytick={0,10000000,20000000,30000000,40000000,50000000,60000000},
ytick={0,1000000,2000000,3000000,4000000,5000000,6000000},
tick align=inside,
y tick style={opacity=0},
x tick style={opacity=0},
......@@ -21,112 +21,112 @@ axis x line*=bottom,
xmin=0,
xmax=105,
ymin=0,
ymax=60000000
ymax=6000000
]
\addplot[fill=blue!40,draw=blue!40] coordinates{(1,56000000)
(2,34000000)
(3,30000000)
(4,27000000)
(5,18000000)
(6,12000000)
(7,11000000)
(8,10000000)
(9,9000000)
(10,8600000)
(11,8200000)
(12,7800000)
(13,7400000)
(14,7000000)
(15,6600000)
(16,6200000)
(17,5800000)
(18,5400000)
(19,5000000)
(20,4800000)
(21,4600000)
(22,4400000)
(23,4200000)
(24,4000000)
(25,3800000)
(26,3600000)
(27,3400000)
(28,3200000)
(29,3000000)
(30,2950000)
(31,2900000)
(32,2850000)
(33,2800000)
(34,2750000)
(35,2700000)
(36,2650000)
(37,2600000)
(38,2550000)
(39,2500000)
(40,2450000)
(41,2400000)
(42,2350000)
(43,2300000)
(44,2250000)
(45,2200000)
(46,2150000)
(47,2100000)
(48,2050000)
(49,2000000)
(50,1970000)
(51,1940000)
(52,1910000)
(53,1880000)
(54,1850000)
(55,1820000)
(56,1790000)
(57,1760000)
(58,1730000)
(59,1700000)
(60,1670000)
(61,1640000)
(62,1610000)
(63,1580000)
(64,1550000)
(65,1520000)
(66,1490000)
(67,1460000)
(68,1430000)
(69,1400000)
(70,1370000)
(71,1340000)
(72,1310000)
(73,1280000)
(74,1250000)
(75,1220000)
(76,1190000)
(77,1160000)
(78,1130000)
(79,1100000)
(80,1070000)
(81,1040000)
(82,1010000)
(83,980000)
(84,950000)
(85,920000)
(86,890000)
(87,860000)
(88,830000)
(89,800000)
(90,770000)
(91,740000)
(92,710000)
(93,680000)
(94,650000)
(95,620000)
(96,590000)
(97,560000)
(98,530000)
(99,500000)
(100,470000)
(101,440000)
(102,410000)
(103,380000)
(104,350000)};
\addplot[fill=blue!40,draw=blue!40] coordinates{(1,5584823)
(2,4971506)
(3,3624899)
(4,2737620)
(5,2499539)
(6,1979164)
(7,1894558)
(8,1677048)
(9,1338685)
(10,1075325)
(11,881576)
(12,853819)
(13,728291)
(14,688528)
(15,679711)
(16,675287)
(17,675032)
(18,632025)
(19,600898)
(20,583875)
(21,583522)
(22,512782)
(23,441959)
(24,436363)
(25,431900)
(26,417082)
(27,354550)
(28,326416)
(29,318305)
(30,306216)
(31,292528)
(32,281598)
(33,275598)
(34,235033)
(35,203336)
(36,203212)
(37,194870)
(38,191058)
(39,189667)
(40,186430)
(41,185670)
(42,181247)
(43,179733)
(44,176758)
(45,174862)
(46,166456)
(47,163459)
(48,163454)
(49,158057)
(50,156709)
(51,155431)
(52,152103)
(53,150736)
(54,149068)
(55,145573)
(56,141128)
(57,138306)
(58,135556)
(59,130319)
(60,126371)
(61,124383)
(62,123422)
(63,119260)
(64,115844)
(65,113966)
(66,110018)
(67,109467)
(68,102051)
(69,100733)
(70,99837)
(71,99818)
(72,97887)
(73,96296)
(74,96183)
(75,93734)
(76,92977)
(77,91793)
(78,90597)
(79,90225)
(80,90191)
(81,89732)
(82,88286)
(83,87322)
(84,87015)
(85,84554)
(86,83599)
(87,81803)
(88,80455)
(89,78025)
(90,76980)
(91,76901)
(92,75611)
(93,75220)
(94,74378)
(95,74305)
(96,73776)
(97,71929)
(98,71592)
(99,71340)
(100,71237)
(101,71203)
(102,70171)
(103,69555)
(104,68668)};
\end{axis}
\end{tikzpicture}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\vspace{0.5em}
\begin{tikzpicture}
{\small
\node [ugreen] (input) at (0,0) {猫喜欢吃鱼};
\node [draw,thick,anchor=west,ublue] (preprocessing) at ([xshift=1em]input.east) {分词系统};
\node [ugreen,anchor=west] (mtinput) at ([xshift=1em]preprocessing.east) {猫/喜欢/吃/鱼};
\node [draw,thick,anchor=west,ublue] (smt) at ([xshift=1em]mtinput.east) {MT系统};
\node [anchor=west] (mtoutput) at ([xshift=1em]smt.east) {...};
\draw [->,thick,ublue] ([xshift=0.1em]input.east) -- ([xshift=-0.2em]preprocessing.west);
\draw [->,thick,ublue] ([xshift=0.2em]preprocessing.east) -- ([xshift=-0.1em]mtinput.west);
\draw [->,thick,ublue] ([xshift=0.1em]mtinput.east) -- ([xshift=-0.2em]smt.west);
\draw [->,thick,ublue] ([xshift=0.2em]smt.east) -- ([xshift=-0.1em]mtoutput.west);
}
\end{tikzpicture}
%---------------------------------------------------------------------
%%% outline
%-------------------------------------------------------------------------
\vspace{0.3em}
\begin{tikzpicture}
\begin{scope}[scale=1.0,level distance=30pt,sibling distance=15pt,grow'=up]
{
\Tree[.\node(sn0){IP};
[.\node(sn1){NP};
[.\node(sn2){NN}; \node(sw1){}; ]
]
[.\node(sn3){VP};
[.\node(sn4){VV}; \node(sw2){喜欢}; ]
[.\node(sn5){VP}; \edge[roof]; \node(sw3){\ }; ]
]
]
}
\end{scope}
\end{tikzpicture}
%---------------------------------------------------------------------
\begin{tikzpicture}
\tikzstyle{hide} = [draw,line width=1pt,inner sep=2pt,fill=green!30,minimum size=2em]
\node[hide] (y1) at (0,0){$y_1$};
\node[anchor=west,hide](y2)at([xshift=2em]y1.east){$y_2$};
\node[anchor=west,hide](y3)at([xshift=2em]y2.east){$y_3$};
\node[anchor=west,line width=1pt,inner sep=2pt,minimum size=2em](dots)at([xshift=2em]y3.east){$\cdots$};
\node[anchor=west,hide](yn-1)at([xshift=2em]dots.east){$y_{n-1}$};
\node[anchor=west,hide](yn)at([xshift=2em]yn-1.east){$y_n$};
\node[anchor=north,draw,line width=1pt,inner sep=2pt,fill=red!30,minimum height=2em,minimum width=12em](see)at ([yshift=-3em,xshift=2em]y3.south){$\mathbf{X}=(x_1,x_2,\ldots,x_{n-1},x_n)$};
\node[anchor=south,font=\footnotesize] at ([yshift=1em,xshift=2em]y3.north){待预测的隐藏状态序列};
\node[anchor=north,font=\footnotesize] at ([yshift=-1em]see.south){可见状态序列};
\draw[line width=1pt] (y1.east) -- (y2.west);
\draw[line width=1pt] (y2.east) -- (y3.west);
\draw[line width=1pt] (y3.east) -- (dots.west);
\draw[line width=1pt] (dots.east) -- (yn-1.west);
\draw[line width=1pt] (yn-1.east) -- (yn.west);
\draw[line width=1pt] (y1.south) -- (see.north);
\draw[line width=1pt] (y2.south) -- (see.north);
\draw[line width=1pt] (y3.south) -- (see.north);
\draw[line width=1pt] (yn-1.south) -- (see.north);
\draw[line width=1pt] (yn.south) -- (see.north);
\end{tikzpicture}
\ No newline at end of file
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
\begin{scope}
{
{\small
\node [anchor=north west] (entry1) at (0,0) {\textbf{1:}};
\node [anchor=north west] (entry2) at ([yshift=0.1em]entry1.south west) {\textbf{2:}};
\node [anchor=north west] (entry3) at ([yshift=0.1em]entry2.south west) {\textbf{3:} 现在};
\node [anchor=north west] (entry4) at ([yshift=0.1em]entry3.south west) {\textbf{4:} 物价};
\node [anchor=north west] (entry5) at ([yshift=0.1em]entry4.south west) {\textbf{5:} 确实};
\node [anchor=north west] (entry6) at ([yshift=0.1em]entry5.south west) {\textbf{6:} 实现};
\node [anchor=south west] (dictionarylabel) at (entry1.north west) {{\color{ublue} 分词词典}};
}
}
\begin{pgfonlayer}{background}
{
\node[rectangle,draw=ublue, inner sep=0.2em] [fit = (entry1) (entry2) (entry3) (entry4) (entry5) (entry6) (dictionarylabel)] {};
}
\end{pgfonlayer}
\end{scope}
{
\begin{scope}[xshift=1.2in,yshift=1em]
\node [anchor=west] (c1) at (0,0) {};
\node [anchor=west] (c2) at ([xshift=0em]c1.east) {};
\node [anchor=west] (c3) at ([xshift=0em]c2.east) {};
\node [anchor=west] (c4) at ([xshift=0em]c3.east) {};
\node [anchor=west] (c5) at ([xshift=0em]c4.east) {};
\node [anchor=west] (c6) at ([xshift=0em]c5.east) {};
\node [anchor=west] (c7) at ([xshift=0em]c6.east) {};
\node [anchor=west] (c8) at ([xshift=0em]c7.east) {};
\end{scope}
}
{
\node [anchor=west,thick,draw,minimum width=3.4em,minimum height=1.5em,ugreen] (w1) at (c3.west){};
\draw [->,thick,ugreen] (entry3.30) ..controls +(70:1) and +(south:1.5).. ([xshift=0.3em]w1.south) node [pos=0.5, above] {\footnotesize{命中}};
}
{
\node [anchor=west,very thick,draw,dotted,minimum width=3.4em,minimum height=1.9em,ublue] (w3) at (c2.west){};
\draw [->,very thick,dotted,ublue] ([yshift=-0.2em]entry6.30) ..controls +(60:2) and +(south:3).. ([xshift=-0.6em]w3.south) node [pos=0.5, below] {\color{ublue}{\footnotesize{命中}}};
}
\end{tikzpicture}
%---------------------------------------------------------------------
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
\begin{scope}[sibling distance=0pt,level distance=17pt]
{\footnotesize
\Tree[.\node[inner sep=2pt](t1n1){IP};
[.\node[inner sep=2pt](t1n2){NP};
[.\node[inner sep=2pt](t1n3){NN}; 狗 ]
]
[.\node[inner sep=2pt](t1n4){VP};
[.\node[inner sep=2pt](t1n5){VV}; 喜欢 ]
[.\node[inner sep=2pt](t1n6){VP};
[.\node[inner sep=2pt](t1n7){VV}; 吃 ]
[.\node[inner sep=2pt](t1n8){NN}; 骨头 ]
]
]
]
}
\end{scope}
\begin{scope}[sibling distance=0pt,level distance=17pt,yshift=-7em]
{\footnotesize
\Tree[.\node[inner sep=2pt](t2n1){IP};
[.\node[inner sep=2pt](t2n2){VP};
[.\node[inner sep=2pt](t2n3){VV}; \node[](t2w1){}; ]
]
[.\node[inner sep=2pt](t2n4){IP};
[.\node[inner sep=2pt](t2n5){VP};
[.\node[inner sep=2pt](t2n6){VV}; 看 ]
]
[.\node[inner sep=2pt](t2n7){NP};
[.\node[inner sep=2pt](t2n8){QP};
[.\node[inner sep=2pt](t2n9){CD}; 一 ]
[.\node[inner sep=2pt](t2n10){M}; 个 ]
]
[.\node[inner sep=2pt](t2n11){ADJP};
[.\node[inner sep=2pt](t2n12){JJ}; 新 ]
]
[.\node[inner sep=2pt](t2n13){NP};
[.\node[inner sep=2pt](t2n14){NN}; \node[](t2wn){句子}; ]
]
]
]
]
}
\end{scope}
\node [anchor=south] (treebanklabel) at (t1n1.north) {{\color{ublue} 数据:树库}};
\begin{pgfonlayer}{background}
\node[rectangle,draw=ublue, inner sep=0.2em] [fit = (treebanklabel) (t1n1) (t2w1) (t2wn)] (treebank) {};
\end{pgfonlayer}
\node [anchor=north west] (math1) at ([xshift=2em]treebank.north east) {P(VP $\to$ VV NN)};
\node [anchor=north west] (math1part2) at ([xshift=-1em,yshift=0.2em]math1.south west) {$=\frac{\textrm{``VP''和``VV NN''同时出现的次数=1}}{\textrm{``VP''出现的次数}=4}$};
\node [anchor=north west] (math1part3) at ([yshift=0.2em]math1part2.south west){$=\frac{1}{4}$};
\node [anchor=north west] (math2) at ([yshift=-6em]math1.north west) {P(NP $\to$ NN)};
\node [anchor=north west] (math2part2) at ([xshift=-1em,yshift=0.2em]math2.south west) {$=\frac{\textrm{``NP''和``NN''同时出现的次数=2}}{\textrm{``NP''出现的次数}=3}$};
\node [anchor=north west] (math2part3) at ([yshift=0.2em]math2part2.south west){$=\frac{2}{3}$};
\node [anchor=north west] (math3) at ([yshift=-6em]math2.north west) {P(IP $\to$ NP NP)};
\node [anchor=north west] (math3part2) at ([xshift=-1em,yshift=0.2em]math3.south west) {$=\frac{\textrm{``IP''和``NP NP''同时出现的次数=0}}{\textrm{``IP''出现的次数}=3}$};
\node [anchor=north west] (math3part3) at ([yshift=0.2em]math3part2.south west){$=\frac{0}{3}$};
\begin{pgfonlayer}{background}
\path [] (t1n4.north east) -- (t1n4.north west) -- (t1n4.south west) -- (t1n4.south east);
\path [] (t1n6.north east) -- (t1n6.north west) -- (t1n6.south west) -- (t1n6.south east);
\path [] (t2n2.north east) -- (t2n2.north west) -- (t2n2.south west) -- (t2n2.south east);
\path [] (t2n5.north east) -- (t2n5.north west) -- (t2n5.south west) -- (t2n5.south east);
\path [] (t1n6.north west) -- (t1n7.north west) -- (t1n7.south west) -- (t1n8.south east) -- (t1n8.north east) -- (t1n6.north east);
\path [] (t1n2.north east) -- (t1n2.north west) -- (t1n2.south west) -- (t1n2.south east);
\path [] (t2n7.north east) -- (t2n7.north west) -- (t2n7.south west) -- (t2n7.south east);
\path [] (t2n13.north east) -- (t2n13.north west) -- (t2n13.south west) -- (t2n13.south east);
\path [] (t1n2.north west) -- (t1n3.south west) -- (t1n3.south east) -- (t1n2.north east) -- (t1n2.north west);
\path [] (t2n13.north west) -- (t2n14.south west) -- (t2n14.south east) -- (t2n13.north east) -- (t2n13.north west);
\path [] (t1n1.north east) -- (t1n1.north west) -- (t1n1.south west) -- (t1n1.south east);
\path [] (t2n4.north east) -- (t2n4.north west) -- (t2n4.south west) -- (t2n4.south east);
\path [] (t2n1.north east) -- (t2n1.north west) -- (t2n1.south west) -- (t2n1.south east);
\end{pgfonlayer}
\end{tikzpicture}
%---------------------------------------------------------------------
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{minipage}[t]{0.38\linewidth}
{\small
\begin{eqnarray}
& &\textrm{IP} \nonumber \\
& \overset{r_8}{\Rightarrow} & \textrm{NP VP} \nonumber \\
& \overset{r_5}{\Rightarrow} & \textrm{NN VP} \nonumber \\
& \overset{r_1}{\Rightarrow} & \textrm{猫 VP} \nonumber \\
& \overset{r_7}{\Rightarrow} & \textrm{猫 VV VP} \nonumber \\
& \overset{r_2}{\Rightarrow} & \textrm{猫 喜欢 VP} \nonumber \\
& \overset{r_6}{\Rightarrow} & \textrm{猫 喜欢 VV NN} \nonumber \\
& \overset{r_3}{\Rightarrow} & \textrm{猫 喜欢 吃 NN} \nonumber \\
& \overset{r_4}{\Rightarrow} & \textrm{猫 喜欢 吃 鱼} \nonumber
\end{eqnarray}
}
\end{minipage}
\hfill
\begin{minipage}[t]{0.55\linewidth}
\vspace{1.0em}
\begin{center}
\begin{tikzpicture}
\begin{scope}
{\scriptsize
\node [anchor=west,inner sep=2pt] (r1) at (0,0) {$r_1$: NN $\to$};
\node [anchor=west,inner sep=2pt] (r2) at ([xshift=3em]r1.east) {$r_2$: VV $\to$ 喜欢};
\node [anchor=north west,inner sep=2pt] (r3) at ([yshift=-0.2em]r1.south west) {$r_3$: VV $\to$};
\node [anchor=north west,inner sep=2pt] (r4) at ([yshift=-0.2em]r2.south west) {$r_4$: NN $\to$};
\node [anchor=north west,inner sep=2pt] (r5) at ([yshift=-0.2em]r3.south west) {$r_5$: NP $\to$ NN};
\node [anchor=north west,inner sep=2pt] (r6) at ([yshift=-0.2em]r4.south west) {$r_6$: VP $\to$ VV NN};
\node [anchor=north west,inner sep=2pt] (r7) at ([yshift=-0.2em]r5.south west) {$r_7$: VP $\to$ VV VP};
\node [anchor=north west,inner sep=2pt] (r8) at ([yshift=-0.2em]r6.south west) {$r_8$: IP $\to$ NP VP};
\node [anchor=west,inner sep=2pt] (r1) at (0,0) {$r_1$: NN $\to$};
\node [anchor=west,inner sep=2pt] (r2) at ([xshift=3em]r1.east) {$r_2$: VV $\to$ 喜欢};
\node [anchor=north west,inner sep=2pt] (r3) at ([yshift=-0.2em]r1.south west) {$r_3$: VV $\to$};
\node [anchor=north west,inner sep=2pt] (r4) at ([yshift=-0.2em]r2.south west) {$r_4$: NN $\to$};
\node [anchor=north west,inner sep=2pt] (r5) at ([yshift=-0.2em]r3.south west) {$r_5$: NP $\to$ NN};
\node [anchor=north west,inner sep=2pt] (r6) at ([yshift=-0.2em]r4.south west) {$r_6$: VP $\to$ VV NN};
\node [anchor=north west,inner sep=2pt] (r7) at ([yshift=-0.2em]r5.south west) {$r_7$: VP $\to$ VV VP};
\node [anchor=north west,inner sep=2pt] (r8) at ([yshift=-0.2em]r6.south west) {$r_8$: IP $\to$ NP VP};
}
\end{scope}
\begin{scope}[xshift=4.5em,yshift=-5.5em,level distance=20pt,sibling distance=13pt]
\Tree[.IP \edge[white];
[.{\color{white} NP} \edge[white];
[.{\color{white} NN} \edge[white]; \node[white](sw1){}; ]
] \edge[white];
[.{\color{white} VP} \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw2){喜欢}; ] \edge[white];
[.{\color{white} VP} \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw1){}; ] \edge[white];
[.{\color{white} NN} \edge[white]; \node[white](sw1){}; ]
]
]
]
\Tree[.IP
[.NP \edge[white];
[.{\color{white} NN} \edge[white]; \node[white](sw1){}; ]
]
[.VP \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw2){喜欢}; ] \edge[white];
[.{\color{white} VP} \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw1){}; ] \edge[white];
[.{\color{white} NN} \edge[white]; \node[white](sw1){}; ]
]
]
]
\Tree[.IP
[.NP
[.NN \edge[white]; \node[white](sw1){}; ]
]
[.VP \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw2){喜欢}; ] \edge[white];
[.{\color{white} VP} \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw1){}; ] \edge[white];
[.{\color{white} NN} \edge[white]; \node[white](sw1){}; ]
]
]
]
\Tree[.IP
[.NP
[.NN \node(sw1){}; ]
]
[.VP \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw2){喜欢}; ] \edge[white];
[.{\color{white} VP} \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw1){}; ] \edge[white];
[.{\color{white} NN} \edge[white]; \node[white](sw1){}; ]
]
]
]
\Tree[.IP
[.NP
[.NN \node(sw1){}; ]
]
[.VP
[.VV \edge[white]; \node[white](sw2){喜欢}; ]
[.VP \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw1){}; ] \edge[white];
[.{\color{white} NN} \edge[white]; \node[white](sw1){}; ]
]
]
]
\Tree[.IP
[.NP
[.NN \node(sw1){}; ]
]
[.VP
[.VV \node(sw2){喜欢}; ]
[.VP \edge[white];
[.{\color{white} VV} \edge[white]; \node[white](sw1){}; ] \edge[white];
[.{\color{white} NN} \edge[white]; \node[white](sw1){}; ]
]
]
]
\Tree[.IP
[.NP
[.NN \node(sw1){}; ]
]
[.VP
[.VV \node(sw2){喜欢}; ]
[.VP
[.VV \edge[white]; \node[white](sw1){}; ]
[.NN \edge[white]; \node[white](sw1){}; ]
]
]
]
\Tree[.IP
[.NP
[.NN \node(sw1){}; ]
]
[.VP
[.VV \node(sw2){喜欢}; ]
[.VP
[.VV \node(sw1){}; ]
[.NN \node(sw1){}; ]
]
]
]
\end{scope}
\end{tikzpicture}
\end{center}
\end{minipage}
%---------------------------------------------------------------------
\begin{tikzpicture}
\tikzstyle{hide} = [draw,inner sep=2pt,line width=1pt,align=center,drop shadow,fill=green!20,font=\footnotesize,minimum height=1.8em,minimum width=1.8em]
\tikzstyle{see} = [draw,inner sep=2pt,line width=1pt,align=center,drop shadow,fill=red!30,font=\footnotesize,minimum height=1.2em,minimum width=1.2em,circle]
\node[hide] (h1) at (0,0){C};
\node[hide,anchor=west] (h2) at ([xshift=2em]h1.east){B};
\node[hide,anchor=west] (h3) at ([xshift=2em]h2.east){A};
\node[hide,anchor=west] (h4) at ([xshift=2em]h3.east){B};
\node[hide,anchor=west] (h5) at ([xshift=2em]h4.east){C};
\node[hide,anchor=west] (h6) at ([xshift=2em]h5.east){A};
\node[see,anchor=north] (s1) at ([yshift=-1.6em]h1.south){};
\node[see,anchor=north] (s2) at ([yshift=-1.6em]h2.south){};
\node[see,anchor=north] (s3) at ([yshift=-1.6em]h3.south){};
\node[see,anchor=north] (s4) at ([yshift=-1.6em]h4.south){};
\node[see,anchor=north] (s5) at ([yshift=-1.6em]h5.south){};
\node[see,anchor=north] (s6) at ([yshift=-1.6em]h6.south){};
\draw[->,line width=1.4pt] (h1.east) -- node[above]{$\frac{1}{3}$}(h2.west);
\draw[->,line width=1.4pt] (h2.east) -- node[above]{$\frac{1}{3}$}(h3.west);
\draw[->,line width=1.4pt] (h3.east) -- node[above]{$\frac{1}{3}$}(h4.west);
\draw[->,line width=1.4pt] (h4.east) -- node[above]{$\frac{1}{3}$}(h5.west);
\draw[->,line width=1.4pt] (h5.east) -- node[above]{$\frac{1}{3}$}(h6.west);
\draw[->,line width=1.4pt,blue!60] (h1.south) -- node[right,black]{\footnotesize $0.7$}(s1.north);
\draw[->,line width=1.4pt,blue!60] (h2.south) -- node[right,black]{\footnotesize $0.5$}(s2.north);
\draw[->,line width=1.4pt,blue!60] (h3.south) -- node[right,black]{\footnotesize $0.7$}(s3.north);
\draw[->,line width=1.4pt,blue!60] (h4.south) -- node[right,black]{\footnotesize $0.5$}(s4.north);
\draw[->,line width=1.4pt,blue!60] (h5.south) -- node[right,black]{\footnotesize $0.7$}(s5.north);
\draw[->,line width=1.4pt,blue!60] (h6.south) -- node[right,black]{\footnotesize $0.7$}(s6.north);
\begin{pgfonlayer}{background}
\node [draw,rectangle,inner sep=1em,rounded corners=2pt,fill=gray!20] [fit = (h1)(s1)(h6) (s6)] (box) {};
\end{pgfonlayer}
\node[anchor=north,font=\footnotesize] (note) at ([xshift=0.4em,yshift=-1.4em]s1.south){图示说明:};
\node[anchor=north,hide,minimum height=1em,minimum width=1em] (one_h) at ([xshift=-0.6em,yshift=-1em]note.south){};
\node[anchor=west,font=\scriptsize] at ([xshift=0.2em]one_h.east){一个隐含状态};
\node[anchor=north,see] (one_s) at ([yshift=-1.4em]one_h.south){};
\node[anchor=west,font=\scriptsize] at ([xshift=0.2em]one_s.east){一个可见状态};
\draw[->,line width=1.4pt] ([xshift=8em]one_h.east) -- ([xshift=9em]one_h.east);
\node[anchor=west,align=left,font=\scriptsize] at ([xshift=9.2em]one_h.east){从一个隐含状态到下一个隐含状态\\的转换,该过程隐含着转移概率};
\draw[->,line width=1.4pt,blue!60] ([yshift=-2em,xshift=8.5em]one_h.east) --([yshift=-3em,xshift=8.5em]one_h.east) ;
\node[anchor=west,align=left,font=\scriptsize] at ([yshift=-2.5em,xshift=9.2em]one_h.east){从一个隐含状态到可见状态的输出\\,该过程隐含着发射概率};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [draw,circle,line width=0.8pt,align=center,fill=green!30,minimum size=1em]
\node[minimum width=3em,minimum height=1.8em] (o) at (0,0){};
\node[anchor=north,inner sep=1pt,font=\footnotesize] (state_A) at ([xshift=-0em,yshift=-1em]o.south){隐藏状态A};
\node[anchor=north,inner sep=1pt,font=\footnotesize] (state_B) at ([yshift=-1.6em]state_A.south){隐藏状态B};
\node[anchor=north,inner sep=1pt,font=\footnotesize] (state_C) at ([yshift=-1.6em]state_B.south){隐藏状态C};
\node[anchor=north,inner sep=1pt,font=\footnotesize] (state_D) at ([yshift=-1.6em]state_C.south){隐藏状态D};
\node[anchor=west,inner sep=1pt,font=\footnotesize] (c1) at ([yshift=0.2em,xshift=2em]o.east){T};
\node[anchor=west,inner sep=1pt,font=\footnotesize] (c2) at ([xshift=5em]c1.east){F};
\node[anchor=west,inner sep=1pt,font=\footnotesize] (c3) at ([xshift=5em]c2.east){F};
\node[anchor=west,inner sep=1pt,font=\footnotesize] (c4) at ([xshift=5em]c3.east){T};
\node[anchor=south,font=\scriptsize] (cl1) at (c1.north) {时刻1};
\node[anchor=south,font=\scriptsize] (cl2) at (c2.north) {时刻2};
\node[anchor=south,font=\scriptsize] (cl3) at (c3.north) {时刻3};
\node[anchor=south,font=\scriptsize] (cl4) at (c4.north) {时刻4};
\node[anchor=north,unit,fill=red!30] (u11) at ([yshift=-1.6em]c1.south){};
\node[anchor=north,unit] (u21) at ([yshift=-1.6em]u11.south){};
\node[anchor=north,unit] (u31) at ([yshift=-1.6em]u21.south){};
\node[anchor=north,unit] (u41) at ([yshift=-1.6em]u31.south){};
\node[anchor=north,unit,fill=red!30] (u12) at ([yshift=-1.6em]c2.south){};
\node[anchor=north,unit] (u22) at ([yshift=-1.6em]u12.south){};
\node[anchor=north,unit] (u32) at ([yshift=-1.6em]u22.south){};
\node[anchor=north,unit] (u42) at ([yshift=-1.6em]u32.south){};
\node[anchor=north,unit,fill=red!30] (u13) at ([yshift=-1.6em]c3.south){};
\node[anchor=north,unit] (u23) at ([yshift=-1.6em]u13.south){};
\node[anchor=north,unit] (u33) at ([yshift=-1.6em]u23.south){};
\node[anchor=north,unit] (u43) at ([yshift=-1.6em]u33.south){};
\node[anchor=north,unit,fill=red!30] (u14) at ([yshift=-1.6em]c4.south){};
\node[anchor=north,unit] (u24) at ([yshift=-1.6em]u14.south){};
\node[anchor=north,unit] (u34) at ([yshift=-1.6em]u24.south){};
\node[anchor=north,unit] (u44) at ([yshift=-1.6em]u34.south){};
\node[anchor=south west,align=center,font=\footnotesize] (label) at ([yshift=-1.4em,xshift=-4em]o.45){可见状态序列};
\draw[->] ([xshift=-0.2em]label.east) -- ([xshift=0.7em]label.east);
\draw[->,line width=1pt] (u11.east) -- node[above,red!50,font=\footnotesize]{0.65}(u12.west);
\draw[->,line width=1pt] (u12.east) -- node[above,red!50,font=\footnotesize]{0.55}(u13.west);
\draw[->,line width=1pt] (u12.east) -- node[right,pos=0.6,font=\footnotesize,xshift=0.2em]{0.45}(u23.west);
\draw[->,line width=1pt] (u13.east) -- node[above,red!50,font=\footnotesize]{0.5}(u14.west);
\draw[->,line width=1pt] (u13.east) -- node[right,pos=0.6,font=\footnotesize,xshift=0.2em]{0.5}(u24.west);
\draw[->,line width=1pt] (u11.east) -- node[right,font=\footnotesize,xshift=0.4em,yshift=-0.1em]{0.35}(u22.west);
\draw[->,line width=1pt] (u22.east) -- node[left,pos=0.4,font=\footnotesize,yshift=0.1em,xshift=-0.3em]{0.3}(u13.west);
\draw[->,line width=1pt] (u22.east) -- node[below,font=\footnotesize,yshift=0.2em]{0.2}(u23.west);
\draw[->,line width=1pt] (u22.east) -- node[below,font=\footnotesize,yshift=0.1em]{0.2}(u33.west);
\draw[->,line width=1pt] (u22.east) -- node[below,font=\footnotesize,yshift=-0.1em]{0.3}(u43.west);
\draw[->,line width=1pt] (u23.east) -- node[left,pos=0.4,font=\footnotesize,xshift=-0.2em]{0.35}(u14.west);
\draw[->,line width=1pt] (u23.east) -- node[below,font=\footnotesize,yshift=0.2em]{0.15}(u24.west);
\draw[->,line width=1pt] (u23.east) -- node[below,font=\footnotesize,xshift=0.4em,yshift=-0.2em,pos=0.6]{0.15}(u34.west);
\draw[->,line width=1pt] (u23.east) -- node[below,font=\footnotesize,yshift=-0.3em]{0.35}(u44.west);
\end{tikzpicture}
\ No newline at end of file
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
\begin{scope}
{
{\small
\node [anchor=north west] (entry1) at (0,0) {\textbf{1:}};
\node [anchor=north west] (entry2) at ([yshift=0.1em]entry1.south west) {\textbf{2:}};
\node [anchor=north west] (entry3) at ([yshift=0.1em]entry2.south west) {\textbf{3:} 现在};
\node [anchor=north west] (entry4) at ([yshift=0.1em]entry3.south west) {\textbf{4:} 物价};
\node [anchor=north west] (entry5) at ([yshift=0.1em]entry4.south west) {\textbf{5:} 确实};
\node [anchor=north west] (entry6) at ([yshift=0.1em]entry5.south west) {\textbf{6:} 实现};
\node [anchor=south west] (dictionarylabel) at (entry1.north west) {{\color{ublue} 分词词典}};
}
}
\begin{pgfonlayer}{background}
{
\node[rectangle,draw=ublue, inner sep=0.2em] [fit = (entry1) (entry2) (entry3) (entry4) (entry5) (entry6) (dictionarylabel)] {};
}
\end{pgfonlayer}
\end{scope}
{
\begin{scope}[xshift=1.2in,yshift=1em]
\node [anchor=west] (c1) at (0,0) {};
\node [anchor=west] (c2) at ([xshift=0em]c1.east) {};
\node [anchor=west] (c3) at ([xshift=0em]c2.east) {};
\node [anchor=west] (c4) at ([xshift=0em]c3.east) {};
\node [anchor=west] (c5) at ([xshift=0em]c4.east) {};
\node [anchor=west] (c6) at ([xshift=0em]c5.east) {};
\node [anchor=west] (c7) at ([xshift=0em]c6.east) {};
\node [anchor=west] (c8) at ([xshift=0em]c7.east) {};
\end{scope}
}
\begin{scope}[xshift=1.2in,yshift=-4em]
{
\node [anchor=west] (bc1) at (0,0) {};
\node [anchor=west] (bc2) at ([xshift=0em]bc1.east) {};
}
{
\node [anchor=west] (bc3) at ([xshift=0em]bc2.east) {};
\node [anchor=west] (bc4) at ([xshift=0em]bc3.east) {};
}
{
\node [anchor=west] (bc5) at ([xshift=0em]bc4.east) {};
\node [anchor=west] (bc6) at ([xshift=0em]bc5.east) {};
}
{
\node [anchor=west] (bc7) at ([xshift=0em]bc6.east) {};
}
{
\node [anchor=west] (bc8) at ([xshift=0em]bc7.east) {};
}
{
\draw [-,very thick] ([xshift=-0.3em,yshift=0.1em]bc2.south east) -- ([xshift=0.3em,yshift=-0.1em]bc3.north west);
}
{
\draw [-,very thick] ([xshift=-0.3em,yshift=0.1em]bc4.south east) -- ([xshift=0.3em,yshift=-0.1em]bc5.north west);
}
{
\draw [-,very thick] ([xshift=-0.3em,yshift=0.1em]bc6.south east) -- ([xshift=0.3em,yshift=-0.1em]bc7.north west);
}
{
\draw [-,very thick] ([xshift=-0.3em,yshift=0.1em]bc7.south east) -- ([xshift=0.3em,yshift=-0.1em]bc8.north west);
}
\end{scope}
{
\draw [<-,thick] ([yshift=-0.2em]c1.north west) -- ([yshift=0.2em]c1.north west);
\node [anchor=south] (b1) at ([yshift=0.0em]c1.north west) {\scriptsize{起始}};
}
{
\draw [<-,thick] ([yshift=-0.2em]c3.north west) -- ([yshift=0.2em]c3.north west);
\node [anchor=south] (b2) at ([yshift=0.0em]c3.north west) {\scriptsize{起始}};
}
{
\draw [<-,thick] ([yshift=-0.2em]c5.north west) -- ([yshift=0.2em]c5.north west);
\node [anchor=south] (b3) at ([yshift=0.0em]c5.north west) {\scriptsize{起始}};
}
{
\draw [<-,thick] ([yshift=-0.2em]c7.north west) -- ([yshift=0.2em]c7.north west);
\node [anchor=south] (b4) at ([yshift=0.0em]c7.north west) {\scriptsize{起始}};
}
{
\draw [<-,thick] ([yshift=-0.2em]c8.north west) -- ([yshift=0.2em]c8.north west);
\node [anchor=south] (b5) at ([yshift=0.0em]c8.north west) {\scriptsize{起始}};
}
{
\node [anchor=west,thick,draw,ublue,minimum width=1.6em,minimum height=1.3em] (w18) at ([xshift=0.1em]c8.west){};
\node [anchor=north] (l18) at ([yshift=-0.2em]w18.south) {{\color{ublue} \footnotesize{命中:第2号单词}}};
}
\end{tikzpicture}
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
{\scriptsize
\node [anchor=north west] (entry1) at (0,0) {\textbf{1:} 这 / 是 / 数据};
\node [anchor=north west] (entry2) at ([yshift=0.1em]entry1.south west) {\textbf{2:} 现在 / 已经 / 实现};
\node [anchor=north west] (entry3) at ([yshift=0.1em]entry2.south west) {\textbf{3:} 确实 / 有 / 很 / 多};
\node [anchor=north west] (entry4) at ([yshift=0.1em]entry3.south west) {...};
\node [anchor=south west] (corpuslabel) at (entry1.north west) {{\color{ublue} \textbf{学习用数据}}};
\begin{pgfonlayer}{background}
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (entry1) (entry2) (entry3) (entry4) (corpuslabel)] (corpus) {};
\end{pgfonlayer}
}
\node [anchor=west,ugreen] (P) at ([xshift=5.2em,yshift=-0.8em]corpus.east){\large{\funp{P}($\cdot$)}};
\node [anchor=south] (modellabel) at (P.north) {{\color{ublue} {\scriptsize \textbf{统计模型}}}};
\begin{pgfonlayer}{background}
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (P) (modellabel)] (model) {};
\end{pgfonlayer}
\draw [->,very thick,ublue] ([xshift=0.2em]corpus.east) -- ([xshift=4.2em]corpus.east) node [pos=0.5, above] {\color{red}{\scriptsize{统计学习}}};
\draw [->,very thick,ublue] ([xshift=0.2em]model.east) -- ([xshift=4.2em]model.east) node [pos=0.5, above] {\color{red}{\scriptsize{预测}}};
{\scriptsize
\node [anchor=north west] (sentlabel) at ([xshift=6.2em,yshift=-1em]model.north east) {\color{red}{自动分词系统}};
\node [anchor=north west] (sent) at (sentlabel.south west) {\textbf{对任意句子进行分词}};
}
\begin{pgfonlayer}{background}
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (sentlabel) (sent)] (segsystem) {};
\end{pgfonlayer}
{\footnotesize
{
\node [anchor=west] (label1) at (0,6em) {实际上,通过学习我们得到了一个分词模型\funp{P}($\cdot$),给定任意的分词结果};
\node [anchor=north west] (label1part2) at ([yshift=0.5em]label1.south west) {$W=w_1 w_2...w_n$,都能通过\funp{P}($W$)=$\funp{P}(w_1) \cdot \funp{P}(w_2) \cdot ... \cdot \funp{P}(w_n)$ 计算这种分词的\hspace{0.13em} };
\node [anchor=north west] (label1part3) at ([yshift=0.5em]label1part2.south west) {概率值};
}
\begin{pgfonlayer}{background}
{
\node[rectangle,fill=blue!10,thick,dotted,inner sep=0.2em] [fit = (label1) (label1part2) (label1part3)] (label1content) {};
}
\end{pgfonlayer}
{
\draw [-,thick,dotted] ([yshift=0.3em]modellabel.north) ..controls +(north:0.5) and +(south:0.5).. ([xshift=-3em]label1content.south);
}
}
{\footnotesize
{
\node [anchor=west] (label1) at (0,-6.8em) {\textbf{自动分词系统}:对任意的数据句子$S$,找到最佳的分词结果$W^{*}$输出};
}
{
\node [anchor=north west] (label2) at (label1.south west) {假设输入$S$=“确实现在数据很多”};
}
{
\node [anchor=north west,draw,thick,inner sep=2pt] (data11) at (label2.south west) {枚举所有可能的切分};
}
{
\node [anchor=west,draw,thick,inner sep=2pt] (data12) at ([xshift=4em]data11.east) {计算每种切分的概率};
}
{
\node [anchor=west,draw,thick,inner sep=2pt] (data13) at ([xshift=4.0em]data12.east) {选择最佳结果};
}
{
\draw [->,thick] ([xshift=0.1em]data11.east) -- ([xshift=-0.1em]data12.west);
}
{
\draw [->,thick] ([xshift=0.1em]data12.east) -- ([xshift=-0.1em]data13.west);
}
{\scriptsize
{
\node [anchor=north west] (data21) at (data11.south west) {确/实现/在/数/据很/多};
}
{
\node [anchor=north west] (data22) at (data12.south west) {$\funp{P}(\textrm{}) \cdot \funp{P}(\textrm{实现}) \cdot \funp{P}(\textrm{}) \cdot \funp{P}(\textrm{}) \cdot $};
}
\node [anchor=north west,minimum height=1.6em] (data23) at (data13.south west) {};
\node [anchor=north west,minimum height=1.6em] (data31) at ([yshift=0.3em]data21.south west) {};
{
\node [anchor=north west] (data32) at ([yshift=0.3em]data22.south west) {$\funp{P}(\textrm{据很}) \cdot \funp{P}(\textrm{}) = 2.13 \times 10^{-45}$};
}
\node [anchor=north west,minimum height=1.6em] (data33) at ([yshift=0.3em]data23.south west) {};
{
\node [anchor=north west] (data41) at (data31.south west) {确实/现在/数据/很多};
}
{
\node [anchor=north west] (data42) at (data32.south west) {$\funp{P}(\textrm{确实}) \cdot \funp{P}(\textrm{现在}) \cdot \funp{P}(\textrm{数据}) \cdot $};
}
{
\node [anchor=north west] (data43) at ([yshift=-0.2em,xshift=-2em]data33.south west) {\color{red}{\textbf{输出}}};
\draw [->,red,thick] (data43.west)--([xshift=-1em]data43.west);
}
{
\node [anchor=north west] (data51) at (data41.south west) {...};
}
{
\node [anchor=north west] (data52) at ([yshift=0.3em]data42.south west) {$\funp{P}(\textrm{}) \cdot \funp{P}(\textrm{}) = 1.54 \times 10^{-25}$};
}
\node [anchor=north west] (data53) at ([yshift=0.3em]data43.south west) {};
}
}
\begin{pgfonlayer}{background}
{
\node[rectangle,fill=blue!10,thick,dotted,inner sep=0.1em] [fit = (label1) (data11) (data13) (data51) (data52) (data53)] (segcontent) {};
}
\end{pgfonlayer}
{
\draw [-,thick,dotted] (segcontent.north) ..controls +(north:0.7) and +(south:0.7).. (segsystem.south);
}
\end{tikzpicture}
\begin{tikzpicture}
\tikzstyle{unit} = [draw,inner sep=2pt,line width=0.8pt,align=center,drop shadow,fill=red!30,font=\footnotesize,minimum height=1.2em,minimum width=1.8em]
\tikzstyle{lab} = [inner sep=0pt,align=center,rotate=-90,font=\scriptsize]
\node[unit] (n11) at (0,0){北京};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n11.east){\Large{/}};
\node[unit,anchor=west] (n12) at ([xshift=1.2em]n11.east){};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n12.east){\Large{/}};
\node[unit,anchor=west] (n13) at ([xshift=1.2em]n12.east){中华};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n13.east){\Large{/}};
\node[unit,anchor=west] (n14) at ([xshift=1.2em]n13.east){人民};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n14.east){\Large{/}};
\node[unit,anchor=west] (n15) at ([xshift=1.2em]n14.east){共和};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n15.east){\Large{/}};
\node[unit,anchor=west] (n16) at ([xshift=1.2em]n15.east){};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n16.east){\Large{/}};
\node[unit,anchor=west] (n17) at ([xshift=1.2em]n16.east){};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n17.east){\Large{/}};
\node[unit,anchor=west] (n18) at ([xshift=1.2em]n17.east){首都};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n11.south){B-CIT};
\node[lab,anchor=north] at ([yshift=-0.8em,xshift=0.2em]n12.south){O};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n13.south){B-CNT};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n14.south){I-CNT};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n15.south){I-CNT};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n16.south){I-CNT};
\node[lab,anchor=north] at ([yshift=-0.8em,xshift=0.2em]n17.south){O};
\node[lab,anchor=north] at ([yshift=-0.8em,xshift=0.2em]n18.south){O};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [draw,inner sep=2pt,line width=0.8pt,align=center,drop shadow,fill=red!30,font=\footnotesize,minimum height=1.2em,minimum width=1.8em]
\tikzstyle{lab} = [inner sep=0pt,align=center,rotate=-90,font=\scriptsize]
\node[unit] (n11) at (0,0){北京};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n11.east){\Large{/}};
\node[unit,anchor=west] (n12) at ([xshift=1.2em]n11.east){};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n12.east){\Large{/}};
\node[unit,anchor=west] (n13) at ([xshift=1.2em]n12.east){中华};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n13.east){\Large{/}};
\node[unit,anchor=west] (n14) at ([xshift=1.2em]n13.east){人民};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n14.east){\Large{/}};
\node[unit,anchor=west] (n15) at ([xshift=1.2em]n14.east){共和};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n15.east){\Large{/}};
\node[unit,anchor=west] (n16) at ([xshift=1.2em]n15.east){};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n16.east){\Large{/}};
\node[unit,anchor=west] (n17) at ([xshift=1.2em]n16.east){};
\node[anchor=west,inner sep=0pt,font=\footnotesize] at ([xshift=0.5em]n17.east){\Large{/}};
\node[unit,anchor=west] (n18) at ([xshift=1.2em]n17.east){首都};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n11.south){S-CIT};
\node[lab,anchor=north] at ([yshift=-0.8em,xshift=0.2em]n12.south){O};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n13.south){B-CNT};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n14.south){I-CNT};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n15.south){I-CNT};
\node[lab,anchor=north] at ([yshift=-1.4em,xshift=0.2em]n16.south){E-CNT};
\node[lab,anchor=north] at ([yshift=-0.8em,xshift=0.2em]n17.south){O};
\node[lab,anchor=north] at ([yshift=-0.8em,xshift=0.2em]n18.south){O};
\end{tikzpicture}
\ No newline at end of file
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\vspace{0.3em}
\begin{tikzpicture}
\begin{scope}
\node [] (input) at (-0.6em,0) {{\scriptsize 猫喜欢吃鱼}};
\node [] (output) at ([xshift=3.35in]input.east) {{\scriptsize Cats like eating fish}};
\draw[->,thick] ([xshift=-1pt]input.east) -- ([xshift=8pt]input.east);
\draw[->,thick] ([xshift=-6pt]output.west) -- ([xshift=2pt]output.west);
%{
%\draw[->,thick] ([xshift=-12pt]mtengine.west) -- ([xshift=-2pt]mtengine.west);
%\draw[->,thick] ([xshift=2pt]mtengine.east) -- ([xshift=12pt]mtengine.east);
%}
{
\node[minimum height=4em,minimum width=4.5em,fill=white] (inputmarking) at (0.88in,-0.39in) {};
\node[minimum height=4em,minimum width=5.2em,fill=white] (outputmarking) at (2.57in,-0.39in) {};
}
\node [anchor=south] (inputlabel) at ([yshift=-0.5em]input.north) {{\scriptsize \color{red}{\textbf{输入}}}};
\node [anchor=south] (outputlabel) at ([yshift=-0.5em]output.north) {{\scriptsize \color{red}{\textbf{输出}}}};
{
\node [anchor=west] (mtinputlabel) at ([xshift=0.35in]inputlabel.east) {{\scriptsize \color{red}{\textbf{}}}};
\node [anchor=west] (mtoutputlabel) at ([xshift=0.88in]mtinputlabel.east) {{\scriptsize \color{red}{\textbf{}}}};
\node[rectangle,draw=ublue, inner sep=0mm] [fit = (mtinputlabel) (mtoutputlabel) (inputmarking) (outputmarking)] {};
}
{
\node[rectangle,fill=ublue,inner sep=2pt] [fit = (mtinputlabel) (mtoutputlabel) (inputmarking) (outputmarking)] {{\color{white} \textbf{\Large{MT 系统}}}};
}
%\begin{scope}[scale=0.9,xshift=1.2in,yshift=-1.2in,level distance=20pt,sibling distance=0pt]
%
%\end{scope}
\end{scope}
\end{tikzpicture}
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\vspace{0.3em}
\begin{tikzpicture}
\begin{scope}
\node [] (input) at (-0.6em,0) {{\scriptsize 猫喜欢吃鱼}};
{
\begin{scope}[scale=0.8,xshift=0.9in,yshift=-0.87in,level distance=20pt,sibling distance=-1pt,grow'=up]
{\scriptsize
\Tree[.\node(sn0){IP};
[.\node(sn1){NP};
[.\node(sn2){NN}; \node(sw1){}; ]
]
[.\node(sn3){VP};
[.\node(sn4){VV}; \node(sw2){喜欢}; ]
[.\node(sn5){VP}; \edge[roof]; \node(sw3){\ }; ]
]
]
}
\end{scope}
\node [anchor=west,draw,thick,inner sep=3pt,ublue] (mtengine) at ([xshift=1.05in]input.east) {{\scriptsize MT系统}};
\begin{scope}[scale=0.8,xshift=3.0in,yshift=-0.87in,level distance=20pt,sibling distance=-3pt,grow'=up]
{\scriptsize
\Tree[.\node(tn0){S};
[.\node(tn1){NP};
[.\node(tn2){NNS}; \node(tw1){cats}; ]
]
[.\node(tn3){VP};
[.\node(tn4){VB}; \node(tw2){like}; ]
[.\node(tn5){VP}; \edge[roof]; \node(tw3){eating fish}; ]
]
]
}
\end{scope}
}
\node [] (output) at ([xshift=3.35in]input.east) {{\scriptsize Cats like eating fish}};
\draw[->,thick] ([xshift=-1pt]input.east) -- ([xshift=8pt]input.east);
\draw[->,thick] ([xshift=-6pt]output.west) -- ([xshift=2pt]output.west);
{
\draw[->,thick] ([xshift=-12pt]mtengine.west) -- ([xshift=-2pt]mtengine.west);
\draw[->,thick] ([xshift=2pt]mtengine.east) -- ([xshift=12pt]mtengine.east);
}
{
\node[minimum height=4em,minimum width=4.5em] (inputmarking) at (0.85in,-0.39in) {};
\node[minimum height=4em,minimum width=5.2em] (outputmarking) at (2.55in,-0.39in) {};
}
\node [anchor=south] (inputlabel) at ([yshift=-0.5em]input.north) {{\scriptsize \color{red}{\textbf{输入}}}};
\node [anchor=south] (outputlabel) at ([yshift=-0.5em]output.north) {{\scriptsize \color{red}{\textbf{输出}}}};
{
\node [anchor=west] (mtinputlabel) at ([xshift=0.35in]inputlabel.east) {{\scriptsize \color{red}{\textbf{实际的输入}}}};
\node [anchor=west] (mtoutputlabel) at ([xshift=1.0in]mtinputlabel.east) {{\scriptsize \color{red}{\textbf{实际的输出}}}};
\node[rectangle,draw=ublue, inner sep=2pt] [fit = (mtinputlabel) (mtoutputlabel) (inputmarking) (outputmarking)] {};
}
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\tikzstyle{class} = [draw,inner sep=2pt,line width=1pt,align=center,drop shadow,fill=green!20,font=\footnotesize,minimum height=1.6em,minimum width=3.4em,rotate=-90]
\tikzstyle{word} = [draw,inner sep=2pt,line width=1pt,align=center,drop shadow,fill=red!30,font=\footnotesize,minimum height=1.4em,minimum width=1.6em]
\coordinate (o) at (0,0);
\node[anchor=west,class] (c1) at ([xshift=0em]o.east){B-CIT};
\node[anchor=west,class] (c2) at ([xshift=4em]o.east){O};
\node[anchor=west,class] (c3) at ([xshift=8em]o.east){B-CNT};
\node[anchor=west,class] (c4) at ([xshift=12em]o.east){I-CNT};
\node[anchor=west,class] (c5) at ([xshift=16em]o.east){I-CNT};
\node[anchor=west,class] (c6) at ([xshift=20em]o.east){I-CNT};
\node[anchor=west,class] (c7) at ([xshift=24em]o.east){O};
\node[anchor=west,class] (c8) at ([xshift=28em]o.east){O};
\node[anchor=north,word] (w1) at ([xshift=-0.8em,yshift=-4em]c1.north){北京};
\node[anchor=north,word] (w2) at ([xshift=-0.8em,yshift=-4em]c2.north){};
\node[anchor=north,word] (w3) at ([xshift=-0.8em,yshift=-4em]c3.north){中华};
\node[anchor=north,word] (w4) at ([xshift=-0.8em,yshift=-4em]c4.north){人民};
\node[anchor=north,word] (w5) at ([xshift=-0.8em,yshift=-4em]c5.north){共和};
\node[anchor=north,word] (w6) at ([xshift=-0.8em,yshift=-4em]c6.north){};
\node[anchor=north,word] (w7) at ([xshift=-0.8em,yshift=-4em]c7.north){};
\node[anchor=north,word] (w8) at ([xshift=-0.8em,yshift=-4em]c8.north){首都};
\draw[->,line width=1.4pt] (c1.north) -- (c2.south);
\draw[->,line width=1.4pt] (c2.north) -- (c3.south);
\draw[->,line width=1.4pt] (c3.north) -- (c4.south);
\draw[->,line width=1.4pt] (c4.north) -- (c5.south);
\draw[->,line width=1.4pt] (c5.north) -- (c6.south);
\draw[->,line width=1.4pt] (c6.north) -- (c7.south);
\draw[->,line width=1.4pt] (c7.north) -- (c8.south);
\draw[->,line width=1.4pt] (c1.east) -- (w1.north);
\draw[->,line width=1.4pt] (c2.east) -- (w2.north);
\draw[->,line width=1.4pt] (c3.east) -- (w3.north);
\draw[->,line width=1.4pt] (c4.east) -- (w4.north);
\draw[->,line width=1.4pt] (c5.east) -- (w5.north);
\draw[->,line width=1.4pt] (c6.east) -- (w6.north);
\draw[->,line width=1.4pt] (c7.east) -- (w7.north);
\draw[->,line width=1.4pt] (c8.east) -- (w8.north);
\end{tikzpicture}
\ No newline at end of file
%%% outline
%-------------------------------------------------------------------------
\begin{tabular}{l c c c}
&
\begin{tikzpicture}
\begin{scope}[sibling distance=-5pt, level distance=20pt]
{\footnotesize
\Tree[.IP
[.VP
[.VP
[.NN 猫 ]
[.VV 喜欢 ]
]
[.VV 吃 ]
]
[.NP
[.NN 鱼 ]
]
]
}
\end{scope}
\end{tikzpicture}
&
\begin{tikzpicture}
\begin{scope}[sibling distance=-5pt, level distance=20pt]
{\footnotesize
\Tree[.IP
[.NP
[.NN 猫 ]
]
[.VP
[.VV 喜欢 ]
[.VP
[.VV 吃 ]
[.NN 鱼 ]
]
]
]
}
\end{scope}
\end{tikzpicture}
&
\begin{tikzpicture}
\begin{scope}[sibling distance=-5pt, level distance=20pt]
{\footnotesize
\Tree[.IP
[.NP
[.NN 猫 ]
]
[.VP
[.VP
[.VV 喜欢 ]
[.VV 吃 ]
]
[.NP
[.NN 鱼 ]
]
]
]
}
\end{scope}
\end{tikzpicture}
\\
语言学家: & 不对 && 不对 \\
我们: & 似乎对了 & 比较肯定 & 不太可能 \\
分析器: & $\textrm{P}=0.2$ & $\textrm{P}=0.6$ & $\textrm{P}=0.1$
\end{tabular}
%---------------------------------------------------------------------
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
\begin{scope}[sibling distance=7pt,level distance=22pt]
\Tree[.\node[inner sep=1pt](sn0){IP\scriptsize{:句子}};
[.\node[inner sep=1pt](sn1){NP\scriptsize{:名}};
[.\node[inner sep=1pt](sn2){NN\tiny{:名词}}; \node(sw1){}; ]
]
[.\node[inner sep=1pt](sn3){VP\scriptsize{:动}};
[.\node[inner sep=1pt](sn4){VV\tiny{:动词}}; \node(sw2){喜欢}; ]
[.\node[inner sep=1pt](sn5){VP\scriptsize{:动}};
[.\node[inner sep=1pt](sn6){VV\tiny{:动词}}; \node(sw1){}; ]
[.\node[inner sep=1pt](sn7){NN\tiny{:名词}}; \node(sw1){}; ]
]
]
]
\Tree[.\node[inner sep=1pt](sn0){IP\scriptsize{:句子}};
[.\node[inner sep=1pt](sn1){NP\scriptsize{:名}};
[.\node[inner sep=1pt,fill=blue!20](sn2){NN\tiny{:名词}}; \node(sw1){}; ]
]
[.\node[inner sep=1pt](sn3){VP\scriptsize{:动}};
[.\node[inner sep=1pt,fill=blue!20](sn4){VV\tiny{:动词}}; \node(sw2){喜欢}; ]
[.\node[inner sep=1pt](sn5){VP\scriptsize{:动}};
[.\node[inner sep=1pt,fill=blue!20](sn6){VV\tiny{:动词}}; \node(sw1){}; ]
[.\node[inner sep=1pt,fill=blue!20](sn7){NN\tiny{:名词}}; \node(sw1){}; ]
]
]
]
\Tree[.\node[inner sep=1pt,fill=red!20](sn0){IP\scriptsize{:句子}};
[.\node[inner sep=1pt,fill=red!20](sn1){NP\scriptsize{:名}};
[.\node[inner sep=1pt,fill=blue!20](sn2){NN\tiny{:名词}}; \node(sw1){}; ]
]
[.\node[inner sep=1pt,fill=red!20](sn3){VP\scriptsize{:动}};
[.\node[inner sep=1pt,fill=blue!20](sn4){VV\tiny{:动词}}; \node(sw2){喜欢}; ]
[.\node[inner sep=1pt](sn5){VP\scriptsize{:动}};
[.\node[inner sep=1pt,fill=blue!20](sn6){VV\tiny{:动词}}; \node(sw1){}; ]
[.\node[inner sep=1pt,fill=blue!20](sn7){NN\tiny{:名词}}; \node(sw1){}; ]
]
]
]
\Tree[.\node[inner sep=1pt,fill=red!20](sn0){IP\scriptsize{:句子}};
[.\node[inner sep=1pt,fill=red!20](sn1){NP\scriptsize{:名}};
[.\node[inner sep=1pt,fill=blue!20](sn2){NN\tiny{:名词}}; \node(sw1){}; ]
]
[.\node[inner sep=1pt,fill=red!20](sn3){VP\scriptsize{:动}};
[.\node[inner sep=1pt,fill=blue!20](sn4){VV\tiny{:动词}}; \node(sw2){喜欢}; ]
[.\node[inner sep=1pt,fill=green!20](sn5){VP\scriptsize{:动}};
[.\node[inner sep=1pt,fill=green!20](sn6){VV\tiny{:动词}}; \node(sw1){}; ]
[.\node[inner sep=1pt,fill=green!20](sn7){NN\tiny{:名词}}; \node(sw1){}; ]
]
]
]
\end{scope}
\begin{scope}[xshift=1.7in,yshift=-0.4in]
\node [,inner sep=2pt] (w1) at (0,0) {};
\node [anchor=west,inner sep=2pt] (w2) at ([xshift=0.8em,yshift=3em]w1.east) {喜欢};
\node [anchor=west,inner sep=2pt] (w3) at ([xshift=4.5em]w1.east) {};
\node [anchor=west,inner sep=2pt] (w4) at ([xshift=2em,yshift=-3em]w3.east) {};
\draw [-,ultra thick,ublue] (w1.north east) -- (w2.south) node [pos=0.3, above, xshift=-0.5em] {\color{red}{\tiny{主谓}}};
\draw [-,ultra thick,red] (w3.north west) -- (w2.south) node [pos=0.3, above, xshift=0.5em] {\color{red}{\tiny{连动}}};
\draw [-,ultra thick,ugreen] (w3.south east) -- (w4.north west) node [pos=0.5, above, xshift=0.5em] {\color{red}{\tiny{谓宾}}};
\end{scope}
\end{tikzpicture}
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
\begin{scope}
\node [] (sent) at (0,0) {\textbf{猫 喜欢 吃 鱼}};
\end{scope}
\begin{scope}[xshift=-8em,yshift=-9em,sibling distance=-5pt,level distance=17pt,grow'=up]
{\footnotesize
\Tree[.IP
[.VP
[.VP
[.NN 猫 ]
[.VV 喜欢 ]
]
[.VV 吃 ]
]
[.NP
[.NN 鱼 ]
]
]
}
\end{scope}
\begin{scope}[xshift=-1em,yshift=-9em,sibling distance=-5pt,level distance=17pt,grow'=up]
{\footnotesize
\Tree[.IP
[.NP
[.NN 猫 ]
]
[.VP
[.VV 喜欢 ]
[.VP
[.VV 吃 ]
[.NN 鱼 ]
]
]
]
}
\end{scope}
\begin{scope}[xshift=8em,yshift=-9em,sibling distance=-5pt, level distance=17pt,grow'=up]
{\footnotesize
\Tree[.IP
[.NP
[.NN 猫 ]
]
[.VP
[.VP
[.VV 喜欢 ]
[.VV 吃 ]
]
[.NP
[.NN 鱼 ]
]
]
]
}
\end{scope}
\draw [->,thick,ublue] ([xshift=-2em]sent.south) ..controls + (south:2em) and +(north:2em).. ([xshift=-8em,yshift=-2em]sent.south);
\draw [->,thick,ublue] ([xshift=-1em]sent.south) ..controls + (south:2em) and +(north:2em).. ([xshift=-2em,yshift=-2em]sent.south);
\draw [->,thick,ublue] ([xshift=0em]sent.south) ..controls + (south:2em) and +(north:2em).. ([xshift=6.5em,yshift=-2em]sent.south);
\draw [->,thick,ublue,dotted] ([xshift=1em]sent.south) ..controls + (south:1.5em) and +(north:2.5em).. ([xshift=12.5em,yshift=-2em]sent.south);
\node [anchor=north west] (others) at (11.8em,-3em) {...};
\node [] (d1) at (-9em,-10em) {$d_1$};
\node [] (d2) at (0em,-10em) {$d_2$};
\node [] (d3) at (8.5em,-10em) {$d_2$};
\node [anchor=east] (d1p) at ([xshift=0.4em]d1.west) {$\textrm{P}($};
\node [anchor=west] (d1p2) at ([xshift=-0.4em]d1.east) {$)=0.0123$};
\node [anchor=east] (d2p) at ([xshift=0.4em]d2.west) {$\textrm{P}($};
\node [anchor=west] (d2p2) at ([xshift=-0.4em]d2.east) {$)=0.4031$};
\node [anchor=east] (d3p) at ([xshift=0.4em]d3.west) {$\textrm{P}($};
\node [anchor=west] (d3p2) at ([xshift=-0.4em]d3.east) {$)=0.0056$};
\end{tikzpicture}
%---------------------------------------------------------------------
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
{\scriptsize
\begin{scope}[level distance=10pt,xshift=1.5em,yshift=-0.5em]
{\tiny
\Tree[.\node[inner sep=1pt](t1n1){IP};
[.\node[inner sep=1pt](t1n2){VP};
[.\node[inner sep=1pt](t1n3){VV}; \node[](t1w1){}; ]
]
[.\node[inner sep=1pt](t1n4){NP};
[.\node[inner sep=1pt](t1n5){M}; 个 ]
[.\node[inner sep=1pt](t1n6){NN}; 例子 ]
]
]
}
\end{scope}
\begin{scope}[level distance=10pt,xshift=6.5em,yshift=-0.5em]
{\tiny
\Tree[.\node[inner sep=1pt](t2n1){IP};
[.\node[inner sep=1pt](t2n2){NP};
[.\node[inner sep=1pt](t2n3){PN}; 你 ]
]
[.\node[inner sep=1pt](t2n4){VP};
[.\node[inner sep=1pt](t2n5){VV}; 看到 ]
[.\node[inner sep=1pt](t2n6){AS}; \node[](t2wn){}; ]
]
]
}
\end{scope}
\node [anchor=west] (othertrees) at ([xshift=1em]t2n1.east) {...};
\node [anchor=south west] (corpuslabel) at ([xshift=-1em]t1n1.north west) {{\color{ublue} \textbf{学习用数据}}};
\begin{pgfonlayer}{background}
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (t1n1) (t1w1) (t2wn) (othertrees) (corpuslabel)] (corpus) {};
\end{pgfonlayer}
}
\node [anchor=west,ugreen] (P) at ([xshift=5.95em,yshift=-0.8em]corpus.east){\large{P($\cdot$)}};
\node [anchor=south] (modellabel) at (P.north) {{\color{ublue} {\scriptsize \textbf{统计分析模型}}}};
\begin{pgfonlayer}{background}
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (P) (modellabel)] (model) {};
\end{pgfonlayer}
\draw [->,very thick,ublue] ([xshift=0.2em]corpus.east) -- ([xshift=4.2em]corpus.east) node [pos=0.5, above] {\color{red}{\scriptsize{统计学习}}};
\draw [->,very thick,ublue] ([xshift=0.2em]model.east) -- ([xshift=4.2em]model.east) node [pos=0.5, above] {\color{red}{\scriptsize{预测}}};
{\scriptsize
\node [anchor=north west] (sentlabel) at ([xshift=6.2em,yshift=-1em]model.north east) {{\color{ublue} {\scriptsize \textbf{统计分析模型}}}};
\node [anchor=north west] (sent) at (sentlabel.south west) {\textbf{对任意句子进行分析}};
}
\begin{pgfonlayer}{background}
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (sentlabel) (sent)] (parser) {};
\end{pgfonlayer}
\end{tikzpicture}
%---------------------------------------------------------------------
\begin{tikzpicture}
\tikzstyle{unit} = [draw,minimum size=1em,circle]
\node[unit,fill=ugreen!20] (g1) at (0,0){};
\node[anchor=west,unit,fill=ugreen!20] (g2)at([xshift=1.8em]g1.east){};
\node[anchor=west,unit,fill=ugreen!20] (g3)at([xshift=1.8em]g2.east){};
\node[anchor=west,unit,fill=ugreen!20] (g4)at([xshift=1.8em]g3.east){};
\node[anchor=north,unit,fill=red!30] (r1)at([yshift=-4em]g1.south){};
\node[anchor=north,unit,fill=red!30] (r2)at([yshift=-4em]g2.south){};
\node[anchor=north,unit,fill=red!30] (r3)at([yshift=-4em]g3.south){};
\node[anchor=north,unit,fill=red!30] (r4)at([yshift=-4em]g4.south){};
\begin{pgfonlayer}{background}
\node [draw=ugreen!70,rectangle,inner sep=2pt,rounded corners=4pt,dashed,line width=1.0pt] [fit = (g1)(g2)(g3)(g4)] (box1) {};
\node [draw=red!70,rectangle,inner sep=2pt,rounded corners=4pt,dashed,line width=1.0pt] [fit = (r1)(r2)(r3)(r4)] (box2) {};
\end{pgfonlayer}
\node[anchor=north,draw,inner sep=2pt,rounded corners=2pt,fill=blue!30,minimum width=6em](cla) at ([yshift=-1em]box1.south){分类器};
\node[anchor=south,font=\scriptsize] at ([yshift=0.4em,xshift=1.4em]g2.north){待预测标签序列};
\node[anchor=north,font=\scriptsize] at ([yshift=-0.4em,xshift=1.4em]r2.south){观测序列};
\draw[->,thick] (cla.north) -- (box1.south);
\draw[->,thick] (box2.north) -- (cla.south);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [draw,minimum size=1em,circle]
\node[unit,fill=ugreen!20] (g1) at (0,0){};
\node[anchor=west,unit,fill=ugreen!20] (g2)at([xshift=1.8em]g1.east){};
\node[anchor=west,unit,fill=ugreen!20] (g3)at([xshift=1.8em]g2.east){};
\node[anchor=west,unit,fill=ugreen!20] (g4)at([xshift=1.8em]g3.east){};
\node[anchor=north,unit,fill=red!30] (r1)at([yshift=-1.8em,xshift=1.4em]g2.south){};
\node[anchor=south,font=\scriptsize] at ([yshift=0.4em,xshift=1.4em]g2.north){待预测标签序列};
\node[anchor=north,font=\scriptsize] at ([yshift=-0.4em]r1.south){观测序列};
\draw[-,thick] (g1.east) -- (g2.west);
\draw[-,thick] (g2.east) -- (g3.west);
\draw[-,thick] (g3.east) -- (g4.west);
\draw[-,thick] (g1.south) -- (r1.north);
\draw[-,thick] (g2.south) -- (r1.north);
\draw[-,thick] (g3.south) -- (r1.north);
\draw[-,thick] (g4.south) -- (r1.north);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [draw,minimum size=1em,circle]
\node[unit,fill=ugreen!20] (g1) at (0,0){};
\node[anchor=west,unit,fill=ugreen!20] (g2)at([xshift=1.8em]g1.east){};
\node[anchor=west,unit,fill=ugreen!20] (g3)at([xshift=1.8em]g2.east){};
\node[anchor=west,unit,fill=ugreen!20] (g4)at([xshift=1.8em]g3.east){};
\node[anchor=north,unit,fill=red!30] (r1)at([yshift=-1.8em]g1.south){};
\node[anchor=north,unit,fill=red!30] (r2)at([yshift=-1.8em]g2.south){};
\node[anchor=north,unit,fill=red!30] (r3)at([yshift=-1.8em]g3.south){};
\node[anchor=north,unit,fill=red!30] (r4)at([yshift=-1.8em]g4.south){};
\node[anchor=south,font=\scriptsize] at ([yshift=0.4em,xshift=1.4em]g2.north){待预测标签序列};
\node[anchor=north,font=\scriptsize] at ([yshift=-0.4em,xshift=1.4em]r2.south){观测序列};
\draw[->,thick] (g1.east) -- (g2.west);
\draw[->,thick] (g2.east) -- (g3.west);
\draw[->,thick] (g3.east) -- (g4.west);
\draw[->,thick] (g1.south) -- (r1.north);
\draw[->,thick] (g2.south) -- (r2.north);
\draw[->,thick] (g3.south) -- (r3.north);
\draw[->,thick] (g4.south) -- (r4.north);
\end{tikzpicture}
\ No newline at end of file
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
\small
\node [anchor=west,inner sep=2pt] (r1) at (0,0) {$r_1$: NN $\to$};
\node [anchor=west,inner sep=2pt] (r2) at ([xshift=6em]r1.east) {$r_2$: VV $\to$ 喜欢};
\node [anchor=north west,inner sep=2pt] (r3) at ([yshift=-0.2em]r1.south west) {$r_3$: VV $\to$};
\node [anchor=north west,inner sep=2pt] (r4) at ([yshift=-0.2em]r2.south west) {$r_4$: NN $\to$};
\node [anchor=north west,inner sep=2pt] (r5) at ([yshift=-0.2em]r3.south west) {$r_5$: NP $\to$ NN};
\node [anchor=north west,inner sep=2pt] (r6) at ([yshift=-0.2em]r4.south west) {$r_6$: VP $\to$ VV NN};
\node [anchor=north west,inner sep=2pt] (r7) at ([yshift=-0.2em]r5.south west) {$r_7$: VP $\to$ VV VP};
\node [anchor=north west,inner sep=2pt] (r8) at ([yshift=-0.2em]r6.south west) {$r_8$: IP $\to$ NP VP};
\node [anchor=west,inner sep=2pt,fill=blue!20] (r1) at (0,0) {$r_1$: NN $\to$};
\node [anchor=west,inner sep=2pt,fill=blue!20] (r2) at ([xshift=6em]r1.east) {$r_2$: VV $\to$ 喜欢};
\node [anchor=north west,inner sep=2pt,fill=blue!20] (r3) at ([yshift=-0.2em]r1.south west) {$r_3$: VV $\to$};
\node [anchor=north west,inner sep=2pt,fill=blue!20] (r4) at ([yshift=-0.2em]r2.south west) {$r_4$: NN $\to$};
\node [anchor=north west,inner sep=2pt,fill=red!20] (r5) at ([yshift=-0.2em]r3.south west) {$r_5$: NP $\to$ NN};
\node [anchor=north west,inner sep=2pt,fill=green!20] (r6) at ([yshift=-0.2em]r4.south west) {$r_6$: VP $\to$ VV NN};
\node [anchor=north west,inner sep=2pt,fill=green!20] (r7) at ([yshift=-0.2em]r5.south west) {$r_7$: VP $\to$ VV VP};
\node [anchor=north west,inner sep=2pt,fill=green!20] (r8) at ([yshift=-0.2em]r6.south west) {$r_8$: IP $\to$ NP VP};
\node [anchor=north west,fill=blue!20] (sent1) at ([yshift=-0.4em]r7.south west) {$r_1,r_2,r_3,r_4$};
\node [anchor=west] (sent1part2) at (sent1.east) {为生成单词词性的规则};
\node [anchor=north west,fill=red!20] (sent2) at ([yshift=-0.2em]sent1.south west) {$r_5$};
\node [anchor=west] (sent2part2) at (sent2.east) {为单变量规则,它将词性NN进一步抽象为名词短语NP};
\node [anchor=north west,fill=green!20] (sent3) at ([yshift=-0.2em]sent2.south west){$r_6,r_7,r_8$};
\node [anchor=west] (sent3part2) at (sent3.east) {为句法结构规则,比如$r_8$表示了主(NP)+谓(VP)结构};
\end{tikzpicture}
%---------------------------------------------------------------------
\begin{tikzpicture}
\begin{scope}
\node[minimum width=3em,minimum height=1.5em] (o) at (0,0){};
\node[anchor=west,inner sep=0pt] (ca) at ([yshift=0.2em,xshift=1.4em]o.east){\scriptsize\bfnew{硬币A}};
\node[anchor=west,inner sep=0pt] (cb) at ([xshift=1.4em]ca.east){\scriptsize\bfnew{硬币B}};
\node[anchor=west,inner sep=0pt] (cc) at ([xshift=1.4em]cb.east){\scriptsize\bfnew{硬币C}};
\node[anchor=north,inner sep=0pt] (ra) at ([yshift=-0.6em,xshift=-0.4em]o.south){\scriptsize\bfnew{硬币A}};
\node[anchor=north,inner sep=0pt] (rb) at ([yshift=-1.4em]ra.south){\scriptsize\bfnew{硬币B}};
\node[anchor=north,inner sep=0pt] (rc) at ([yshift=-1.4em]rb.south){\scriptsize\bfnew{硬币C}};
\node[anchor=north,inner sep=0pt] (n11) at ([yshift=-0.9em]ca.south){\small{$\frac{1}{3}$}};
\node[anchor=north,inner sep=0pt] (n21) at ([yshift=-1em]n11.south){\small{$\frac{1}{3}$}};
\node[anchor=north,inner sep=0pt] (n31) at ([yshift=-1em]n21.south){\small{$\frac{1}{3}$}};
\node[anchor=north,inner sep=0pt] (n12) at ([yshift=-0.9em]cb.south){\small{$\frac{1}{3}$}};
\node[anchor=north,inner sep=0pt] (n22) at ([yshift=-1em]n12.south){\small{$\frac{1}{3}$}};
\node[anchor=north,inner sep=0pt] (n32) at ([yshift=-1em]n22.south){\small{$\frac{1}{3}$}};
\node[anchor=north,inner sep=0pt] (n13) at ([yshift=-0.9em]cc.south){\small{$\frac{1}{3}$}};
\node[anchor=north,inner sep=0pt] (n23) at ([yshift=-1em]n13.south){\small{$\frac{1}{3}$}};
\node[anchor=north,inner sep=0pt] (n33) at ([yshift=-1em]n23.south){\small{$\frac{1}{3}$}};
\draw[thick] (o.north west) -- (o.south east);
\node[anchor=south west] at ([yshift=-1em,xshift=-1.4em]o.45){\tiny{$i+1$}};
\node[anchor=north east] at ([yshift=1em,xshift=1em]o.-135){\tiny{$i$}};
\begin{pgfonlayer}{background}
\node [rectangle,inner sep=0.5em,rounded corners=2pt,fill=red!10] [fit = (o)(n33)(cc) ] (box0) {};
\end{pgfonlayer}
\node[anchor=south] at (box0.north){\scriptsize{转移概率$\funp{P}$(第$i+1$次|第$i$次)}};
\end{scope}
\begin{scope}[xshift=8cm]
\node[minimum width=3em,minimum height=1.5em] (o) at (0,0){};
\node[anchor=west,inner sep=0pt] (ca) at ([yshift=0.2em,xshift=1.4em]o.east){\scriptsize\bfnew{正面}};
\node[anchor=west,inner sep=0pt] (cb) at ([xshift=1.4em]ca.east){\scriptsize\bfnew{反面}};
\node[anchor=north,inner sep=0pt] (ra) at ([yshift=-0.6em,xshift=-0.4em]o.south){\scriptsize\bfnew{硬币A}};
\node[anchor=north,inner sep=0pt] (rb) at ([yshift=-1.5em]ra.south){\scriptsize\bfnew{硬币B}};
\node[anchor=north,inner sep=0pt] (rc) at ([yshift=-1.5em]rb.south){\scriptsize\bfnew{硬币C}};
\node[anchor=north,inner sep=0pt] (n11) at ([yshift=-1.2em]ca.south){\footnotesize{$0.3$}};
\node[anchor=north,inner sep=0pt] (n21) at ([yshift=-1.7em]n11.south){\footnotesize{$0.5$}};
\node[anchor=north,inner sep=0pt] (n31) at ([yshift=-1.7em]n21.south){\footnotesize{$0.7$}};
\node[anchor=north,inner sep=0pt] (n12) at ([yshift=-1.2em]cb.south){\footnotesize{$0.7$}};
\node[anchor=north,inner sep=0pt] (n22) at ([yshift=-1.7em]n12.south){\footnotesize{$0.5$}};
\node[anchor=north,inner sep=0pt] (n32) at ([yshift=-1.7em]n22.south){\footnotesize{$0.3$}};
\draw[thick] (o.north west) -- (o.south east);
\node[anchor=south west] at ([yshift=-1em,xshift=-1.4em]o.45){\tiny{可见}};
\node[anchor=north east] at ([yshift=1em,xshift=1em]o.-135){\tiny{隐藏}};
\begin{pgfonlayer}{background}
\node [rectangle,inner sep=0.5em,rounded corners=2pt,fill=red!10] [fit = (o)(n32)(rc)(cb) ] (box1) {};
\end{pgfonlayer}
\node[anchor=south] at (box1.north){\scriptsize{发射概率$\funp{P}$(可见状态|隐藏状态)}};
\end{scope}
\end{tikzpicture}
\ No newline at end of file
%%% outline
%-------------------------------------------------------------------------
\begin{minipage}[t]{0.32\linewidth}
\vspace{1.5em}
\begin{tikzpicture}
\begin{scope}[sibling distance=3pt, level distance=25pt]
{\small
\Tree[.IP
[.NP
[.NN \node(sw1){}; ]
]
[.VP
[.VV \node(sw2){喜欢}; ]
[.VP
[.VV \node(sw1){}; ]
[.NN \node(sw1){}; ]
]
]
]
}
\end{scope}
\end{tikzpicture}
\end{minipage}
\hfill
\begin{minipage}[t]{0.32\linewidth}
{\small
\begin{eqnarray}
& & \textrm{\textbf{推导1}} \nonumber \\
& & \textrm{IP} \nonumber \\
& \overset{r_8}{\Rightarrow} & \textrm{NP VP} \nonumber \\
& \overset{r_5}{\Rightarrow} & \textrm{NN VP} \nonumber \\
& \overset{r_1}{\Rightarrow} & \textrm{猫 VP} \nonumber \\
& \overset{r_7}{\Rightarrow} & \textrm{猫 VV VP} \nonumber \\
& \overset{r_2}{\Rightarrow} & \textrm{猫 喜欢 VP} \nonumber \\
& \overset{r_6}{\Rightarrow} & \textrm{猫 喜欢 VV NN} \nonumber \\
& \overset{r_3}{\Rightarrow} & \textrm{猫 喜欢 吃 NN} \nonumber \\
& \overset{r_4}{\Rightarrow} & \textrm{猫 喜欢 吃 鱼} \nonumber
\end{eqnarray}
}
\end{minipage}
\hfill
\begin{minipage}[t]{0.32\linewidth}
{\small
\begin{eqnarray}
& & \textrm{\textbf{推导2}} \nonumber \\
& & \textrm{IP} \nonumber \\
& \overset{r_8}{\Rightarrow} & \textrm{NP VP} \nonumber \\
& \overset{r_7}{\Rightarrow} & \textrm{NP VV VP} \nonumber \\
& \overset{r_2}{\Rightarrow} & \textrm{NP 喜欢 VP} \nonumber \\
& \overset{r_6}{\Rightarrow} & \textrm{NP 喜欢 VV NN} \nonumber \\
& \overset{r_4}{\Rightarrow} & \textrm{NP 喜欢 VV 鱼} \nonumber \\
& \overset{r_5}{\Rightarrow} & \textrm{NN 喜欢 VV 鱼} \nonumber \\
& \overset{r_3}{\Rightarrow} & \textrm{NN 喜欢 吃 鱼} \nonumber \\
& \overset{r_1}{\Rightarrow} & \textrm{猫 喜欢 吃 鱼} \nonumber
\end{eqnarray}
}
\end{minipage}
%---------------------------------------------------------------------
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
\begin{scope}
\node [anchor=west] (arule) at (0,0) {\large{$u \overset{r}{\Rightarrow} v$}};
\node [anchor=west,inner sep=2pt] (u) at ([xshift=-4em,yshift=-4em]arule.west) {VV};
\node [anchor=west,inner sep=2pt,fill=orange!40] (u) at ([xshift=-4em,yshift=-4em]arule.west) {VV};
\node [anchor=west] (upart2) at (u.east) {NN};
\node [anchor=east] (unumber) at (u.west) {$u:$};
\node [anchor=west,inner sep=2pt] (r) at ([xshift=-3em,yshift=2.5em]u.west) {VV};
\node [anchor=west,inner sep=2pt,fill=orange!40] (r) at ([xshift=-3em,yshift=2.5em]u.west) {VV};
\node [anchor=west] (rpart2) at (r.east) {$\to$};
\node [anchor=west,inner sep=2pt] (rpart3) at (rpart2.east) {};
\node [anchor=east] (rnumber) at (r.west) {$r:$};
\node [anchor=west,inner sep=2pt,fill=red!20] (rpart3) at (rpart2.east) {};
\node [anchor=west] (v) at ([xshift=5.5em]u.east) {$v$:};
\node [anchor=west,inner sep=2pt,fill=red!20] (vpart2) at (v.east) {};
\node [anchor=west] (vpart3) at (vpart2.east) {NN};
\node [anchor=west] (arrow) at ([xshift=3em]u.east) {$\Rightarrow$};
\draw [<-,dotted,thick] ([xshift=0.6em]arule.south west) ..controls +(south:0.7) and +(north:0.7).. ([xshift=-1.0em]upart2.north east);
\draw [<-,dotted,thick] ([xshift=-0.6em]arule.south east) ..controls +(south:0.7) and +(north:0.7).. ([xshift=1.0em]v.north west);
\draw [<-,dotted,thick] ([xshift=-0.4em,yshift=-0.5em]arule.north) ..controls +(180:0.7) and +(50:0.7) .. ([xshift=1em]rpart2.north west);
\draw [->,dotted,thick,ublue] (r.south) ..controls +(south:0.5) and +(north:0.5).. ([yshift=0]u.north);
\end{scope}
\end{tikzpicture}
%---------------------------------------------------------------------
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
\vspace{-0.5em}
\begin{tikzpicture}
{\scriptsize
{
\node [anchor=north west] (entry1) at (0,0) {\textbf{1:} 这 / 是 / 数据};
\node [anchor=north west] (entry2) at ([yshift=0.1em]entry1.south west) {\textbf{2:} 现在 / 已经 / 实现};
\node [anchor=north west] (entry3) at ([yshift=0.1em]entry2.south west) {\textbf{3:} 确实 / 有 / 很 / 多};
\node [anchor=north west] (entry4) at ([yshift=0.1em]entry3.south west) {...};
\node [anchor=south west] (corpuslabel) at (entry1.north west) {{\color{ublue} \textbf{学习用数据}}};
}
\begin{pgfonlayer}{background}
{
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (entry1) (entry2) (entry3) (entry4) (corpuslabel)] (corpus) {};
}
\end{pgfonlayer}
}
{
\node [anchor=west,ugreen] (P) at ([xshift=5.2em,yshift=-0.8em]corpus.east){\large{\funp{P}($\cdot$)}};
\node [anchor=south] (modellabel) at (P.north) {{\color{ublue} {\scriptsize \textbf{统计模型}}}};
}
\begin{pgfonlayer}{background}
{
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (P) (modellabel)] (model) {};
}
\end{pgfonlayer}
{
\draw [->,very thick,ublue] ([xshift=0.2em]corpus.east) -- ([xshift=4.2em]corpus.east) node [pos=0.5, above] {\color{red}{\scriptsize{统计学习}}};
}
{
\draw [->,very thick,ublue] ([xshift=0.2em]model.east) -- ([xshift=4.2em]model.east) node [pos=0.5, above] {\color{red}{\scriptsize{推断}}};
}
{\scriptsize
{
\node [anchor=north west] (sentlabel) at ([xshift=6.8em,yshift=2em]model.north east) {\color{red}{新的句子}};
\node [anchor=north west] (sent) at (sentlabel.south west) {\textbf{确实现在数据很多}};
}
{
\node [anchor=north west] (seg1) at ([xshift=1.0em]sent.south west) {确/实现/在/数/据很/多};
\node [anchor=north west] (seg2) at (seg1.south west) {确实/现在/数据/很/多};
\node [anchor=north west] (seg3) at (seg2.south west) {确实/现在/数/据/很/多};
}
{
\node [anchor=north west] (seg4) at ([xshift=-1.0em,yshift=0.4em]seg3.south west) {...};
\node [anchor=east,ugreen] (p1seg1) at ([xshift=0.5em]seg1.west) {P(};
\node [anchor=west,ugreen] (p2seg1) at ([xshift=-0.5em]seg1.east) {)=0.1};
\node [anchor=east,ugreen] (p1seg2) at ([xshift=0.5em]seg2.west) {P(};
\node [anchor=west,ugreen] (p2seg2) at ([xshift=-0.5em]seg2.east) {)=0.6};
\node [anchor=east,ugreen] (p1seg3) at ([xshift=0.5em]seg3.west) {P(};
\node [anchor=west,ugreen] (p2seg3) at ([xshift=-0.5em]seg3.east) {)=0.2};
}
{
\node [anchor=east,draw,dashed,red,thick,minimum width=13em,minimum height=1.4em] (final) at (p2seg2.east) {};
\node [anchor=west,red] (finallabel) at ([xshift=3.1em]sentlabel.east) {输出概率最大的结果};
%\node [anchor=north east,red] (finallabel2) at ([yshift=0.5em]finallabel.south east) {的结果};
\draw [->,thick,red] ([xshift=0.0em,yshift=-0.5em]final.north east) ..controls +(east:0.2) and +(south:1.0).. ([xshift=2.0em]finallabel.south);
}
}
\end{tikzpicture}
%---------------------------------------------------------------------
......@@ -15,16 +15,875 @@
\renewcommand\figurename{}%将figure改为图
\renewcommand\tablename{}%将figure改为图
\chapterimage{fig-NEU-3.jpg} % Chapter heading image
%----------------------------------------------------------------------------------------
% CHAPTER 3
%----------------------------------------------------------------------------------------
\chapter{词法分析和语法分析基础}
\chapter{词法分析和语法分析}
\parinterval 机器翻译并非是一个孤立的系统,它依赖于很多模块,并且需要多个学科知识的融合。其中就会用到许多自然语言处理工具来对不同语言的文字进行分析。因此,在正式开始机器翻译内容的介绍之前,本章会对相关的词法分析和语法分析知识进行概述,包括:分词、命名实体识别、短语结构句法分析。它们都是自然语言处理中的经典问题,而且在机器翻译中被广泛使用。本章会重点介绍这些任务的定义和求解问题的思路。其中也会使用到统计建模方法,因此本章也可以被看作是第二章内容的延伸。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{}
\section{问题概述}
\parinterval 很多时候机器翻译系统被看作是孤立的``黑盒''系统(图\ref{fig:3.1-1}(a))。将一段文本作为输入送入机器翻译系统之后,系统输出翻译好的译文。但是真实的机器翻译系统非常复杂,因为系统看到的输入和输出实际上只是一些符号串,这些符号并没有任何意义,因此需要进一步对这些符号串进行处理才能更好的使用它们。比如,需要定义翻译中最基本的单元是什么?符号串是否具有结构信息?如何用数学工具刻画这些基本单元和结构?
%----------------------------------------------
\begin{figure}[htp]
\centering
\subfigure[机器翻译系统被看作一个黑盒] {\input{./Chapter3/Figures/figure-mt-system-as-a-black-box} }
\subfigure[机器翻译系统 = 前/后处理 + 翻译引擎] {\input{./Chapter3/Figures/figure-mt=language-analysis+translation-engine}}
\caption{机器翻译系统的结构}
\label{fig:3.1-1}
\end{figure}
%-------------------------------------------
\parinterval\ref{fig:3.1-1}(b)展示了一个机器翻译系统的输入和输出形式。可以看到,输入的中文词串``猫喜欢吃鱼''被加工成一个新的结构(图\ref{fig:3.1-2})。直觉上,这个结构有些奇怪,因为上面多了很多新的符号,而且还有一些线将不同符号进行连接。实际上这就是一种常见的句法表示\ \dash \ 短语结构树。生成这样的结构会涉及两方面问题:
\begin{itemize}
\vspace{0.5em}
\item {\small\bfnew{分词}}\index{分词}(Segmentation)\index{Segmentation}:这个过程会把词串进行切分,切割成最小的具有完整功能的单元\ \dash\ {\small\bfnew{单词}}\index{单词}(Word\index{单词})。因为只有知道了什么是单词,机器翻译系统才能完成对句子的表示、分析和生成。
\vspace{0.5em}
\item {\small\bfnew{句法分析}}\index{句法分析}(Parsing)\index{Parsing}:这个过程会对分词的结果进行进一步分析。比如,可以对句子进行浅层分析,得到句子中实体的信息(如人名、地名等)。也可以对句子进行更深层次的分析,得到完整的句法结构,类似于图\ref{fig:3.1-2}中的结果。这种结构可以被看作是对句子的进一步抽象,被称为短语结构树,比如,NP+VP就可以表示由名词短语(Noun Phrase,NP)和动词短语(Verb Phrase,VP)构成的主谓结构。利用这些信息,机器翻译可以更加准确地对句子的结构进行分析和生成。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-analysis-of-sentence-participle&syntactic}
\caption{汉语句子``猫喜欢吃鱼''的分析结果(分词和句法分析)}
\label{fig:3.1-2}
\end{figure}
%-------------------------------------------
\parinterval 类似地,机器翻译输出的结果也可以包含同样的信息。甚至系统输出英语译文之后,还有一个额外的步骤来把部分英语单词的大小写恢复出来,比如,上例中句首单词``Cats''的首字母要大写。
\parinterval 一般来说,在送入机器翻译系统前需要对文字序列进行处理和加工,这个过程被称为{\small\bfnew{预处理}}\index{预处理}(Preprocessing)\index{Preprocessing}。类似地,在机器翻译模型输出译文后进行的处理被称作{\small\bfnew{后处理}}\index{后处理}(Postprocessing)\index{Postprocessing}。这两个过程对机器翻译性能影响很大,比如,对于神经机器翻译系统来说,不同的分词策略可能会造成翻译性能的天差地别。
\parinterval 值得注意的是,有些观点认为,对于机器翻译来说,不论是分词还是句法分析,并不要求符合人的认知和语言学约束。换句话说,机器翻译所使用的``单词''和``结构''本身并不是为了符合人类的解释,它们更直接目的是为了进行翻译。从系统开发的角度,有时候即使使用一些与人类的语言习惯有差别的处理,仍然会带来性能的提升,比如在神经机器翻译中,在传统分词的基础上进一步使用{\small\bfnew{双字节编码}}\index{双字节编码}(Byte Pair Encoding,BPE)\index{Byte Pair Encoding}子词切分会使得机器翻译性能大幅提高。当然,自然语言处理中语言学信息的使用一直是学界关注的焦点。甚至关于语言学结构对机器翻译是否有作用这个问题也有一些不同的观点。但是不能否认的是,无论是语言学的知识,还是计算机自己学习到的知识,对机器翻译都是有价值的。在后续章节会看到,这两种类型的知识对机器翻译帮助很大。
\parinterval 剩下的问题是如何进行句子的切分和结构的分析。思路有很多,一种常用的方法是对问题进行概率化,用统计模型来描述问题并求解之。比如,一个句子切分的好坏,并不是非零即一的判断,而是要估计出这种切分的可能性大小,最终选择可能性最大的结果进行输出。这也是一种典型的用统计建模的方式来描述自然语言处理问题的方法。
\parinterval 本章将会对上述问题及求解问题的方法进行介绍。并将统计建模应用到中文分词、命名实体识别和短语结构句法分析等任务中。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{中文分词}
\parinterval 对于机器翻译系统而言,输入的是已经切分好的单词序列,而不是原始的字符串(图\ref{fig:3.2-1})。比如,对于一个中文句子,单词之间是没有间隔的,因此需要把一个个的单词切分出来,这样机器翻译系统可以区分不同的翻译单元。甚至,可以对语言学上的单词进行进一步切分,得到词片段序列(比如:中国人$\to$中国/人)。广义上,可以把上述过程看作是一种分词过程,即:将一个输入的自然语言字符串切割成单元序列,每个{\small\bfnew{单元}}\index{单元}(Token\index{Token})都对应可以处理的最小单位。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-a-simple-pre-processing-process}
\caption{一个简单的预处理流程}
\label{fig:3.2-1}
\end{figure}
%-------------------------------------------
\parinterval 分词得到的单元序列可以是语言学上的词序列,也可以是根据其他方式定义的基本处理单元。在本章中,把分词得到的一个个单元称为{\small\bfnew{单词}}\index{单词}(Word)\index{Word}或词,尽管这些单元可以不是语言学上的完整单词。而这个过程也被称作{\small\bfnew{词法分析}}\index{词法分析}(Lexical Analysis)\index{Lexical Analysis}。除了汉语,词法分析在日语、泰语等单词之间无明确分割符的语言中有着广泛的应用,芬兰语、维吾尔语等一些形态学十分丰富的语言,也需要使用词法分析来解决复杂的词尾、词缀变化等形态学变化。
\parinterval 在机器翻译中,分词系统的好坏往往会决定译文的质量。分词的目的是定义系统处理的基本单元,那么什么叫做``词'' 呢?关于词的定义有很多,比如:
\vspace{0.5em}
\begin{definition}
\vspace{0.5em}
语言里最小的可以独立运用的单位。
\begin{flushright}——《新华字典》\end{flushright}
单词(word),含有语义内容或语用内容,且能被单独念出来的的最小单位。
\begin{flushright}——《维基百科》\end{flushright}
語句中具有完整概念,能獨立自由運用的基本單位。
\begin{flushright}——《国语辞典》\end{flushright}
\end{definition}
\parinterval 从语言学的角度来看,人们普遍认为词是可以单独运用的、包含意义的基本单位。这样可以使用有限的词组合出无限的句子,这也正体现出自然语言的奇妙之处。不过,机器翻译并不仅仅局限在语言学定义的单词。比如,神经机器翻译中广泛使用的BPE子词切分方法,可以被理解为将词的一部分也切分出来,也就是得到词片段送给机器翻译系统使用。比如,对如下英语字符串,可以得到切分结果:
\vspace{0.8em}
\noindent
\begin{tabular}{l l l}
Interesting \; $\to$ \; Interest/ing & selection $\to$ \;se/lect/ion & procession $\to$ \; pro/cess/ion \\
Interested $\to$ \; Interest/ed & selecting $\to$ \; se/lect/ing & processing $\to$ \; pro/cess/ing \\
Interests $\to$ \; Interest/s & selected $\to$ \; se/lect/ed & processed $\to$ \; pro/cess/ed
\end{tabular}
\vspace{0.8em}
\parinterval 词法分析的重要性在自然语言处理领域已经有共识。如果切分的颗粒度很大,获得的单词的歧义也很小,比如``中华人民共和国''整体作为一个单词不存在歧义,而如果单独的一个单词``国'',可能会代表``中国''、``美国''等不同的国家,存在歧义。但是随着切分颗粒度的增大,特定单词出现的频次也随之降低,低频词容易和噪音混淆,系统很难进行学习。因此,处理这些问题并开发适合翻译任务的分词系统是机器翻译的第一步。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{基于词典的分词方法}
\parinterval 计算机并不能像人类一样在概念上理解``词'',因此需要使用其他方式让计算机“学会”如何分词。一个最简单的方法就是给定一个词典,在这个词典中出现的汉字组合就是所定义的``词''。也就是,通过一个词典定义一个标准,符合这个标准定义的字符串都是合法的``词''。
\parinterval 在使用基于词典的分词方法时,只需预先加载词典到计算机中,扫描输入句子,查询每个词串是否出现在词典中。如图\ref{fig:3.2-2}所示,有一个包含六个词的词典,给定输入句子``确实现在物价很高''后,分词系统自左至右遍历输入句子的每个字,发现词串``确实''在词典中出现,说明``确实''是一个``词''。之后,重复这个过程。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-example-of-word-segmentation-based-on-dictionary}
\caption{基于词典进行分词的实例}
\label{fig:3.2-2}
\end{figure}
%-------------------------------------------
\parinterval 但是,基于词典的分词方法很``硬''。这是因为自然语言非常灵活,经常出现歧义。图\ref{fig:3.2-3}就给出了上面例子中的交叉型歧义,从词典中查看,`` 实现''和``现在''都是合法的单词,但是在句子中二者有重叠,因此词典无法告诉系统哪个结果是正确的。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-cross-type-word-segmentation-ambiguity}
\caption{交叉型分词歧义}
\label{fig:3.2-3}
\end{figure}
%-------------------------------------------
\parinterval 类似的例子在生活中也很常见。再比如``答辩结束的和尚未答辩的同学都请留在教室''一句中,正常的分词结果是``答辩/结束/的/和/尚未/答辩/的/同学/都/请/留在/教室'',但是由于``尚未''、``和尚''都是常见词汇,使用基于词典的分词方法在这时很容易出现切分错误。
\parinterval 基于词典的分词方法是典型的基于规则的方法,完全依赖于人工给定的词典。在遇到歧义时,需要人工定义消除歧义的规则,比如,可以自左向右扫描每次匹配最长的单词,这是一种简单的启发式的消歧策略。图\ref{fig:3.2-2}中的例子实际上就是使用这种策略得到的分词结果。但是,启发式的消岐方法仍然需要人工设计启发式规则,而且启发式规则也不能处理所有的情况。所以说简单的基于词典的方法还不能很好的解决分词问题。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{基于统计的分词方法}
\parinterval 既然基于词典的方法有很多问题,那么就需要一种更为有效的方法。在上文中提到,想要搭建一个分词系统,需要让计算机知道什么是``词'',那么可不可以给出已经切分好的分词数据,让计算机在这些数据中学习到规律呢?答案是肯定的,利用``数据''来让计算机明白``词''的定义,让计算机直接在数据中学到知识,这就是一个典型的基于统计建模的学习过程。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{1. 统计模型的学习与推断}
\parinterval 统计分词也是一种典型的数据驱动方法。这种方法将已经经过分词的数据``喂''给系统,这个数据也被称作{\small\bfnew{标注数据}}\index{标注数据}(Annotated Data)\index{Annotated Data}。在获得标注数据后,系统自动学习一个统计模型来描述分词的过程,而这个模型会把分词的``知识''作为参数保存在模型中。当送入一个新的需要分词的句子时,可以利用学习到的模型对可能的分词结果进行概率化的描述,最终选择概率最大的结果作为输出。这个方法就是基于统计的分词方法,其与{\chaptertwo}介绍的统计语言建模方法本质上是一样的。具体来说,可以分为两个步骤:
\begin{itemize}
\vspace{0.5em}
\item {\small\bfnew{训练}}\index{训练}(Training)\index{Training}。利用标注数据,对统计模型的参数进行学习。
\vspace{0.5em}
\item {\small\bfnew{预测}}\index{预测}(Prediction)\index{Prediction}。利用学习到的模型和参数,对新的句子进行切分。这个过程也可以被看作是利用学习到的模型在新的数据上进行{\small\bfnew{推断}}\index{推断}(Inference)\index{Inference}
\vspace{0.5em}
\end{itemize}
\parinterval\ref{fig:3.2-4}给出了一个基于统计建模的汉语分词实例。左侧是标注数据,其中每个句子是已经经过人工标注的分词结果(单词用斜杠分开)。之后,建立一个统计模型,记为$\funp{P}(\cdot)$。模型通过在标注数据上的学习来对问题进行描述,即学习$\funp{P}(\cdot)$。最后,对于新的未分词的句子,使用模型$\funp{P}(\cdot)$对每个可能的切分方式进行概率估计,之后选择概率最高的切分结果输出。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-word-segmentation-based-on-statistics}
\caption{基于统计的自动分词流程}
\label{fig:3.2-4}
\end{figure}
%-------------------------------------------
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{2. 全概率分词方法}
\parinterval 上述过程的核心在于从标注数据中学习一种对分词现象的统计描述,即句子的分词结果概率$\funp{P}(\cdot)$。如何让计算机利用分好词的数据学习到分词知识呢?本书的{\chaptertwo}曾介绍如何对单词概率进行统计建模,而对分词现象的统计描述就是在单词概率的基础上,基于独立性假设获取的\footnote{即假定所有词的出现都是相互独立的。}。虽然独立性假设并不能完美描述分词过程中单词之间的关系,但是它大大化简了分词问题的复杂度。
\parinterval 如图\ref{fig:3.2-5}所示,可以利用大量人工标注好的分词数据,通过统计学习方法获得一个统计模型$\funp{P}(\cdot)$,给定任意分词结果$W = w_1w_2 \ldots w_m$,都能通过$\funp{P}(W)=\funp{P}(w_1) \cdot \funp{P}(w_2) \cdot \ldots \cdot \funp{P}(w_m)
$计算这种切分的概率值。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-examples-of-chinese-word-segmentation-based-on-1-gram-model}
\caption{基于1-gram语言模型的中文分词实例}
\label{fig:3.2-5}
\end{figure}
%-------------------------------------------
\parinterval 以``确实现在数据很多''这个实例来说,如果把这句话按照``确实/现在/数据/很/多''这样的方式进行切分,这个句子切分的概率$\funp{P}$(确实/现在/数据/很/多) 可以通过每个词出现概率相乘的方式进行计算。
\begin{eqnarray}
&\funp{P}&\textrm{(确实/现在/数据/很/多)} \nonumber \\
& = &\funp{P}\textrm{(确实)} \cdot \funp{P}\textrm{(现在)} \cdot \funp{P}\textrm{(数据)} \cdot \funp{P}\textrm{(很)} \cdot \funp{P}\textrm{(多)}
\label{eq:3.2-1}
\end{eqnarray}
\parinterval 经过充分训练的统计模型$\funp{P}(\cdot)$就是得到的分词模型。对于输入的新句子$S$,通过这个模型找到最佳的分词结果输出。假设输入句子$S$是``确实现在数据很多'',可以通过列举获得不同切分方式的概率,其中概率最高的切分方式,就是系统的目标输出。
\parinterval 这种分词方法也被称作基于1-gram语言模型的分词,或全概率分词。全概率分词最大的优点在于方法简单、效率高,因此被广泛应用在工业界系统里。它本质上就是一个1-gram语言模型,因此可以直接复用$n$-gram语言模型的训练方法和未登录词处理方法。与传统$n$-gram语言模型稍有不同的是,分词的预测过程需要找到一个给定字符串所有可能切分中1-gram语言模型得分最高的切分。因此,可以使用{\chaptertwo}中所描述的搜索算法实现这个预测过程,也可以使用动态规划方法快速找到最优切分结果。由于本节的重点是介绍中文分词的基础方法和统计建模思想,因此不会对相关搜索算法进行进一步展开,有兴趣的读者可以参考{\chaptertwo}和本章\ref{sec3:summary}节的相关文献做进一步深入研究。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{命名实体识别}
\parinterval 在人类使用语言的过程中,单词往往不是独立出现的。很多时候,多个单词会组合成一个更大的单元来表达特定的意思。其中,最典型的代表是{\small\bfnew{命名实体}}\index{命名实体}(Named Entity)\index{Named Entity}。通常,命名实体是指名词性的专用短语,例如公司名称、品牌名称、产品名称等专有名词和行业术语。准确地识别出这些命名实体,是提高机器翻译质量的关键。比如,在翻译技术文献时,往往需要对术语进行识别并进行准确翻译。因此引入{\small\bfnew{命名实体识别}}\index{命名实体识别}(Named Entity Recognition)\index{Named Entity Recognition}可以帮助系统对特定术语进行更加细致的处理。
\parinterval 从句法分析的角度来说,命名实体识别是一种浅层句法分析任务。它在分词的基础上,进一步对句子浅层结构进行识别。包括词性标注、组块识别在内的很多任务都可以被看作是浅层句法分析的内容。本节会以命名实体识别为例,对基于序列标注的浅层句法分析方法进行介绍。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{序列标注任务}
\parinterval 命名实体识别是一种典型的{\small\bfnew{序列标注}}\index{序列标注}(Sequence Labeling\index{Sequence Labeling})任务。对于一个输入序列,它会生成一个相同长度的输出序列。输入序列的每一个位置,都有一个与之对应的输出,输出的内容是这个位置所对应的标签(或者类别)。比如,对于命名实体识别,每个位置的标签可以被看作是一种命名实体``开始''和``结束''的标志,而这里就是得到这种``开始''和``结束''标注的序列。不仅如此,分词、词性标注、组块识别等也都可以被看作是序列标注任务。
\parinterval 通常来说,序列标注任务中首先需要定义标注策略,即使用什么样的格式来对序列进行标注。为了便于描述,这里假设输入序列为一个个单词\footnote{广义上,序列标注任务并不限制输入序列的形式,比如,字符、单词、多个单词构成的词组都可以作为序列标注的输入单元。}。常用的标注策略有:
\begin{itemize}
\vspace{0.5em}
\item BIO(Beginning-inside-outside)格式。以命名实体识别为例,B代表一个命名实体的开始,I表示一个命名实体的其它部分,O表示一个非命名实体单元。
\vspace{0.5em}
\item BIOES格式。与BIO格式相比,多出了标签E(End)和S(Single)。仍然以命名实体识别为例,E和S分别用于标注一个命名实体的结束位置和仅含一个单词的命名实体。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------
\begin{figure}[htp]
\centering
\subfigure[BIO格式标注命名实体] {\input{./Chapter3/Figures/figure-labeling-named-entities-in-bio-format} }
\subfigure[BIOES格式标注命名实体] {\input{./Chapter3/Figures/figure-labeling-named-entities-in-bioes-format}}
\caption{BIO和BIOES格式对比}
\label{fig:3.3-1}
\end{figure}
%-------------------------------------------
%
\parinterval\ref{fig:3.3-1}给出了不同标注格式所对应的标注结果。可以看出文本序列中的非命名实体直接被标注为``O'',而命名实体的标注则被分为了两部分:位置和命名实体类别,图中的``B''、``I''、``E''等标注出了位置信息,而``CIT''和``CNT''则标注出了命名实体类别(``CIT''表示城市,``CNT''表示国家)。可以看到,命名实体的识别结果可以通过BIO、BIOES这类序列标注结果归纳出来:例如在BIOES格式中,标签``B-CNT''后面的标签只会是``I-CNT''或``E-CNT'',而不会是其他的标签。同时,在命名实体识别任务中涉及到实体边界的确定,而``BIO''或``BIOES''的标注格式本身就暗含着边界问题:在``BIO''格式下,实体左边界只能在``B''的左边,右边界只能在``B''或``I''的右边;在``BIOES''格式下,实体左边界只能在``B''或``S''的左边,右边界只能在``E''和``S''的右边。
\parinterval 主要注意的是,虽然图\ref{fig:3.3-1}中的命名实体识别以单词为基本单位进行标注,但真实系统中也可以在字序列上进行命名实体识别。其方法与基于词序列的命名实体识别是一样的。因此,这里仍然以基于词序列的方法为例进行介绍。
\parinterval 对于像命名实体识别这样的任务,早期的方法主要是基于词典和规则的方法。这些方法依赖于人工构造的识别规则,通过字符串匹配的方式识别出文本中的命名实体\upcite{rau1991extracting,张小衡1997中文机构名称的识别与分析}。严格意义上来说,那时命名实体识别还并没有被看作是一种序列标注问题。
\parinterval 序列标注这个概念更多的是出现在基于统计建模的方法中。许多统计机器学习方法都被成功应用用于命名实体识别任务,例如{\small\bfnew{隐马尔可夫模型}}\index{隐马尔可夫模型}(Hidden Markov Model,HMM)\index{HMM}{\small\bfnew{条件随机场}}\index{条件随机场}(Conditional Random Fields,CRFs)\index{Conditional Random Fields}{\small\bfnew{最大熵}}\index{最大熵}(Maximum Entropy,ME)\index{ME}模型和{\small\bfnew{支持向量机}}\index{支持向量机}(Support Vector Machine,SVM)\index{SVM}等。此外,近些年深度学习的兴起也给命名实体识别带来了新的思路{\color{red}(参考文献!!!!)}。而命名实体识别也成为了验证机器学习方法有效性的重要任务之一。本节将对序列标注中几类基础的方法进行介绍。其中会涉及概率图模型、统计分类模型等方法。特别是统计分类的概念,在后续章节中也会被使用到。
%----------------------------------------------------------------------------------------
% NEW SUBS-SECTION
%----------------------------------------------------------------------------------------
\subsection{基于特征的统计学习} \label{sec3:feature}
\parinterval 基于特征的统计学习是解决序列标注的有效方法之一。这种方法中,系统研发人员通过定义不同的特征来完成对问题的描述,之后利用统计模型完成对这些特征的某种融合,并得到最终的预测结果。
\parinterval 在开始介绍序列标注模型之前,先来看一下统计学习所涉及的重要概念\ \dash\ {\small\bfnew{特征}}\index{特征}(Feature)\index{Feature}。简单来说,特征是指能够反映事物在某方面表现或行为的一种属性,如现实生活中小鸟的羽毛颜色、喙的形状、翼展长度等就是小鸟的特征;命名实体识别任务中的每个词的词根、词性和上下文组合也可以被看做是识别出命名实体可以采用的特征。
\parinterval 从统计建模的角度看,特征的形式可以非常灵活。比如,可以分为连续型特征和离散型特征,前者通常用于表示取值蕴含数值大小关系的信息,如人的身高和体重,后者通常用于表示取值不蕴含数值大小关系的信息,例如人的性别。正是由于这种灵活性,系统开发者可以通过定义多样的特征从多个不同的角度对目标问题进行建模。而这种设计特征的过程也被称作{\small\bfnew{特征工程}}\index{特征工程}(Feature Engineering)\index{Feature Engineering}
\parinterval 设计更好的特征也成为了很多机器学习方法的关键。通常有两个因素需要考虑:
\begin{itemize}
\vspace{0.5em}
\item 样本在这些特征上的差异度,即特征对于样本的区分能力。比如,可以考虑优先选择样本特征值方差较大即区分能力强的特征\footnote{方差如果很小,意味着样本在这个特征上基本上没有差异,那么这个特征对于样本的区分并没有什么用。}
\vspace{0.5em}
\item 特征与任务目标的相关性。优先选择相关性高的特征。
\vspace{0.5em}
\end{itemize}
\parinterval 回到命名实体识别任务上来。对于输入的每个单词,可以将其表示为一个单词和对应的{\small\bfnew{词特征}}\index{词特征}(word feature)\index{word feature}的组合,记作$<w, f>$。通过这样的表示,就可以将原始的单词序列转换为词特征序列。命名实体识别中的特征可以分为两大类,一种是单词对应各个标签的特征;另一种是标签之间组合的特征。常用的特征包括词根、词缀、词性或者标签的固定搭配等。表\ref{tab:3.3-1}展示了命名实体识别任务中一些典型的特征。
\begin{table}[htp]{
\begin{center}
\caption{命名实体识别中常用的特征}
{
\begin{tabular}{c|c|c}
特征名 & 示例文本 & 释义 \\
\hline
\rule{0pt}{10pt} LocSuffix & 沈阳\underline{} & 地名后缀 \\
\rule{0pt}{10pt} FourDigitYear & \underline{2020} & 四位数年份 \\
\rule{0pt}{10pt} OtherDigit & \underline{202020} & 其他数字 \\
\rule{0pt}{10pt} NamePrefix & \underline{}& 姓名前缀 \\
\rule{0pt}{10pt} ShortName & \underline{东大}成立120周年 & 缩略词 \\
\end{tabular}
\label{tab:3.3-1}
}
\end{center}
}\end{table}
\parinterval 在相当长的一段时期内,基于特征工程的方法都是自然语言处理领域的主流范式。虽然深度学习技术的进步使得系统研发人员可以逐步摆脱繁重的特征设计工作。但是很多传统的模型和方法在今天仍然被广泛使用。比如,在当今最先进的序列标注模型中\upcite{lample2016neural},本节即将介绍的条件随机场模型仍然是一个主要部件。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{基于概率图模型的方法}
\parinterval {\small\bfnew{概率图模型}}\index{概率图模型}(Probabilistic Graphical Model)\index{Probabilistic Graphical Model}是使用图表示变量及变量间概率依赖关系的方法。在概率图模型中,可以根据可观测变量推测出未知变量的条件概率分布等信息。如果把序列标注任务中的输入序列看作观测变量,而把输出序列看作需要预测的未知变量,那么就可以把概率图模型应用于命名实体识别等序列标注任务。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{1. 隐马尔可夫模型}
\parinterval 隐马尔可夫模型是一种经典的序列模型\upcite{Baum1966Statistical,baum1970maximization}。它在语音识别、自然语言处理的很多领域得到了广泛的应用。隐马尔可夫模型的本质概率化的马尔可夫过程,这个过程隐含着状态间转移和可见状态生成的概率。
\parinterval 这里用一个简单的``抛硬币''游戏来对这些概念进行说明:假设有三枚质地不同的硬币A、B、C,已知这三个硬币抛出正面的概率分别为0.3、0.5、0.7。在游戏中,游戏发起者在上述三枚硬币中选择一枚硬币上抛,每枚硬币被挑选到的概率可能会受上次被挑选的硬币的影响,且每枚硬币正面向上的概率都各不相同。不停的重复挑选硬币、上抛硬币的过程,会得到一串硬币的正反序列,例如:抛硬币6次,得到:正正反反正反。游戏挑战者通过观察6次后获得的硬币正反序列,猜测每次选择的究竟是哪一枚硬币。
\parinterval 在上面的例子中,每次挑选并上抛硬币后得到的``正面''或``反面''即为``可见状态'';再次挑选并上抛硬币会获得新的``可见状态'',这个过程即为``状态的转移'';经过6次反复挑选上抛后得到的硬币正反序列叫做可见状态序列,由每个回合的可见状态构成。此外,在这个游戏中还暗含着一个会对最终``可见状态序列''产生影响的``隐含状态序列''\ \dash \ 每次挑选的硬币形成的序列,例如CBABCA。
\parinterval 实际上,隐马尔科夫模型在处理序列问题时的关键依据是两个至关重要的概率关系,并且这两个概率关系也始终贯穿于``抛硬币''的游戏中。一方面,隐马尔可夫模型中用{\small\bfnew{发射概率}}\index{发射概率}(Emission Probability)\index{Emission Probability}来描述了隐含状态和可见状态之间存在的输出概率(即A、B、C 抛出正面的输出概率为0.3、0.5、0.7);同样的,隐马尔可夫模型还会描述系统隐藏状态的{\small\bfnew{转移概率}}\index{转移概率}(Transition Probability)\index{Transition Probability},在这个例子中,A 的下一个状态是A、B、C 的概率都是1/3。B、C 的下一个状态是A、B、C 的转移概率也同样是1/3。图\ref{fig:3.3-2}展示了在``抛硬币''游戏中的转移概率和发射概率,它们都可以被看做是条件概率矩阵。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-transition-prob-and-launch-prob-in-coin-toss-game}
\caption{``抛硬币''游戏中的转移概率和发射概率}
\label{fig:3.3-2}
\end{figure}
%-------------------------------------------
\parinterval 由于隐含状态序列之间存在转移概率,并且隐马尔可夫模型中隐含状态和可见状态之间存在着发射概率,因此根据可见状态的转移猜测隐藏状态序列并非无迹可循。图\ref{fig:3.3-3}描述了如何使用隐马尔可夫模型根据``抛硬币''结果推测挑选的硬币序列。可见,通过隐藏状态之间的联系(绿色方框及它们之间的连线)可以对有序的状态进行描述,进而得到隐藏状态序列所对应的可见状态序列(红色圆圈)。
\parinterval 从统计建模的角度看,上述过程本质上在描述隐含状态和可见状态出现的联合概率。这里,用$\mathbf{X}=(x_1,...,x_m)$表示可见状态序列,用$\mathbf{Y}=(y_1,...,y_m)$表示隐藏状态序列。(一阶)隐马尔可夫模型假设:
\begin{itemize}
\vspace{0.5em}
\item 当前位置的隐含状态仅与前一个位置的隐含状态相关,即$y_i$仅与$y_{i-1}$相关;
\vspace{0.5em}
\item 当前位置的可见状态仅与当前位置的隐含状态相关,即$x_i$仅与$y_i$相关。
\vspace{0.5em}
\end{itemize}
于是,联合概率$\funp{P}(\mathbf{X},\mathbf{Y})$可以被定义为:
\begin{eqnarray}
\funp{P}(\mathbf{X},\mathbf{Y}) & = & \funp{P}(\mathbf{X}|\mathbf{Y})\funp{P}(\mathbf{Y}) \nonumber \\
& = & \funp{P}(x_1,...,x_m|y_1,...,y_m) \funp{P}(y_1,...,y_m) \nonumber \\
& = & \prod_{i=1}^{m} \funp{P}(x_i|x_1,...,x_{i-1},y_1,...,y_m) \prod_{i=1}^{m} \funp{P}(y_i | y_{i-1}) \nonumber \\
& = & \prod_{i=1}^{m} \funp{P}(x_i|y_i) \prod_{i=1}^{m} \funp{P}(y_i | y_{i-1}) \nonumber \\
& = & \prod_{i=1}^{m} \funp{P}(x_i|y_i) \funp{P}(y_i | y_{i-1}) \label{eq:joint-prob-xy}
\end{eqnarray}
\noindent 这里,$y_{0}$表示一个虚拟的隐含状态。这样,可以定义$\funp{P}(y_1|y_{0}) \equiv \funp{P}(y_1)$,它表示起始隐含状态出现的概率。隐马尔可夫模型的假设也大大化简了问题,因此可以通过式\ref{eq:joint-prob-xy}很容易地计算隐含状态序列和可见状态序列出现的概率。值得注意的是,发射概率和转移概率都可以被看作是描述序列生成过程的“特征”。但是,这些“特征”并不是随意定义的,而是符合问题的概率解释。而这种基于事件发生的逻辑所定义的概率生成模型,通常可以被看作是一种{\small\bfnew{生成式模型}}\index{生成式模型}(Generative Model\index{Generative Model})。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-example-of-hmm-in-coin-toss}
\caption{抛硬币的隐马尔可夫模型实例}
\label{fig:3.3-3}
\end{figure}
%-------------------------------------------
\parinterval 一般来说,隐马尔可夫模型中包含下面三个问题:
\begin{itemize}
\vspace{0.5em}
\item 隐藏状态序列的概率计算:即给定模型(转移概率和发射概率),根据可见状态序列(抛硬币的结果),计算在该模型下得到这个结果的概率,这个问题的解决需要用到前后向算法\upcite{baum1970maximization}
\vspace{0.5em}
\item 参数学习:即给定硬币种类(隐含状态数量),根据多个可见状态序列(抛硬币的结果),估计模型的参数(转移概率),这个问题的求解需要用到EM算法\upcite{1977Maximum}
\vspace{0.5em}
\item 解码:即给定模型(转移概率和发射概率)和可见状态序列(抛硬币的结果),计算在可见状态序列的情况下,最可能出现的对应的状态序列,这个问题的求解需要用到基于动态规划的方法,通常也被称作{\small\bfnew{维特比算法}}\index{维特比算法}(Viterbi Algorithm)\index{Viterbi Algorithm}\upcite{1967Error}
\vspace{0.5em}
\end{itemize}
\parinterval 隐马尔可夫模型处理序列标注问题的基本思路是:
\begin{itemize}
\vspace{0.5em}
\item 第一步:根据可见状态序列(输入序列)和其对应的隐藏状态序列(标记序列)样本,估算模型的转移概率和发射概率;
\vspace{0.5em}
\item 第二步:对于给定的可见状态序列,预测概率最大的隐藏状态序列,比如,根据输入的词序列预测最有可能的命名实体标记序列
\vspace{0.5em}
\end{itemize}
\parinterval 一种简单的办法是使用相对频次估计得到转移概率和发射概率估计值。令$x_i$表示第$i$个位置的可见状态,$y_i$表示第$i$个位置的隐藏状态,$\funp{P}(y_i|y_{i-1})$表示第$i-1$个位置到第$i$个位置的状态转移概率,$\funp{P}(x_i|y_{i}) $表示第$i$个位置的发射概率,于是有:
\begin{eqnarray}
\funp{P}(y_i|y_{i-1}) = \frac{{\textrm{Count}}(y_{i-1},y_i)}{{\textrm{Count}}(y_{i-1})}
\label{eq:3.3-1}
\end{eqnarray}
\begin{eqnarray}
\funp{P}(x_i|y_{i}) = \frac{{\textrm{Count}}(x_i,y_i)}{{\textrm{Count}}(y_i)}
\label{eq:3.3-2}
\end{eqnarray}
\noindent 其中,${\rm{Count}}()$统计训练集中某种现象出现的次数。
\parinterval 在获得转移概率和发射概率的基础上,对于一个句子进行命名实体识别可以被描述为:在观测序列$\mathbf{X}$(可见状态,即输入的词序列)的条件下,最大化标签序列$\mathbf{Y}$(隐藏状态,即标记序列)的概率,即:
\begin{eqnarray}
\hat{\mathbf{Y}} = \arg\max_{\mathbf{Y}}\funp{P}(\mathbf{Y}|\mathbf{X})
\label{eq:3.3-3}
\end{eqnarray}
\parinterval 根据贝叶斯定理,该概率被分解为$\funp{P}(\mathbf{Y}|\mathbf{X})=\frac{\funp{P}(\mathbf{X},\mathbf{Y})}{\funp{P}(\mathbf{X})}$,其中$\funp{P}(\mathbf{X})$是固定概率,因为$\mathbf{X}$在这个过程中是确定的不变量。因此只需考虑如何求解分子,即将求条件概率$\funp{P}(\mathbf{Y}|\mathbf{X})$的问题转化为求联合概率$\funp{P}(\mathbf{Y},\mathbf{X})$的问题:
\begin{eqnarray}
\hat{\mathbf{Y}} = \arg\max_{\mathbf{Y}}\funp{P}(\mathbf{X},\mathbf{Y}) \label{eq:markov-sequence-argmax}
\label{eq:3.3-4}
\end{eqnarray}
\parinterval 将式\ref{eq:joint-prob-xy}带入式\ref{eq:markov-sequence-argmax}可以得到最终计算公式,如下:
\begin{eqnarray}
\hat{\mathbf{Y}} = \arg\max_{\mathbf{Y}}\prod_{i=1}^{m}\funp{P}(x_i|y_i)\funp{P}(y_i|y_{i-1})
\label{eq:3.3-5}
\end{eqnarray}
\parinterval\ref{fig:3.3-4}展示了基于隐马尔可夫模型的命名实体识别模型。实际上,这种描述序列生成的过程也可以被应用于机器翻译,在第五章还将看到隐马尔可夫模型在翻译建模中的应用。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-ner-based-on-hmm}
\caption{基于隐马尔可夫模型的命名实体识别(解码过程)}
\label{fig:3.3-4}
\end{figure}
%-------------------------------------------
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{2. 条件随机场}
\parinterval 隐马尔可夫模型有一个很强的假设:一个隐藏状态出现的概率仅由上一个隐藏状态决定。这个假设也会带来一些问题。举一个例子:在某个隐马尔可夫模型中,隐藏状态集合为\{A, B, C, D\},可见状态集合为\{T, F\}。其中隐藏状态A可能的后继隐藏状态集合为\{A, B\},隐藏状态B可能的后继隐藏状态集合为\{A, B, C, D\},于是有:
\begin{eqnarray}
\funp{P}({\rm A}|{\rm A})+\funp{P}({\rm A}|{\rm B}) & = & 1 \label{eq:3.3-6} \\
\funp{P}({\rm A}|{\rm B})+\funp{P}({\rm B}|{\rm B})+\funp{P}({\rm C}|{\rm B})+\funp{P}({\rm D}|{\rm B}) & = & 1 \label{eq:3.3-7}
\end{eqnarray}
\noindent 其中,$\funp{P}(b|a)$表示由状态$a$转移到状态$b$的概率。由于式\ref{eq:3.3-6}中的分式数量少于式\ref{eq:3.3-7},这就导致在统计中获得的$\funp{P}({\rm A}|{\rm A})$$\funp{P}({\rm A}|{\rm B})$的值很可能会比$\funp{P}({\rm A}|{\rm B})$$\funp{P}({\rm B}|{\rm B})$$\funp{P}({\rm C}|{\rm B})$$\funp{P}({\rm D}|{\rm B})$要大。
\parinterval\ref{fig:3.3-5}展示了一个具体的例子。有一个可见状态序列T F F T,假设初始隐藏状态是A,图中线上的概率值是对应的转移概率与发射概率的乘积,比如图中隐藏状态A开始,下一个隐藏状态是A 且可见状态是F 的概率是0.45,下一个隐藏状态是B 且可见状态是F的概率是0.55。图中可以看出,由于有较大的值,当可见状态序列为T F F T时,隐马尔可夫计算出的最有可能的隐藏状态序列为A A A A。但是如果对训练集进行统计可能会发现,当可见序列为T F F T 时,对应的隐藏状态是A A A A的概率可能是比较大的,但也可能是比较小的。这个例子中出现预测偏差的主要原因是:由于比其他状态转移概率要大得多,隐藏状态的预测一直停留在状态A。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-example-of-hmm}
\caption{隐马尔可夫实例}
\label{fig:3.3-5}
\end{figure}
%-------------------------------------------
\parinterval 上述现象也被称作{\small\bfnew{标注偏置}}\index{标注偏置}(Label Bias)\index{Label Bias}。条件随机场模型在隐马尔可夫模型的基础上,解决了这个问题\upcite{lafferty2001conditional}。在条件随机场模型中,以全局范围的统计归一化代替了隐马尔可夫模型中的局部归一化。除此之外,条件随机场模型中并非使用概率计算而是特征函数的方式对可见状态序列$\mathbf{X}$对应的隐藏状态序列$\mathbf{Y}$的概率进行计算。
\parinterval 条件随机场中一般有若干个特征函数,都是经过设计的、能够反映序列规律的一些二元函数\footnote{二元函数的函数值一般非1即0},并且每个特征函数都有其对应的权重$\lambda$。特征函数一般由两部分组成:能够反映隐藏序列之间转移规则的转移特征$t(y_{i-1},y_i,\mathbf{X},i)$和状态特征$s(y_i,\mathbf{X},i)$。其中$y_i$$y_{i-1}$分别是位置$i$和前一个位置的隐藏状态,$\mathbf{X}$则是可见状态序列。转移特征$t(y_{i-1},y_i,\mathbf{X},i)$反映了两个相邻的隐藏状态之间的转换关系,而状态特征$s(y_i,\mathbf{X},i)$则反映了第$i$个可见状态应该对应什么样的隐藏状态。这两部分共同组成了一个特征函数$F(y_{i-1},y_i,\mathbf{X})$,即
\begin{eqnarray}
F(y_{i-1},y_i,\mathbf{X}) & = & t(y_{i-1},y_i,\mathbf{X},i)+s(y_i,\mathbf{X},i)
\label{eq:3.3-8}
\end{eqnarray}
\parinterval 实际上,基于特征函数的方法更像是对隐藏状态序列的一种打分:根据人为设计的模板(特征函数),测试隐藏状态之间的转换以及隐藏状态与可见状态之间的对应关系是否符合这种模板。在处理序列问题时,假设可见状态序列$\mathbf{X}$的长度和待预测隐藏状态序列$\mathbf{Y}$的长度均为$m$,且共设计了$k$个特征函数,则有:
\begin{eqnarray}
\funp{P}(\mathbf{Y}|\mathbf{X}) & = & \frac{1}{Z(\mathbf{X})}\exp(\sum_{i=1}^m\sum_{j=1}^{k}\lambda_{j}F_{j}(y_{i-1},y_i,x,i))
\label{eq:3.3-9}
\end{eqnarray}
\parinterval 公式\ref{eq:3.3-9}中的$Z(X)$即为上面提到的实现全局统计归一化的归一化因子,其计算方式为:
\begin{eqnarray}
Z(\mathbf{X})=\sum_{\mathbf{Y}}\exp(\sum_{i=1}^m\sum_{j=1}^k\lambda_{j}F_{j}(y_{i-1},y_i,x,i))
\label{eq:3.3-10}
\end{eqnarray}
\parinterval 由公式\ref{eq:3.3-10}可以看出,归一化因子的求解依赖于整个可见状态序列和每个位置的隐藏状态,因此条件随机场模型中的归一化是一种全局范围的归一化方式。图\ref{fig:3.3-6}为条件随机场模型处理序列问题的示意图。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-crf-to-deal-with-sequence-problems}
\caption{条件随机场模型处理序列问题}
\label{fig:3.3-6}
\end{figure}
%-------------------------------------------
\parinterval 虽然,式\ref{eq:3.3-9}和式\ref{eq:3.3-10}的表述相较于隐马尔可夫模型更加复杂,但是其实现有非常高效的方式。比如,可以使用动态规划方法完成整个条件随机场模型的计算,具体方法读者可以参看参考文献\upcite{lafferty2001conditional}
\parinterval 条件随机场模型处理命名实体识别任务时,可见状态序列对应着文本内容,隐藏状态序列对应着待预测的标签。对于命名实体识别任务,需要单独设计若干适合命名实体识别任务的特征函数。例如在使用BIOES标准标注命名实体识别任务时,标签``B-ORG''\footnote{ORG表示机构实体}后面的标签必然是``I-ORG''或是``E-ORG'',而不可能是``O'',针此规则可以设计相应特征函数。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{基于分类器的方法}
\parinterval 基于概率图的模型将序列表示为有向图或无向图,如图\ref{fig:3.3-7}(a)、(b)所示。这种方法增加了建模的复杂度。既然要得到每个位置的类别输出,另一种更加直接的方法是使用分类器对每个位置进行独立预测。分类器是机器学习中广泛使用的方法,它可以根据输入自动地对类别进行预测。如图\ref{fig:3.3-7}(c)所示,对于序列标注任务,分类器把每一个位置所对应的所有特征看作是输入,而把这个位置对应的标签看作输出。从这个角度说,隐马尔可夫模型等方法实际上也是在进行一种``分类''操作,只不过这些方法考虑了不同位置输出(或隐含状态)之间的依赖。
%----------------------------------------------
\begin{figure}[htp]
\centering
\begin{tabular}{l l l}
\subfigure[HMM处理序列标注]{\input{./Chapter3/Figures/figure-process-sequence-labeling-by-hmm}} & \subfigure[CRF处理序列标注]{\input{./Chapter3/Figures/figure-process-sequence-labeling-by-crf}} & \subfigure[分类模型处理序列标注]{\input{./Chapter3/Figures/figure-process-sequence-labeling-by-classfication}}
\end{tabular}
\caption{HMM、CRF、分类算法三种方法对比}
\label{fig:3.3-7}
\end{figure}
%-------------------------------------------
\parinterval 值得注意的是分类模型可以被应用于序列标注之外的很多任务。在后面的章节中还会看到,机器翻译中的很多模块也借鉴了统计分类的思想。其中使用到的基础数学模型和特征定义形式,与这里提到的分类器本质上是一样的。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{1. 分类任务与分类器}
\parinterval 无论在日常生活中还是在研究工作中,都会遇到各种各样的分类问题,例如挑选西瓜时需要区分``好瓜''和``坏瓜''、编辑看到一篇新闻稿件时要对稿件进行分门别类。事实上,在机器学习中,对``分类任务''的定义会更宽泛而并不拘泥于``类别''的概念:在对样本进行预测时,只要预测标签集合是有限的且预测标签是离散的,就可认定其为分类任务。
\parinterval 具体来说,分类任务目标是训练一个可以根据输入数据预测离散标签的{\small\bfnew{分类器}}\index{分类器}(Classifier\index{Classifier}),也可称为分类模型。在有监督的分类任务中\footnote{与之相对应的,还有无监督、半监督分类任务,不过这些内容不是本书讨论的重点。读者可以参看参考文献\upcite{周志华2016机器学习,李航2019统计学习方法}对相关概念进行了解。},训练数据集合通常由形似$(\mathbf{x}_i,y_i)$的带标注数据构成:$\mathbf{x}_i=(x_i^1,x_i^2,\ldots,x_i^k)$作为分类器的输入数据(通常被称作一个训练样本),其中$x_i^j$表示样本$\mathbf{x}_i$的第$j$个特征;$y_i$作为输入数据对应的{\small\bfnew{标签}}\index{标签}(Label)\index{Label},反映了输入数据对应的``类别''。若标签集合大小为$n$,则分类任务的本质是通过对训练数据集合的学习,建立一个从$k$ 维样本空间到$n$维标签空间的映射关系。更确切地说,分类任务的最终目标是学习一个条件概率分布$\funp{P}(y|\mathbf{x})$,这样对于输入$\mathbf{x}$可以找到概率最大的$y$作为分类结果输出。
\parinterval 与概率图模型一样,分类模型中也依赖特征定义。其定义形式与\ref{sec3:feature}节的描述一致,这里不再赘述。分类任务一般根据类别数量分为二分类任务和多分类任务。二分类任务是最经典的分类任务,只需要对输出进行非零即一的预测。多分类任务则可以有多种处理手段,比如,可以将其``拆解''为多个二分类任务求解,或者直接让模型输出多个类别中的一个。在命名实体识别中,往往会使用多类别分类模型。比如,在BIO标注下,有三个类别(B、I和O)。一般来说,类别数量越大分类的难度也越大。比如,BIOES标注包含5个类别,因此使用同样的分类器,它要比BIO标注下的分类问题难度大。另一方面,更多的类别有助于准确的刻画目标问题。因此在实践中需要在类别数量和分类难度之间找到一种平衡。
\parinterval 在机器翻译和语言建模中也会遇到类似的问题,比如,生成单词的过程可以被看做是一个分类问题,类别数量就是词表的大小。显然,词表越大可以覆盖更多样的单词及形态学变化,但是过大的词表里会包含很多低频词,其计算复杂度会显著增加。但是,过小的词表又无法包含足够多的单词。因此,在设计这类系统的时候对词表大小的选择(类别数量的选择)是十分重要的,往往要通过大量的实验得到最优的设置。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{2. 经典的分类模型}
\parinterval 经过多年的发展,研究者提出了很多分类模型。由于篇幅所限,本书无法一一列举这些模型,这里仅列出了部分经典的模型。关于分类模型更全面的介绍可以参考相关文献\upcite{harrington2013机器学习实战,李航2019统计学习方法}
\begin{itemize}
\vspace{0.5em}
\item $K$-近邻分类算法。$K$-近邻分类算法通过计算不同特征值之间的距离进行分类,这种方法适用于可以提取到数值型特征\footnote{即可以用数值大小对某方面特征进行衡量。}的分类问题。该方法的基本思想为:将提取到的特征分别作为坐标轴,建立一个$k$维坐标系(对应特征数量为$k$的情况),此时每个样本都将成为该$k$维空间的一个点,将未知样本与已知类别样本的空间距离作为分类依据进行分类,比如,考虑与输入样本最近的$K$个样本的类别进行分类。
\vspace{0.5em}
\item 支持向量机。支持向量机是一种二分类模型,其思想是通过线性超平面将不同输入划分为正例和负例,并使线性超平面与不同输入的距离都达到最大。与$K$-近邻分类算法类似,支持向量机也适用于可以提取到数值型特征的分类问题。
\vspace{0.5em}
\item 最大熵模型。最大熵模型是根据最大熵原理提出的一种分类模型,其基本思想是:以在训练数据集中学习到的经验知识作为一种``约束'',并在符合约束的前提下,在若干合理的条件概率分布中选择``使条件熵最大''的模型。
\vspace{0.5em}
\item 决策树分类算法。决策树分类算法是一种基于实例的归纳学习方法:将样本中某些决定性特征作为决策树的节点,根据特征表现进行对样本划分,最终根节点到每个叶子节点均形成一条分类的路径规则。这种分类方法适用于可以提取到离散型特征\footnote{即特征值是离散的。}的分类问题。
\vspace{0.5em}
\item 朴素贝叶斯分类算法。朴素贝叶斯算法是以贝叶斯定理为基础并且假设特征之间相互独立的方法:以特征之间相互独立作为前提假设,学习从输入到输出的联合概率分布,并以后验概率最大的输出作为最终类别。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{句法分析(短语结构分析)}
\parinterval 前面已经介绍了什么叫做``词''、如何对分词问题进行统计建模。同时,也介绍了如何对多个单词构成的命名实体进行识别。无论是分词还是命名实体识别都是句子浅层信息的一种表示。对于一个自然语言句子来说,它更深层次的结构信息可以通过更完整的句法结构来描述,而句法信息也是机器翻译和自然语言处理其他任务中常用的知识之一。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{句法树}
\parinterval {\small\bfnew{句法}}\index{句法}(Syntax)\index{Syntax}是研究句子的每个组成部分和它们之间的组合方式。一般来说,句法和语言是相关的,比如,英文是主谓宾结构,而日语是主宾谓结构。因此不同的语言也会有不同的句法描述方式。自然语言处理领域最常用的两种句法分析形式是{\small\bfnew{短语结构分析}}\index{短语结构分析}(Phrase Structure Parsing)\index{Phrase Structure Parsing}{\small\bfnew{依存分析}}\index{依存分析}(Dependency Parsing)\index{Dependency Parsing}。图\ref{fig:3.4-1}展示了这两种的句法表示形式的实例。其中,左侧是短语结构树。它描述的是短语的结构功能,比如``吃''是动词(记为VV),``鱼''是名词(记为NN),``吃/鱼''组成动词短语,这个短语再与``喜欢''这一动词组成新的动词短语。短语结构树的每个子树都是一个句法功能单元,比如,子树VP(VV(吃) NN(鱼))就表示了``吃/鱼''这个动词短语的结构,其中子树根节点VP是句法功能标记。短语结构树利用嵌套的方式描述了语言学的功能。短语结构树中,每个词都有词性(或词类),不同的词或者短语可以组成名动结构、动宾结构等语言学短语结构。短语结构分析一般也被称为{\small\bfnew{成分分析}}\index{成分分析}(Constituency Parsing)或{\small\bfnew{完全分析}}\index{完全分析}(Full Parsing)\index{Full Parsing}
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-phrase-structure-tree-and-dependency-tree}
\caption{短语结构树(左)和依存树(右)}
\label{fig:3.4-1}
\end{figure}
%---------------------------
\parinterval\ref{fig:3.4-1}右侧展示的是另一种句法结构,被称作依存句法树。依存句法树表示了句子中单词和单词之间的依存关系。比如,从这个例子可以了解,``猫''依赖``喜欢'',``吃''依赖``喜欢'',``鱼''依赖``吃''。
\parinterval 短语结构树和依存句法树的结构和功能有很大不同。短语结构树的叶子节点是单词,中间节点是词性或者短语句法标记。在短语结构分析中,通常把单词称作{\small\bfnew{终结符}}\index{终结符}(Terminal)\index{Terminal},把词性称为{\small\bfnew{预终结符}}\index{预终结符}(Pre-terminal)\index{Pre-terminal},而把其他句法标记称为{\small\bfnew{非终结符}}\index{非终结符}(Non-terminal)\index{Non-terminal}。依存句法树没有预终结符和非终结符,所有的节点都是句子里的单词,通过不同节点间的连线表示句子中各个单词之间的依存关系。每个依存关系实际上都是有方向的,头和尾分别指向``接受''和``发出''依存关系的词。依存关系也可以进行分类,例如,图\ref{fig:3.4-1}中的对每个依存关系的类型都有一个标记,这也被称作是有标记的依存分析。如果不生成这些标记,这样的句法分析被称作无标记的依存分析。
\parinterval 虽然短语结构树和依存树的句法表现形式有很大不同,但是它们在某些条件下能相互转化。比如,可以使用启发性规则将短语结构树自动转化为依存树。从应用的角度,依存分析由于形式更加简单,而且直接建模词语之间的依赖,因此在自然语言处理领域中受到很多关注。在机器翻译中,无论是哪种句法树结构,都已经被证明会对机器翻译系统产生帮助。特别是短语结构树,在机器翻译中的应用历史更长,研究更为深入,因此本节将会以短语结构分析为例介绍句法分析的相关概念。
\parinterval 而句法分析到底是什么呢?简单的理解,句法分析就是在小学语文课程中学习的句子成分的分析,以及对句子中各个成分内部、外部关系的判断。更规范一些的定义,可以参照百度百科和维基百科关于句法分析的解释。
%-------------------------------------------
\begin{definition} 句法分析
句法分析(Parsing)就是指对句子中的词语语法功能进行分析。
\begin{flushright}——《百度百科》\end{flushright}
在自然语言或者计算机语言中,句法分析是利用形式化的文法规则对一个符号串进行分析的过程。
\begin{flushright}——《维基百科(译文)》\end{flushright}
\end{definition}
%-------------------------------------------
\parinterval 上面的定义中,句法分析包含三个重要的概念:
\begin{itemize}
\vspace{0.5em}
\item 形式化的文法:描述语言结构的定义,由文法规则组成。
\vspace{0.5em}
\item 符号串:在本节中,符号串就是指词串,由前面提到的分词系统生成。
\vspace{0.5em}
\item 分析:使用形式文法对符号串进行分析的具体方法,在这里指实现分析的计算机算法。
\vspace{0.5em}
\end{itemize}
\parinterval 以上三点是实现一个句法分析器的要素。本节的后半部分会对相关的概念和技术方法进行介绍。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{上下文无关文法}
\parinterval 句法树是对句子的一种抽象。这种树形结构表达了一种对句子结构的归纳过程,比如,从树的叶子开始,把每一个树节点看作一次抽象,最终形成一个根节点。那这个过程如何用计算机来实现呢?这就需要使用到形式文法。
\parinterval 形式文法是分析自然语言的一种重要工具。根据乔姆斯基的定义\upcite{chomsky1957syntactic},形式文法分为四种类型:无限制文法(0型文法)、上下文有关文法(1型文法)、上下文无关文法(2型文法)和正规文法(3型文法)。不同类型的文法有不同的应用,比如,正规文法可以用来描述有限状态自动机,因此也会被使用在语言模型等系统中。对于短语结构分析问题,常用的是{\small\bfnew{上下文无关文法}}\index{上下文无关文法}(Context-Free Grammar)\index{Context-Free Grammar}。上下文无关文法的具体形式如下:
%-------------------------------------------
\vspace{0.5em}
\begin{definition} 上下文无关文法
一个上下文无关文法可以被视为一个系统$G=<N,\Sigma,R,S>$,其中
\begin{itemize}
\vspace{0.5em}
\item $N$为一个非终结符集合;
\vspace{0.5em}
\item $\Sigma$为一个终结符集合;
\vspace{0.5em}
\item $R$为一个规则(产生式)集合,每条规则 $r \in R$的形式为$X \to Y_1Y_2...Y_n$,其中$X \in N$, $Y_i \in N \cup \Sigma$
\vspace{0.5em}
\item $S$为一个起始符号集合且$S \subseteq N$
\vspace{0.5em}
\end{itemize}
\end{definition}
%-------------------------------------------
\parinterval 举例说明,假设有上下文无关文法$G=<N,\Sigma,R,S>$,可以用它描述一个简单汉语句法结构。其中非终结符集合为不同的汉语句法标记
\begin{eqnarray}
N=\{\textrm{NN},\textrm{VV},\textrm{NP},\textrm{VP},\textrm{IP}\} \nonumber
\label{eq:3.4-1}
\end{eqnarray}
\noindent 这里,\textrm{NN}代表名词,\textrm{VV}代表动词,\textrm{NP}代表名词短语,\textrm{VP}代表动词短语,\textrm{IP}代表单句。进一步,把终结符集合定义为
\begin{eqnarray}
\Sigma = \{\text{猫,喜欢,吃,鱼}\} \nonumber
\label{eq:3.4-2}
\end{eqnarray}
再定义起始符集合为
\begin{eqnarray}
S=\{\textrm{IP}\} \nonumber
\label{eq:3.4-3}
\end{eqnarray}
\parinterval 最后,文法的规则集定义图\ref{fig:3.4-2}所示(其中$r_i$为规则的编号)。这个文法蕴含了不同``层次''的句法信息。比如,规则$r_1$$r_2$$r_3$$r_4$表达了词性对单词的抽象;规则$r_6$$r_7$$r_8$是表达了短语结构的抽象,其中,规则$r_8$描述了汉语中名词短语(主语)+动词短语(谓语)的结构。在实际应用中,像$r_8$这样的规则可以覆盖很大的片段(试想一下一个包含50个词的主谓结构的句子,可以使用$r_8$进行描述)。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-rules-of-grammar}
\caption{一个示例文法的规则集}
\label{fig:3.4-2}
\end{figure}
%---------------------------
\parinterval 上下文无关文法的规则是一种{\small\bfnew{产生式规则}}\index{产生式规则}(Production Rule)\index{Production Rule},形如$\alpha \to \beta $,它表示把规则左端的非终结符$\alpha$替换为规则右端的符号序列$\beta$。 通常,$\alpha$被称作规则的{\small\bfnew{左部}}\index{左部}(Left-hand Side\index{Left-hand Side}),$\beta$被称作规则的{\small\bfnew{右部}}\index{右部}(Right-hand Side\index{Right-hand Side})。使用右部$\beta$ 替换左部$\alpha$ 的过程也被称作规则的使用,而这个过程的逆过程称为规约。规则的使用可以如下定义:
%-------------------------------------------
\vspace{0.5em}
\begin{definition} 上下文无关文法规则的使用
一个符号序列$u$可以通过使用规则$r$替换其中的某个非终结符,并得到符号序列$v$,于是$v$是在$u$上使用$r$的结果,记为$u \overset{r}{\Rightarrow} v$
\begin{center}
\input{./Chapter3/Figures/figure-usage-of-regulation}
\end{center}
\end{definition}
%-------------------------------------------
\parinterval 给定起始非终结符,可以不断地使用规则,最终生成一个终结符串,这个过程也被称为{\small\bfnew{推导}}\index{推导}(Derivation)\index{Derivation}。形式化的定义为:
%-------------------------------------------
\vspace{0.5em}
\begin{definition} 推导
给定一个文法$G=<N,\Sigma,R,S>$,对于一个字符串序 \\
$s_0,s_1,...,s_n$和规则序列$r_1,r_2,...,r_n$,满足
\vspace{-0.5em}
\begin{displaymath}
s_0 \overset{r_1}{\Rightarrow} s_1 \overset{r_2}{\Rightarrow} s_2 \overset{r_3}{\Rightarrow} ... \overset{r_{n}}{\Rightarrow} s_n
\end{displaymath}
\begin{itemize}
\vspace{0.5em}
\item $\forall i \in [0,n], s_i \in (N\cup\Sigma)^*$ \hspace{3.5em} $\lhd$ $s_i$为合法的字符串
\vspace{0.5em}
\item $\forall j \in [1,n], r_j \in R$ \hspace{6.3em} $\lhd$ $r_j$$G$的规则
\vspace{0.5em}
\item $s_0 \in S$ \hspace{10.9em} $\lhd$ $s_0$为起始非终结符
\vspace{0.5em}
\item $s_n \in \Sigma^{*}$ \hspace{10.4em} $\lhd$ $s_n$为终结符序列
\vspace{0.5em}
\end{itemize}
\vspace{0.8em}
$s_0 \overset{r_1}{\Rightarrow} s_1 \overset{r_2}{\Rightarrow} s_2 \overset{r_3}{\Rightarrow} ... \overset{r_{n}}{\Rightarrow} s_n$为一个推导
\end{definition}
%-------------------------------------------
\parinterval 比如,使用前面的示例文法,可以对``猫/喜欢/吃/鱼''进行分析,并形成句法分析树(图\ref{fig:3.4-3})。从起始非终结符IP开始,使用唯一拥有IP作为左部的规则$r_8$推导出NP和VP,之后依次使用规则$r_5$$r_1$$r_7$$r_2$$r_6$$r_3$$r_4$,得到了完整的句法树。
%-------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-example-of-derivation}
\caption{上下文无关文法推导实例}
\label{fig:3.4-3}
\end{figure}
%-------------------------------------------
\parinterval 通常,可以把推导简记为$d=r_1 \circ r_2 \circ ... \circ r_n$,其中$ \circ $表示规则的组合。显然,$d$也对应了树形结构,也就是句法分析结果。从这个角度看,推导就是描述句法分析树的一种方式。此外,规则的推导也把规则的使用过程与生成的字符串对应起来。一个推导所生成的字符串,也被称作文法所产生的一个{\small\bfnew{句子}}\index{句子}(Sentence)\index{Sentence}。而一个文法所能生成的所有句子的集合是这个文法所对应的{\small\bfnew{语言}}\index{语言}(Language)\index{Language}
\parinterval 但是,句子和规则的推导并不是一一对应的。同一个句子,往往有很多推导的方式,这种现象被称为{\small\bfnew{歧义}}\index{歧义}(Ambiguity)\index{Ambiguity}。甚至同一棵句法树,也可以对应不同的推导。图\ref{fig:3.4-4} 给出同一棵句法树所对应的两种不同的规则推导。
%-------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-two-different-derivation-of-regulation}
\setlength{\abovecaptionskip}{-0.5em}
\caption{同一棵句法树对应的不同规则推导}
\label{fig:3.4-4}
\end{figure}
%-------------------------------------------
\parinterval 显然,规则顺序的不同会导致句法树的推导这一确定的过程变得不确定。因此,需要进行{\small\bfnew{消歧}}\index{消歧}(Disambiguation)\index{Disambiguation}。这里,可以使用启发式方法:要求规则使用都服从最左优先原则,这样得到的推导被称为{\small\bfnew{最左优先推导}}\index{最左优先推导}(Left-most Derivation)\index{Left-most Derivation}。图\ref{fig:3.4-4}中的推导1 就是符合最左优先原则的推导。
%-------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-perspectives-of-expert-ordinary-and-syntactic-parser}
\caption{如何选择最佳的句法分析结果 - 专家、普通人和句法分析器的视角}
\label{fig:3.4-5}
\end{figure}
%-------------------------------------------
\parinterval 这样,对于一个上下文无关文法,每一棵句法树都有唯一的最左推导与之对应。于是,句法分析可以被描述为:对于一个句子找到能够生成它的最佳推导,这个推导所对应的句法树就是这个句子的句法分析结果。
\parinterval 不过问题又回来了,怎样才能知道什么样的推导或者句法树是``最佳''的呢?如图\ref{fig:3.4-5}所示,对于语言学专家,他们可以很确定地分辨出哪些句法树是正确的,哪些句法树是错误。甚至普通人也可以通过一些课本中学到的知识产生一些模糊的判断。而计算机如何进行判别呢?沿着前面介绍的统计建模的思想,计算机可以得出不同句法树出现的概率,进而选择概率最高的句法树作为输出,而这正是统计句法分析所做的事情。
\parinterval 在统计句法分析中,需要对每个推导进行统计建模,于是定义一个模型$\funp{P}( \cdot )$,对于任意的推导$d$,都可以用$\funp{P}(d)$计算出推导$d$的概率。这样,给定一个输入句子,我们可以对所有可能的推导用$\funp{P}(d)$计算其概率值,并选择概率最大的结果作为句法分析的结果输出(图\ref{fig:3.4-6})。
%-------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-probability-values-corresponding-to-different-derivations}
\caption{不同推导(句法树)对应的概率值}
\label{fig:3.4-6}
\end{figure}
%-------------------------------------------
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{规则和推导的概率}
\parinterval 对句法树进行概率化,首先要对使用的规则进行概率化。为了达到这个目的,可以使用{\small\bfnew{概率上下文无关文法}}\index{概率上下文无关文法}(Probabilistic Context-Free Grammar)\index{Probabilistic Context-Free Grammar},它是上下文无关文法的一种扩展。
%-------------------------------------------
\vspace{0.5em}
\begin{definition} 概率上下文无关文法
一个概率上下文无关文法可以被视为一个系统$G=<N,\Sigma,R,S>$,其中
\begin{itemize}
\vspace{0.5em}
\item $N$为一个非终结符集合;
\vspace{0.5em}
\item $\Sigma$为一个终结符集合;
\vspace{0.5em}
\item $R$为一个规则(产生式)集合,每条规则 $r \in R$的形式为$p:X \to Y_1Y_2...Y_n$,其中$X \in N$, $Y_i \in N \cup \Sigma$,每个$r$都对应一个概率$p$,表示其生成的可能性;
\vspace{0.5em}
\item $S$为一个起始符号集合且$S \subseteq N$
\vspace{0.5em}
\end{itemize}
\end{definition}
%-------------------------------------------
\parinterval 概率上下文无关文法与传统上下文无关文法的区别在于,每条规则都会有一个概率,描述规则生成的可能性。具体来说,规则$\funp{P}(\alpha \to \beta)$的概率可以被定义为:
\begin{eqnarray}
\funp{P}(\alpha \to \beta)=\funp{P}(\beta | \alpha)
\label{eq:3.4-4}
\end{eqnarray}
\noindent 即,在给定规则左部的情况下生成规则右部的可能性。进一步,在上下文无关文法中,每条规则之间的使用都是相互独立的 \footnote{如果是上下文有关文法,规则会形如 $a\alpha b\to a\beta b$,这时$\alpha \to \beta $的过程会依赖前后上下文$a$$b$}。因此可以把$\funp{P}(d)$分解为规则概率的乘积:
\begin{eqnarray}
\funp{P}(d) & = & \funp{P}(r_1 \cdot r_2 \cdot ... \cdot r_n) \nonumber \\
& = & \funp{P}(r_1) \cdot \funp{P}(r_2) \cdots \funp{P}(r_n)
\label{eq:3.4-5}
\end{eqnarray}
\parinterval 这个模型可以很好的解释词串的生成过程。比如,对于规则集
\begin{eqnarray}
r_3: & &\textrm{VV} \to \text{}\nonumber \\
r_4: & & \textrm{NN} \to \text{}\nonumber \\
r_6: & & \textrm{VP} \to \textrm{VV}\ \textrm{NN} \nonumber
\label{eq:3.4-6}
\end{eqnarray}
\parinterval 可以得到 $d_1=r_3 \cdot r_4 \cdot r_6$的概率为
\begin{eqnarray}
\funp{P}(d_1) & = &\funp{P}(r_3) \cdot \funp{P}(r_4) \cdot \funp{P}(r_6)\nonumber \\
& = & \funp{P}(\textrm{VV} \to \text{}) \cdot \funp{P}(\textrm{NN} \to \text{}) \cdot \funp{P}(\textrm{VP} \to \textrm{VV NN})
\label{eq:3.4-7}
\end{eqnarray}
\parinterval 这也对应了词串``吃/鱼''的生成过程。首先,从起始非终结符VP开始,使用规则$r_6$生成两个非终结符VV和NN;进一步,分别使用规则$r_3$$r_4$从VV和NN进一步生成单词``吃''和``鱼''。整个过程的概率等于三条规则概率的乘积。
\parinterval 新的问题又来了,如何得到规则的概率呢?这里仍然可以从数据中学习文法规则的概率。假设有人工标注的数据,它包括很多人工标注句法树的句法,称之为{\small\bfnew{树库}}\index{树库}(Treebank)\index{Treebank}。然后,对于规则$\textrm{r}:\alpha \to \beta$可以使用基于频次的方法:
\begin{eqnarray}
\funp{P}(r) = \frac{\text{规则$r$在树库中出现的次数}}{\alpha \text{在树库中出现的次数}}
\label{eq:3.4-8}
\end{eqnarray}
\parinterval\ref{fig:3.4-7}展示了通过这种方法计算规则概率的过程。与词法分析类似,可以统计树库中规则左部和右部同时出现的次数,除以规则左部出现的全部次数,所得的结果就是所求规则的概率。这种方法也是典型的相对频次估计。但是如果规则左部和右部同时出现的次数为0时是否代表这个规则概率是0呢?遇到这种情况,可以使用平滑方法对概率进行平滑处理,具体思路可参考{\chaptertwo}的相关内容。
%-------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-evaluation-of-probability-for-grammar}
\caption{上下文无关文法规则概率估计}
\label{fig:3.4-7}
\end{figure}
%-------------------------------------------
\parinterval\ref{fig:3.4-8}展示了基于统计的句法分析的流程。首先,通过树库上的统计,获得各个规则的概率,这样就得到了一个上下文无关句法分析模型$\funp{P}( \cdot )$。对于任意句法分析结果$d=r_1 \circ r_2 \circ ... \circ r_n$,都能通过如下公式计算其概率值:
\begin{equation}
\funp{P}(d)= \prod_{i=1}^{n}\funp{P}(r_i)
\end{equation}
\parinterval 在获取统计分析模型后,就可以使用模型对任意句子进行分析,计算每个句法分析树的概率,并输出概率最高的树作为句法分析的结果。
%-------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter3/Figures/figure-process-of-statistical-syntax-analysis}
\caption{统计句法分析的流程}
\label{fig:3.4-8}
\end{figure}
%-------------------------------------------
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{小结及深入阅读} \label{sec3:summary}
\parinterval 本章将统计建模的思想应用到三个自然语言处理任务中,包括:中文分词、命名实体识别、短语结构句法分析。它们和机器翻译有着紧密的联系,往往作为机器翻译系统输入和输出的数据加工方法。可以发现:经过适当的假设和化简,统计模型可以很好的描述复杂的自然语言处理问题。这种建模手段也会在后续章节的内容中被广泛使用。
\parinterval 由于本章重点介绍如何用统计方法对自然语言处理任务进行建模,因此并没有对具体的问题展开深入讨论。有几方面内容,读者可以继续关注:
\begin{itemize}
\vspace{0.5em}
\item 在建模方面,本章描述了基于1-gram语言模型的分词、基于上下文无关文法的句法分析等,它们都是基于人工先验知识进行模型设计的思路。也就是,问题所表达的现象被``一步一步''生成出来。这是一种典型的生成式建模思想,它把要解决的问题看作一些观测结果的隐含变量(比如,句子是观测结果,分词结果是隐含在背后的变量),之后通过对隐含变量生成观测结果的过程进行建模,以达到对问题进行数学描述的目的。这类模型一般需要依赖一些独立性假设,假设的合理性对最终的性能有较大影响。相对于{\small\sffamily\bfseries{生成式模型}}\index{生成式模型}(Generative Model)\index{Generative Model},另一类方法是{\small\sffamily\bfseries{判别式模型}}\index{判别式模型}(Discriminative Model)\index{Discriminative Model}。本章序列标注内容中提到一些模型就是判别式模型,如条件随机场\upcite{lafferty2001conditional}。它直接描述了从隐含变量生成观测结果的过程,这样对问题的建模更加直接,同时这类模型可以更加灵活的引入不同的特征。判别模型在自然语言处理中也有广泛应用\upcite{ng2002discriminative}。 在本书的第七章也会使用到判别式模型。
\vspace{0.5em}
\item 此外,本章并没有对分词、句法分析中的预测问题进行深入介绍。比如,如何找到概率最大的分词结果?这部分可以直接借鉴第二章中介绍的搜索方法。比如,对于基于$n$-gram语言模型的分词方法,可以 使用动态规划\upcite{huang2008advanced}。对于动态规划的使用条件不满足的情况,可以考虑使用更加复杂的搜索策略,并配合一定剪枝方法。实际上,无论是基于$n$-gram 语言模型的分词还是简单的上下文无关文法都有高效的推断方法。比如,$n$-gram语言模型可以被视为概率有限状态自动机,因此可以直接使用成熟的自动机工具。对于更复杂的句法分析问题,可以考虑使用移进- 规约方法来解决预测问题\upcite{aho1972theory}
\vspace{0.5em}
\item 从自然语言处理的角度来看,词法分析和语法分析中的很多问题都是序列标注问题,例如本章介绍的分词和命名实体识别。此外序列标注还可以被扩展到词性标注\upcite{brants-2000-tnt}、组块识别\upcite{tsuruoka-tsujii-2005-chunk}、关键词抽取\upcite{li-etal-2003-news-oriented}、词义角色标注\upcite{chomsky1993lectures}等任务,本章着重介绍了传统的方法,前沿方法大多与深度学习相结合,感兴趣的读者可以自行了解,其中比较有代表性的使用双向长短时记忆网络对序列进行建模,之后于不同模型进行融合得到最终的结果,例如,与条件随机场相结合的模型(BiLSTM-CRF)\upcite{2015Bidirectional}、与卷积神经网络相结合的模型(BiLSTM-CNNs)\upcite{chiu2016named}、与简单的Softmax结构相结合的模型\upcite{vzukov2018named}等。此外,对于序列标注任务,模型性能很大程度上依赖对输入序列的表示能力,因此基于预训练语言模型的方法也非常流行\upcite{Li2020A},如:BERT\upcite{devlin2018bert}、GPT\upcite{radford2018improving}、XLM\upcite{conneau2019unsupervised}等。
\vspace{0.5em}
\end{itemize}
\begin{tikzpicture}[scale=0.5]
\Tree[.IP
[.ADVP
[.AD \node(e1){前几天};]
]
[.LCP
[.NP
[.CP
[.IP
[.VP
[.VV \node(e2){};]
[.NP
[.NN \node(e3){事故};]
]
]
]
[.DEC \node(e4){};]
]
[.DP
[.DT \node(e5){};]
[.CLP
[.M \node(e6){};]
]
]
[.NP
[.NN \node(e7){};]
]
]
[.LC \node(e8){};]
]
[.VP
[.VP
[.VE \node(e9){};]
[.IP
[.NP
[.NN \node(e10){一家};]
]
[.VP
[.ADVP
[.AD \node(e11){非常};]
]
[.VP
[.VV \node(e12){气派的};]
[.NP
[.ADJP
[.JJ \node(e13){};]
]
[.NP
[.NN \node(e14){商店};]
]
]
]
]
]
]
[.VP
[.ADVP
[.AD \node(e15){,那里};]
]
[.ADVP
[.AD \node(e16){经常};]
]
[.VP
[.VV \node(e17){出售};]
[.NP
[.QP
[.CD \node(e18){一些};]
]
[.ADJP
[.JJ \node(e19){名贵};]
]
[.NP
[.NN \node(e20){鲜花};]
]
]
]
]
]
[.PU \node(e21){.};]
]
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[scale=0.7]
\Tree[.IP
[.NP
[.NR \node(e1){俄国};]
]
[.VP
[.VV \node(e2){希望};]
[.IP
[.NP
[.NR \node(e3){伊朗};]
]
[.VP
[.ADVP
[.AD \node(e4) {没有};]
]
[.VP
[.VV \node(e5) {制造};]
[.NP
[.NN \node(e6){核武器};]
[.NN \node(e7){计划};]
]
]
]
]
]
[.PU \node(e8){.};]
]
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[scale=0.5]
\tikzstyle{cand} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=green!30]
\tikzstyle{ref} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=red!30]
\node[align=center,minimum width=2.4em,minimum height=1.6em,minimum width=6em] (n11) at (0,0){\small\bfnew{Candidate :}};
\node[cand,anchor=west] (n12) at ([xshift=0.0em]n11.east){Can};
\node[cand,anchor=west] (n13) at ([xshift=1em]n12.east){I};
\node[cand,anchor=west] (n14) at ([xshift=1em]n13.east){have};
\node[cand,anchor=west] (n15) at ([xshift=1em]n14.east){this};
\node[cand,anchor=west] (n16) at ([xshift=1em]n15.east){like};
\node[cand,anchor=west] (n17) at ([xshift=1em]n16.east){he};
\node[cand,anchor=west] (n18) at ([xshift=1em]n17.east){do};
\node[cand,anchor=west] (n19) at ([xshift=1em]n18.east){it};
\node[cand,anchor=west] (n20) at ([xshift=1em]n19.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n21) at ([yshift=-6em]n11.south){\small\bfnew{Reference :}};
\node[ref,anchor=west] (n22) at ([xshift=0.0em]n21.east){Can};
\node[ref,anchor=west] (n23) at ([xshift=1em]n22.east){I};
\node[ref,anchor=west] (n24) at ([xshift=1em]n23.east){eat};
\node[ref,anchor=west] (n25) at ([xshift=1em]n24.east){this};
\node[ref,anchor=west] (n26) at ([xshift=1em]n25.east){Can};
\node[ref,anchor=west] (n27) at ([xshift=1em]n26.east){like};
\node[ref,anchor=west] (n28) at ([xshift=1em]n27.east){he};
\node[ref,anchor=west] (n29) at ([xshift=1em]n28.east){did};
\node[ref,anchor=west] (n60) at ([xshift=1em]n29.east){?};
\draw[line width=1.6pt,blue!40] (n12.south) -- (n22.north);
\draw[line width=1.6pt,blue!40] (n13.south) -- (n23.north);
\draw[line width=1.6pt,blue!40] (n15.south) -- (n25.north);
\draw[line width=1.6pt,blue!40] (n16.south) -- (n27.north);
\draw[line width=1.6pt,blue!40] (n17.south) -- (n28.north);
\draw[line width=1.6pt,blue!40] (n20.south) -- (n60.north);
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5]
\tikzstyle{cand} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=green!30]
\tikzstyle{ref} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=red!30]
\node[align=center,minimum width=2.4em,minimum height=1.6em,minimum width=6em] (n11) at (0,0){\small\bfnew{Candidate :}};
\node[cand,anchor=west] (n12) at ([xshift=0.0em]n11.east){Can};
\node[cand,anchor=west] (n13) at ([xshift=1em]n12.east){I};
\node[cand,anchor=west] (n14) at ([xshift=1em]n13.east){have};
\node[cand,anchor=west] (n15) at ([xshift=1em]n14.east){this};
\node[cand,anchor=west] (n16) at ([xshift=1em]n15.east){like};
\node[cand,anchor=west] (n17) at ([xshift=1em]n16.east){he};
\node[cand,anchor=west] (n18) at ([xshift=1em]n17.east){do};
\node[cand,anchor=west] (n19) at ([xshift=1em]n18.east){it};
\node[cand,anchor=west] (n20) at ([xshift=1em]n19.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n21) at ([yshift=-6em]n11.south){\small\bfnew{Reference :}};
\node[ref,anchor=west] (n22) at ([xshift=0.0em]n21.east){Can};
\node[ref,anchor=west] (n23) at ([xshift=1em]n22.east){I};
\node[ref,anchor=west] (n24) at ([xshift=1em]n23.east){eat};
\node[ref,anchor=west] (n25) at ([xshift=1em]n24.east){this};
\node[ref,anchor=west] (n26) at ([xshift=1em]n25.east){Can};
\node[ref,anchor=west] (n27) at ([xshift=1em]n26.east){like};
\node[ref,anchor=west] (n28) at ([xshift=1em]n27.east){he};
\node[ref,anchor=west] (n29) at ([xshift=1em]n28.east){did};
\node[ref,anchor=west] (n30) at ([xshift=1em]n29.east){?};
\draw[line width=1.6pt,blue!40] (n12.south) -- (n26.north);
\draw[line width=1.6pt,blue!40] (n13.south) -- (n23.north);
\draw[line width=1.6pt,blue!40] (n15.south) -- (n25.north);
\draw[line width=1.6pt,blue!40] (n16.south) -- (n27.north);
\draw[line width=1.6pt,blue!40] (n17.south) -- (n28.north);
\draw[line width=1.6pt,blue!40] (n20.south) -- (n30.north);
\end{tikzpicture}
\definecolor{ugreen}{rgb}{0,0.5,0}
\begin{tikzpicture}[scale=0.5]
\tikzstyle{cand} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=green!30]
\tikzstyle{ref} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=red!30]
\node[align=center,minimum width=2.4em,minimum height=1.6em,minimum width=6em] (n11) at (0,0){\small\bfnew{Candidate :}};
\node[cand,anchor=west] (n12) at ([xshift=0.0em]n11.east){Can};
\node[cand,anchor=west] (n13) at ([xshift=1em]n12.east){I};
\node[cand,anchor=west] (n14) at ([xshift=1em]n13.east){have};
\node[cand,anchor=west] (n15) at ([xshift=1em]n14.east){this};
\node[cand,anchor=west] (n16) at ([xshift=1em]n15.east){like};
\node[cand,anchor=west] (n17) at ([xshift=1em]n16.east){he};
\node[cand,anchor=west] (n18) at ([xshift=1em]n17.east){do};
\node[cand,anchor=west] (n19) at ([xshift=1em]n18.east){it};
\node[cand,anchor=west] (n20) at ([xshift=1em]n19.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n21) at ([yshift=-6em]n11.south){\small\bfnew{Reference :}};
\node[ref,anchor=west] (n22) at ([xshift=0.0em]n21.east){Can};
\node[ref,anchor=west] (n23) at ([xshift=1em]n22.east){I};
\node[ref,anchor=west] (n24) at ([xshift=1em]n23.east){eat};
\node[ref,anchor=west] (n25) at ([xshift=1em]n24.east){this};
\node[ref,anchor=west] (n26) at ([xshift=1em]n25.east){Can};
\node[ref,anchor=west] (n27) at ([xshift=1em]n26.east){like};
\node[ref,anchor=west] (n28) at ([xshift=1em]n27.east){he};
\node[ref,anchor=west] (n29) at ([xshift=1em]n28.east){did};
\node[ref,anchor=west] (n30) at ([xshift=1em]n29.east){?};
\draw[line width=1.6pt,blue!40] (n12.south) -- (n22.north);
\draw[line width=1.6pt,blue!40] (n13.south) -- (n23.north);
\draw[line width=1.6pt,blue!40] (n15.south) -- (n25.north);
\draw[line width=1.6pt,blue!40] (n16.south) -- (n27.north);
\draw[line width=1.6pt,blue!40] (n17.south) -- (n28.north);
\draw[line width=1.6pt,blue!40] (n20.south) -- (n30.north);
\draw[line width=1.6pt,orange!40] (n18.south) -- (n29.north);
\draw[line width=1.6pt,ugreen!40](n14.south) -- (n24.north);
\end{tikzpicture}
%\documentclass[tikz]{standalone}
%\usepackage{tikz}
%\usepackage[UTF8]{ctex}
%\usepackage{setspace}
%\usetikzlibrary{shapes}
%\usetikzlibrary{decorations.pathreplacing}
%\begin{document}
\begin{tikzpicture}[scale=0.8]
\begin{scope}
\tikzstyle{every node}=[scale=0.8]
% big circle at center
\node [anchor=center,circle,draw,minimum width=10em,line width=0.2em,ublue] (base) at (0,0) {};
\draw [-,very thick,line width=0.15em,ublue] (0,0) -- (base.90);
\draw [-,very thick,line width=0.15em,ublue] (0,0) -- (base.-30);
\draw [-,very thick,line width=0.15em,ublue] (0,0) -- (base.210);
\node [anchor=south east,align=left] (autoevallabel) at ([xshift=-0.5em,yshift=0.5em]base.-10) {{\small\bfnew\footnotesize{人工构造}}\\{\small\bfnew\footnotesize{参考答案}}};
\node [anchor=south west,align=left] (qualityestlabel) at ([xshift=0.5em,yshift=0.5em]base.190) {{\small\bfnew\footnotesize{人不参与}}\\{\small\bfnew\footnotesize{评价}}};
\node [anchor=south,align=left] (humanevallabel) at ([yshift=1.0em]base.-90) {{\small\bfnew\footnotesize{人直接}}\\{\small\bfnew\footnotesize{进行评价}}};
% quality estimation
\node [anchor=north east,minimum width=10em,minimum height=10em,draw=black!60,very thick,fill=ugreen!20,drop shadow] (qebox) at ([xshift=-8em]base.90) {};
\node [draw,anchor=south,minimum width=10em,align=center,draw=black!60,very thick,fill=ugreen!20,drop shadow] (qelabel) at ([yshift=0.5em]qebox.north) {\small\footnotesize{需要较为复杂的建模,}\\\small\footnotesize{开发难度同机器翻译系统}};
\node [anchor=north,minimum width=10em] (qetitle) at ([yshift=-0.2em]qebox.north) {{\small\bfnew\large{无参考答案的评价}}};
\draw [-] ([yshift=-2em]qebox.north west) -- ([yshift=-2em]qebox.north east);
\node [anchor=north] (qemethod1) at ([yshift=-0.3em]qetitle.south) {单词级评价};
\node [anchor=north] (qemethod2) at ([yshift=-0.3em]qemethod1.south) {短语级评价};
\node [anchor=north] (qemethod3) at ([yshift=-0.3em]qemethod2.south) {句子级评价};
\node [anchor=north] (qemethod4) at ([yshift=-0.3em]qemethod3.south) {篇章级评价};
% auto evaluation
\node [anchor=north west,minimum width=10em,minimum height=10em,draw=black!60,very thick,fill=red!20,drop shadow] (aebox) at ([xshift=8em]base.90) {};
\node [draw,anchor=south,minimum width=10em,align=center,draw=black!60,very thick,fill=red!20,drop shadow] (aelabel) at ([yshift=0.5em]aebox.north) {\small\footnotesize{基于指标性公式}\\\small\footnotesize{和简单的建模}};
\node [anchor=north,minimum width=10em] (aetitle) at ([yshift=-0.2em]aebox.north) {{\small\bfnew\large{有参考答案的评价}}};
\draw [-] ([yshift=-2em]aebox.north west) -- ([yshift=-2em]aebox.north east);
\node [anchor=north] (aemethod1) at ([yshift=-0.5em]aetitle.south) {BLEU、NIST、};
\node [anchor=north] (aemethod2) at ([yshift=-0.3em]aemethod1.south) {GTM、Meteor、};
\node [anchor=north] (aemethod3) at ([yshift=-0.3em]aemethod2.south) {WER、PER、TER、};
\node [anchor=north] (aemethod4) at ([yshift=-0.3em]aemethod3.south) {HTER ...};
% human evaluation
\node [anchor=north,minimum width=10em,minimum height=6em,draw=black!60,very thick,fill=yellow!20,drop shadow] (hebox) at ([yshift=-4em]base.-90) {};
\node [anchor=north,minimum width=10em] (hetitle) at ([yshift=-0.2em]hebox.north) {{\small\bfnew\large{人工评价}}};
\draw [-] ([yshift=-2em]hebox.north west) -- ([yshift=-2em]hebox.north east);
\node [anchor=north] (hemethod1) at ([yshift=-0.5em]hetitle.south) {流畅度、忠实度、};
\node [anchor=north west] (hemethod2) at ([yshift=-0.0em]hemethod1.south west) {一致性\ \ ...};
% confidence estimation
\node [anchor=east,align=left] (conf) at ([xshift=-6em,yshift=0.6em]hebox.west) {\small\bfnew{用于估计同}\\\small\bfnew{一个系统输}\\\small\bfnew{出的可信度}};
\node [anchor=north,single arrow,minimum height=4.0em,fill=blue!30,rotate=-90] (arrow1) at ([yshift=-2.4em]qebox.south) {};
% comparing different systems
\node [anchor=west,align=left] (com) at ([xshift=8em,yshift=0.6em]hebox.east) {\small\bfnew{用于对比}\\\small\bfnew{不同系统}\\\small\bfnew{的好坏}};
\node [anchor=west,single arrow,minimum height=7.5em,fill=blue!30] (arrow2) at ([yshift=-1.4em,xshift=0.5em]hebox.north east) {};
\node [anchor=north,fill=white] (arrow2label) at ([xshift=-0.5em]arrow2.south) {\footnotesize{{\color{blue} 成本高但精度高}}};
\node [anchor=north,single arrow,minimum height=4.0em,fill=blue!30,rotate=-90] (arrow3) at ([yshift=-2.4em,xshift=2.2em]aebox.south) {};
\node [anchor=west,fill=white,font=\footnotesize,align=left,text=blue,inner sep=0pt] (arrow3label) at ([yshift=2.6em,xshift=0.6em]arrow3.east) {成本低\\无人工\\有偏差};
% system optimization
\node [anchor=west,align=left] (optimization) at ([xshift=2em]aebox.east) {\small\bfnew{用于}\\\small\bfnew{机器}\\\small\bfnew{翻译}\\\small\bfnew{系统}\\\small\bfnew{的调}\\\small\bfnew{}};
\node [anchor=west,single arrow,minimum height=1.8em,fill=blue!30] (arrow4) at ([xshift=0.4em]aebox.east) {};
\begin{pgfonlayer}{background}
\draw [->,line width=0.3em,dotted,red] ([yshift=1em,xshift=0em]hebox.south east) -- ([yshift=1em,xshift=4em]hebox.south east) -- ([yshift=10em,xshift=4em]hebox.south east) node [pos=0.8,left] {\small{{\color{red} 评价标准}}};
\end{pgfonlayer}
% more arrows
\draw [->,line width=0.3em,ublue] ([yshift=-0.2em]base.-90) -- ([yshift=0.2em]hebox.north);
\draw [->,line width=0.3em,ublue] ([xshift=0.2em]base.0) -- ([xshift=2.7em]base.0);
\draw [->,line width=0.3em,ublue] ([xshift=-0.2em]base.180) -- ([xshift=-2.7em]base.180);
\end{scope}
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}[scale=0.5]
\tikzstyle{cand} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=green!30]
\tikzstyle{ref} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=red!30]
\node[align=center,minimum width=2.4em,minimum height=1.6em,minimum width=6em] (n11) at (0,0){\small\bfnew{Candidate :}};
\node[cand,anchor=west] (n12) at ([xshift=0.0em]n11.east){Can};
\node[cand,anchor=west] (n13) at ([xshift=1em]n12.east){I};
\node[cand,anchor=west] (n14) at ([xshift=1em]n13.east){have};
\node[cand,anchor=west] (n15) at ([xshift=1em]n14.east){this};
\node[cand,anchor=west] (n16) at ([xshift=1em]n15.east){like};
\node[cand,anchor=west] (n17) at ([xshift=1em]n16.east){he};
\node[cand,anchor=west] (n18) at ([xshift=1em]n17.east){do};
\node[cand,anchor=west] (n19) at ([xshift=1em]n18.east){it};
\node[cand,anchor=west] (n20) at ([xshift=1em]n19.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n21) at ([yshift=-6em]n11.south){\small\bfnew{Reference :}};
\node[ref,anchor=west] (n22) at ([xshift=0.0em]n21.east){Can};
\node[ref,anchor=west] (n23) at ([xshift=1em]n22.east){I};
\node[ref,anchor=west] (n24) at ([xshift=1em]n23.east){eat};
\node[ref,anchor=west] (n25) at ([xshift=1em]n24.east){this};
\node[ref,anchor=west] (n26) at ([xshift=1em]n25.east){Can};
\node[ref,anchor=west] (n27) at ([xshift=1em]n26.east){like};
\node[ref,anchor=west] (n28) at ([xshift=1em]n27.east){he};
\node[ref,anchor=west] (n29) at ([xshift=1em]n28.east){did};
\node[ref,anchor=west] (n30) at ([xshift=1em]n29.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,minimum width=6em] (n31) at ([yshift=-5em]n21.south){\small\bfnew{Candidate :}};
\node[cand,anchor=west] (n32) at ([xshift=0.0em]n31.east){Can};
\node[cand,anchor=west] (n33) at ([xshift=1em]n32.east){I};
\node[cand,anchor=west] (n34) at ([xshift=1em]n33.east){have};
\node[cand,anchor=west] (n35) at ([xshift=1em]n34.east){this};
\node[cand,anchor=west] (n36) at ([xshift=1em]n35.east){like};
\node[cand,anchor=west] (n37) at ([xshift=1em]n36.east){he};
\node[cand,anchor=west] (n38) at ([xshift=1em]n37.east){do};
\node[cand,anchor=west] (n39) at ([xshift=1em]n38.east){it};
\node[cand,anchor=west] (n40) at ([xshift=1em]n39.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n41) at ([yshift=-6em]n31.south){\small\bfnew{Reference :}};
\node[ref,anchor=west] (n42) at ([xshift=0.0em]n41.east){Can};
\node[ref,anchor=west] (n43) at ([xshift=1em]n42.east){I};
\node[ref,anchor=west] (n44) at ([xshift=1em]n43.east){eat};
\node[ref,anchor=west] (n45) at ([xshift=1em]n44.east){this};
\node[ref,anchor=west] (n46) at ([xshift=1em]n45.east){Can};
\node[ref,anchor=west] (n47) at ([xshift=1em]n46.east){like};
\node[ref,anchor=west] (n48) at ([xshift=1em]n47.east){he};
\node[ref,anchor=west] (n49) at ([xshift=1em]n48.east){did};
\node[ref,anchor=west] (n50) at ([xshift=1em]n49.east){?};
\draw[line width=1.6pt,blue!40] (n12.south) -- (n22.north);
\draw[line width=1.6pt,blue!40] (n13.south) -- (n23.north);
\draw[line width=1.6pt,blue!40] (n15.south) -- (n25.north);
\draw[line width=1.6pt,blue!40] (n16.south) -- (n27.north);
\draw[line width=1.6pt,blue!40] (n17.south) -- (n28.north);
\draw[line width=1.6pt,blue!40] (n20.south) -- (n30.north);
\draw[line width=2pt,orange!40] (n18.south) -- (n29.north);
\draw[line width=1.6pt,blue!40] (n32.south) -- (n46.north);
\draw[line width=1.6pt,blue!40] (n33.south) -- (n43.north);
\draw[line width=1.6pt,blue!40] (n35.south) -- (n45.north);
\draw[line width=1.6pt,blue!40] (n36.south) -- (n47.north);
\draw[line width=1.6pt,blue!40] (n37.south) -- (n48.north);
\draw[line width=1.6pt,blue!40] (n40.south) -- (n50.north);
\draw[line width=2pt,orange!40] (n38.south) -- (n49.north);
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit} = [circle,line width=1.5pt,draw,minimum size=1.5em]
\node[unit] (u1)at (0,0){};
\node[unit,anchor=west](u2) at ([xshift=5em]u1.east){};
\node[unit,anchor=west](u3) at ([xshift=5em]u2.east){};
\node[unit,anchor=west](u4) at ([xshift=2em]u3.east){};
\node[unit,anchor=west](u5) at ([xshift=4em]u4.east){};
\draw[->,out=40,in=140,red,line width=1.5pt] (u1.north east) to node[inner sep=0pt,color=red,above]{\footnotesize městská rada}(u2.north west);
\draw[->,out=-40,in=-140,red,line width=1.5pt] (u1.south east) to node[inner sep=0pt,color=red,below]{\footnotesize zastupitelstvo města}(u2.south west);
\draw[->,out=40,in=140,teal,line width=1.5pt] (u2.north east) to node[inner sep=0pt,color=teal,above]{\footnotesize schválila}(u3.north west);
\draw[->,teal,line width=1.5pt](u2.east)-- node[inner sep=0pt,color=teal,above]{\footnotesize požehnala}(u3.west);
\draw[->,out=-40,in=-140,teal,line width=1.5pt] (u2.south east) to node[inner sep=0pt,color=teal,below]{\footnotesize souhlasila s}(u3.south west);
\draw[->,line width=1.5pt](u3.east) -- node[above]{\footnotesize nový} (u4.west);
\draw[->,out=40,in=140,blue,line width=1.5pt] (u4.north east) to node[inner sep=0pt,color=blue,above]{\footnotesize předpis}(u5.north west);
\draw[->,blue,line width=1.5pt](u4.east)-- node[inner sep=0pt,color=blue,above]{\footnotesize směrnici}(u5.west);
\draw[->,out=-40,in=-140,blue,line width=1.5pt] (u4.south east) to node[inner sep=0pt,color=blue,below]{\footnotesize nařízení}(u5.south west);
\end{tikzpicture}
\begin{tikzpicture}
\tikzstyle{unit} = [circle,line width=1.5pt,draw,minimum size=1.5em]
\node[unit] (u1)at (0,0){};
\node[unit,anchor=west](u2) at ([xshift=2em]u1.east){};
\node[unit,anchor=west](u3) at ([xshift=5em]u2.east){};
\node[unit,anchor=west](u4) at ([xshift=6em]u3.east){};
\node[unit,anchor=west](u5) at ([xshift=3em]u4.east){};
\node[unit,anchor=west](u6) at ([xshift=4em]u5.east){};
\draw[->,line width=1.5pt](u1.east) -- node[above]{\footnotesize the} (u2.west);
\draw[->,out=40,in=140,red,line width=1.5pt] (u2.north east) to node[inner sep=0pt,color=red,above]{\footnotesize city council}(u3.north west);
\draw[->,out=-40,in=-140,red,line width=1.5pt] (u2.south east) to node[inner sep=0pt,color=red,below]{\footnotesize local government}(u3.south west);
\draw[->,out=40,in=140,teal,line width=1.5pt] (u3.north east) to node[inner sep=0pt,color=teal,above]{\footnotesize approved}(u4.north west);
\draw[->,teal,line width=1.5pt](u3.east)-- node[inner sep=0pt,color=teal,above]{\footnotesize gave blessing to}(u4.west);
\draw[->,out=-40,in=-140,teal,line width=1.5pt] (u3.south east) to node[inner sep=0pt,color=teal,below]{\footnotesize agreed with}(u4.south west);
\draw[->,line width=1.5pt](u4.east) -- node[above]{\footnotesize a new} (u5.west);
\draw[->,out=40,in=140,blue,line width=1.5pt] (u5.north east) to node[inner sep=0pt,color=blue,above]{\footnotesize regulation}(u6.north west);
\draw[->,blue,line width=1.5pt](u5.east)-- node[inner sep=0pt,color=blue,above]{\footnotesize decree}(u6.west);
\draw[->,out=-40,in=-140,blue,line width=1.5pt] (u5.south east) to node[inner sep=0pt,color=blue,below]{\footnotesize directive}(u6.south west);
\end{tikzpicture}
\begin{tikzpicture}
\tikzstyle{unit} = [circle,line width=1.5pt,draw,minimum size=1.5em]
\node[unit] (u1)at (0,0){};
\node[unit,anchor=west](u2) at ([xshift=7em]u1.east){};
\node[unit,anchor=west](u3) at ([xshift=1.5em]u2.east){};
\node[unit,anchor=west](u4) at ([xshift=5em]u3.east){};
\node[unit,anchor=west](u5) at ([xshift=1.5em]u4.east){};
\node[unit,anchor=west](u6) at ([xshift=5em]u5.east){};
\node[unit,anchor=west,line width=1.5pt](u7) at ([xshift=2em]u6.east){};
\node[unit,anchor=west,line width=1.5pt,minimum size=1em](u8) at ([xshift=2.25em]u6.east){};
\draw[->,out=40,in=140,red,line width=1.5pt] (u1.north east) to node[inner sep=0pt,color=red,above]{\footnotesize the level of approval}(u2.north west);
\draw[->,red,line width=1.5pt](u1.east)-- node[inner sep=0pt,color=red,above]{\footnotesize the approval rate}(u2.west);
\draw[->,out=-30,in=-150,red,line width=1.5pt] (u1.south east) to node[inner sep=0pt,color=red,below]{\footnotesize the approval level}(u2.south west);
\draw[->,line width=1.5pt](u2.east) -- node[above]{\footnotesize for} (u3.west);
\draw[->,line width=1.5pt](u3.east) -- node[above]{\footnotesize the proposal} (u4.west);
\draw[->,line width=1.5pt](u4.east) -- node[above]{\footnotesize was} (u5.west);
\draw[->,out=40,in=140,blue,line width=1.5pt] (u5.north east) to node[inner sep=0pt,color=blue,above]{\footnotesize pratically}(u6.north west);
\draw[->,blue,line width=1.5pt](u5.east)-- node[inner sep=0pt,color=blue,above]{\footnotesize close to}(u6.west);
\draw[->,out=-30,in=-150,blue,line width=1.5pt] (u5.south east) to node[inner sep=0pt,color=blue,below]{\footnotesize about equal to}(u6.south west);
\draw[->,line width=1.5pt](u6.east) -- node[above]{\footnotesize zero} (u7.west);
\end{tikzpicture}
%\usetikzlibrary{backgrounds}
%\usetikzlibrary{fit}
\begin{tikzpicture}[scale=0.5]
\tikzstyle{unit} = [draw,inner sep=1.2pt,font=\tiny,minimum height=1em]
\tikzstyle{box} = [draw=blue!40,rectangle,inner xsep=1.4pt,inner ysep=3pt,line width=1.2pt]
\tikzstyle{bad_tag} = [fill=red!15,inner sep=1pt,align=center,font=\tiny,text=red,minimum height=0.8em]
\tikzstyle{ok_tag} = [fill=ugreen!15,inner sep=1pt,align=center,font=\tiny,text=ugreen,minimum height=0.8em]
\coordinate (o) at (0, 0);
\node[anchor=west,inner sep=0pt,align=center,font=\tiny] (n1_1) at ([yshift=8em]o.east){\textbf{Source}};
\node[unit,anchor=west,fill=green!20](n1_2) at ([xshift=1.2em]n1_1.east){Bei};
\node[unit,anchor=west,fill=green!20](n1_3) at ([xshift=0.4em]n1_2.east){Patienten};
\node[unit,anchor=west,fill=green!20](n1_4) at ([xshift=0.4em]n1_3.east){mit};
\node[unit,anchor=west,fill=green!20](n1_5) at ([xshift=1em]n1_4.east){eingeschränkter};
\node[unit,anchor=west,fill=green!20](n1_6) at ([xshift=0.4em]n1_5.east){Nierenfunktion};
\node[unit,anchor=west,fill=green!20](n1_7) at ([xshift=0.4em]n1_6.east){kann};
\node[unit,anchor=west,fill=green!20](n1_8) at ([xshift=1em]n1_7.east){der};
\node[unit,anchor=west,fill=green!20](n1_9) at ([xshift=0.4em]n1_8.east){Insulinbedarf};
\node[unit,anchor=west,fill=green!20](n1_10) at ([xshift=1em]n1_9.east){infolge};
\node[unit,anchor=west,fill=green!20](n1_11) at ([xshift=0.4em]n1_10.east){des};
\node[unit,anchor=west,fill=green!20](n1_12) at ([xshift=1em]n1_11.east){verminderten};
\node[unit,anchor=west,fill=green!20](n1_13) at ([xshift=1em]n1_12.east){Insulinabbaus};
\node[unit,anchor=west,fill=green!20](n1_14) at ([xshift=1em]n1_13.east){verringert};
\node[unit,anchor=west,fill=green!20](n1_15) at ([xshift=0.4em]n1_14.east){sein};
\node[anchor=west,inner sep=0pt,align=center,font=\tiny] (n2_1) at ([yshift=-2em]o.east){\textbf{MT}};
\node[unit,anchor=west,fill=red!20](n2_2) at ([xshift=3.4em]n2_1.east){In};
\node[unit,anchor=west,fill=red!20](n2_3) at ([xshift=0.4em]n2_2.east){patients};
\node[unit,anchor=west,fill=red!20](n2_4) at ([xshift=0.4em]n2_3.east){with};
\node[unit,anchor=west,fill=red!20](n2_5) at ([xshift=1.6em]n2_4.east){renal};
\node[unit,anchor=west,fill=red!20](n2_6) at ([xshift=0.4em]n2_5.east){impairment};
\node[unit,anchor=west,fill=red!20](n2_7) at ([xshift=1em]n2_6.east){,};
\node[unit,anchor=west,fill=red!20](n2_8) at ([xshift=1em]n2_7.east){insulin};
\node[unit,anchor=west,fill=red!20](n2_9) at ([xshift=0.4em]n2_8.east){requirements};
\node[unit,anchor=west,fill=red!20](n2_10) at ([xshift=0.4em]n2_9.east){may};
\node[unit,anchor=west,fill=red!20](n2_11) at ([xshift=2.2em]n2_10.east){be};
\node[unit,anchor=west,fill=red!20](n2_12) at ([xshift=2.2em]n2_11.east){diminished};
\node[unit,anchor=west,fill=red!20](n2_13) at ([xshift=1.6em]n2_12.east){due};
\node[unit,anchor=west,fill=red!20](n2_14) at ([xshift=0.4em]n2_13.east){to};
\node[unit,anchor=west,fill=red!20](n2_15) at ([xshift=1.6em]n2_14.east){reduced};
\begin{pgfonlayer}{background}
\node [box] [fit = (n1_2) (n1_3) (n1_4)] (box1_1) {};
\node [box] [fit = (n1_5) (n1_6) (n1_7)] (box1_2) {};
\node [box] [fit = (n1_8) (n1_9)] (box1_3) {};
\node [box] [fit = (n1_10) (n1_11) ] (box1_4) {};
\node [box] [fit = (n1_12)] (box1_5) {};
\node [box] [fit = (n1_13)] (box1_6) {};
\node [box] [fit = (n1_14) (n1_15)] (box1_7) {};
\node [box] [fit = (n2_2) (n2_3) (n2_4)] (box2_1) {};
\node [box] [fit = (n2_5) (n2_6)] (box2_2) {};
\node [box] [fit = (n2_8) (n2_9) (n2_10)] (box2_3) {};
\node [box] [fit = (n2_11)] (box2_4) {};
\node [box] [fit = (n2_12)] (box2_5) {};
\node [box] [fit = (n2_13) (n2_14) ] (box2_6) {};
\node [box] [fit = (n2_15)] (box2_7) {};
\end{pgfonlayer}
\node[bad_tag,anchor=north] at ([yshift=-2pt]box2_1.south){BAD\_word\_order};
\node[bad_tag,anchor=north] at ([yshift=-2pt]box2_2.south){BAD};
\node[ok_tag,anchor=north] at ([yshift=-2pt]box2_3.south){OK};
\node[ok_tag,anchor=north] at ([yshift=-2pt]box2_4.south){OK};
\node[ok_tag,anchor=north] at ([yshift=-2pt]box2_5.south){OK};
\node[ok_tag,anchor=north] at ([yshift=-2pt]box2_6.south){OK};
\node[ok_tag,anchor=north] (tag_1) at ([yshift=-2pt]box2_7.south){OK};
\node[ok_tag,anchor=north] (gap_1) at ([xshift=-5.6em,yshift=-3em]box2_1.south){OK};
\node[ok_tag,anchor=north] (gap_2) at ([xshift=5.1em,yshift=-3em]box2_1.south){OK};
\node[ok_tag,anchor=north] (gap_3) at ([xshift=5.7em,yshift=-3em]box2_2.south){OK};
\node[ok_tag,anchor=north] (gap_4) at ([xshift=7.5em,yshift=-3em]box2_3.south){OK};
\node[bad_tag,anchor=north] (gap_5) at ([xshift=2.8em,yshift=-3em]box2_4.south){BAD\_omission};
\node[ok_tag,anchor=north] (gap_6) at ([xshift=3.5em,yshift=-3em]box2_5.south){OK};
\node[ok_tag,anchor=north] (gap_7) at ([xshift=2.7em,yshift=-3em]box2_6.south){OK};
\node[ok_tag,anchor=north] (tag_2) at ([xshift=3.1em,yshift=-3em]box2_7.south){OK};
\node[anchor=west,inner sep=0pt,align=center,font=\tiny] at ([xshift=3.6em]tag_1.east){\textbf{Phrase-target tags}};
\node[anchor=west,inner sep=0pt,align=center,font=\tiny] at ([xshift=4.8em]tag_2.east){\textbf{Gap tags}};
\draw[magenta!50,line width=1pt] (n1_2.south) -- (n2_2.north);
\draw[magenta!50,line width=1pt] (n1_3.south) -- (n2_3.north);
\draw[magenta!50,line width=1pt] (n1_3.south) -- (n2_4.north);
\draw[magenta!50,line width=1pt] (n1_4.south) -- (n2_4.north);
\draw[magenta!50,line width=1pt] (n1_5.south) -- (n2_5.north);
\draw[magenta!50,line width=1pt] (n1_6.south) -- (n2_5.north);
\draw[magenta!50,line width=1pt] (n1_6.south) -- (n2_6.north);
\draw[magenta!50,line width=1pt] (n1_7.south) -- (n2_10.north);
\draw[magenta!50,line width=1pt] (n1_8.south) -- (n2_12.north);
\draw[magenta!50,line width=1pt] (n1_9.south) -- (n2_12.north);
\draw[magenta!50,line width=1pt] (n1_10.south) -- (n2_13.north);
\draw[magenta!50,line width=1pt] (n1_10.south) -- (n2_14.north);
\draw[magenta!50,line width=1pt] (n1_12.south) -- (n2_15.north);
\draw[magenta!50,line width=1pt] (n1_13.south) -- (n2_11.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_1.north) -- ([yshift=3em]gap_1.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_2.north) -- ([yshift=3em]gap_2.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_3.north) -- ([yshift=3em]gap_3.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_4.north) -- ([yshift=3em]gap_4.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt]([xshift=-0.8em]gap_5.north) -- ([xshift=-0.8em,yshift=3em]gap_5.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_6.north) -- ([yshift=3em]gap_6.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_7.north) -- ([yshift=3em]gap_7.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](tag_2.north) -- ([yshift=3em]tag_2.north);
\end{tikzpicture}
\definecolor{ugreen}{rgb}{0,0.5,0}
\begin{tikzpicture}[scale=0.6]
\tikzstyle{unit} = [draw,inner sep=3pt,font=\tiny,minimum height=1.2em]
\tikzstyle{bad_tag} = [fill=red!15,inner sep=1pt,align=center,font=\tiny,text=red]
\tikzstyle{ok_tag} = [fill=ugreen!15,inner sep=1pt,align=center,font=\tiny,text=ugreen]
\coordinate (o) at (0, 0);
\node[anchor=west,inner sep=0pt,align=center,font=\scriptsize] (n1_1) at ([yshift=5.5em]o.east){\textbf{Source}};
\node[unit,anchor=west,fill=green!20](n1_2) at ([xshift=7.6em]n1_1.east){The};
\node[unit,anchor=west,fill=green!20](n1_3) at ([xshift=0.8em]n1_2.east){Sharpen};
\node[unit,anchor=west,fill=green!20](n1_4) at ([xshift=0.8em]n1_3.east){tool};
\node[unit,anchor=west,fill=green!20](n1_5) at ([xshift=0.8em]n1_4.east){sharpens};
\node[unit,anchor=west,fill=green!20](n1_6) at ([xshift=0.8em]n1_5.east){areas};
\node[unit,anchor=west,fill=green!20](n1_7) at ([xshift=0.8em]n1_6.east){in};
\node[unit,anchor=west,fill=green!20](n1_8) at ([xshift=0.8em]n1_7.east){an};
\node[unit,anchor=west,fill=green!20](n1_9) at ([xshift=0.8em]n1_8.east){image};
\node[unit,anchor=west,fill=green!20](n1_10) at ([xshift=0.8em]n1_9.east){.};
\node[anchor=west,inner sep=0pt,align=center,font=\scriptsize] (n2_1) at (o.east){\textbf{PE}};
\node[unit,anchor=west,fill=red!20](n2_2) at ([xshift=1em]n2_1.east){Mit};
\node[unit,anchor=west,fill=red!20](n2_3) at ([xshift=0.8em]n2_2.east){dem};
\node[unit,anchor=west,fill=red!20](n2_4) at ([xshift=0.8em]n2_3.east){Scharfzeichner};
\node[unit,anchor=west,fill=red!20](n2_5) at ([xshift=0.8em]n2_4.east){können};
\node[unit,anchor=west,fill=red!20](n2_6) at ([xshift=0.8em]n2_5.east){Sie};
\node[unit,anchor=west,fill=red!20](n2_7) at ([xshift=0.8em]n2_6.east){einzelne};
\node[unit,anchor=west,fill=red!20](n2_8) at ([xshift=0.8em]n2_7.east){Bereiche};
\node[unit,anchor=west,fill=red!20](n2_9) at ([xshift=0.8em]n2_8.east){in};
\node[unit,anchor=west,fill=red!20](n2_10) at ([xshift=0.8em]n2_9.east){einem};
\node[unit,anchor=west,fill=red!20](n2_11) at ([xshift=0.8em]n2_10.east){Bild};
\node[unit,anchor=west,fill=red!20](n2_12) at ([xshift=0.8em]n2_11.east){scharfzeichnen};
\node[unit,anchor=west,fill=red!20](n2_13) at ([xshift=0.8em]n2_12.east){.};
\node[anchor=west,inner sep=0pt,align=center,font=\scriptsize] (n3_1) at ([yshift=-5.5em]o.east){\textbf{MT}};
\node[unit,anchor=west,fill=blue!20](n3_2) at ([xshift=4.7em]n3_1.east){Der};
\node[unit,anchor=west,fill=blue!20](n3_3) at ([xshift=0.8em]n3_2.east){Schärfen-Werkezug};
\node[unit,anchor=west,fill=blue!20](n3_4) at ([xshift=0.8em]n3_3.east){Bereiche};
\node[unit,anchor=west,fill=blue!20](n3_5) at ([xshift=0.8em]n3_4.east){in};
\node[unit,anchor=west,fill=blue!20](n3_6) at ([xshift=0.8em]n3_5.east){einem};
\node[unit,anchor=west,fill=blue!20](n3_7) at ([xshift=0.8em]n3_6.east){Bild};
\node[unit,anchor=west,fill=blue!20](n3_8) at ([xshift=0.8em]n3_7.east){Schärfer};
\node[unit,anchor=west,fill=blue!20](n3_9) at ([xshift=0.8em]n3_8.east){erscheint};
\node[unit,anchor=west,fill=blue!20](n3_10) at ([xshift=0.8em]n3_9.east){.};
\node[bad_tag,anchor=south] at ([yshift=2pt]n1_2.north){BAD};
\node[bad_tag,anchor=south] at ([yshift=2pt]n1_3.north){BAD};
\node[bad_tag,anchor=south] at ([yshift=2pt]n1_4.north){BAD};
\node[bad_tag,anchor=south] at ([yshift=2pt]n1_5.north){BAD};
\node[ok_tag,anchor=south] at ([yshift=2pt]n1_6.north){OK};
\node[ok_tag,anchor=south] at ([yshift=2pt]n1_7.north){OK};
\node[ok_tag,anchor=south] at ([yshift=2pt]n1_8.north){OK};
\node[ok_tag,anchor=south] at ([yshift=2pt]n1_9.north){OK};
\node[ok_tag,anchor=south] (tag1) at ([yshift=2pt]n1_10.north){OK};
\node[bad_tag,anchor=north] at ([yshift=-2pt]n3_2.south){BAD};
\node[bad_tag,anchor=north] at ([yshift=-2pt]n3_3.south){BAD};
\node[ok_tag,anchor=north] at ([yshift=-2pt]n3_4.south){OK};
\node[ok_tag,anchor=north] at ([yshift=-2pt]n3_5.south){OK};
\node[ok_tag,anchor=north] at ([yshift=-2pt]n3_6.south){OK};
\node[ok_tag,anchor=north] at ([yshift=-2pt]n3_7.south){OK};
\node[bad_tag,anchor=north] at ([yshift=-2pt]n3_8.south){BAD};
\node[bad_tag,anchor=north] at ([yshift=-2pt]n3_9.south){BAD};
\node[ok_tag,anchor=north] (tag2) at ([yshift=-2pt]n3_10.south){OK};
\node[bad_tag,anchor=north] (gap_1)at ([xshift=-2em,yshift=-2em]n3_2.south){BAD};
\node[ok_tag,anchor=north] (gap_2)at ([xshift=1.6em,yshift=-2em]n3_2.south){OK};
\node[bad_tag,anchor=north] (gap_3)at ([xshift=4.4em,yshift=-2em]n3_3.south){BAD};
\node[ok_tag,anchor=north] (gap_4)at ([xshift=2.5em,yshift=-2em]n3_4.south){OK};
\node[ok_tag,anchor=north] (gap_5)at ([xshift=1.3em,yshift=-2em]n3_5.south){OK};
\node[ok_tag,anchor=north] (gap_6)at ([xshift=2em,yshift=-2em]n3_6.south){OK};
\node[ok_tag,anchor=north] (gap_7)at ([xshift=1.7em,yshift=-2em]n3_7.south){OK};
\node[ok_tag,anchor=north] (gap_8)at ([xshift=2.4em,yshift=-2em]n3_8.south){OK};
\node[ok_tag,anchor=north] (gap_9)at ([xshift=2.5em,yshift=-2em]n3_9.south){OK};
\node[ok_tag,anchor=north](tag3) at ([xshift=1.3em,yshift=-2em]n3_10.south){OK};
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_1.north) -- ([yshift=2em]gap_1.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_2.north) -- ([yshift=2em]gap_2.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_3.north) -- ([yshift=2em]gap_3.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_4.north) -- ([yshift=2em]gap_4.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_5.north) -- ([yshift=2em]gap_5.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_6.north) -- ([yshift=2em]gap_6.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_7.north) -- ([yshift=2em]gap_7.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_8.north) -- ([yshift=2em]gap_8.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](gap_9.north) -- ([yshift=2em]gap_9.north);
\draw[dash pattern=on 2pt off 1pt,gray,line width=1pt](tag3.north) -- ([yshift=2em]tag3.north);
\draw [line width=1pt](n1_2.south) -- (n2_3.north);
\draw [line width=1pt](n1_3.south) -- (n2_4.north);
\draw [line width=1pt](n1_4.south) -- (n2_4.north);
\draw [line width=1pt](n1_5.south) -- (n2_12.north);
\draw [line width=1pt](n1_6.south) -- (n2_8.north);
\draw [line width=1pt](n1_7.south) -- (n2_9.north);
\draw [line width=1pt](n1_8.south) -- (n2_10.north);
\draw [line width=1pt](n1_9.south) -- (n2_11.north);
\draw [line width=1pt](n1_10.south) -- (n2_13.north);
\draw[line width=1pt,red!60] (n2_3.south) -- (n3_2.north);
\draw[line width=1pt,red!60] (n2_4.south) -- (n3_3.north);
\draw[line width=1pt,ugreen!60] (n2_8.south) -- (n3_4.north);
\draw[line width=1pt,ugreen!60] (n2_9.south) -- (n3_5.north);
\draw[line width=1pt,ugreen!60] (n2_10.south) -- (n3_6.north);
\draw[line width=1pt,ugreen!60] (n2_11.south) -- (n3_7.north);
\draw[line width=1pt,red!60] (n2_12.south) -- (n3_8.north);
\draw[line width=1pt,ugreen!60] (n2_13.south) -- (n3_10.north);
\node[anchor=west,inner sep=0pt,align=center,font=\scriptsize] at ([xshift=4.6em]tag1.east){\textbf{Source tags}};
\node[anchor=west,inner sep=0pt,align=center,font=\scriptsize] at ([xshift=2.6em]tag2.east){\textbf{MT tags}};
\node[anchor=west,inner sep=0pt,align=center,font=\scriptsize] at ([xshift=1.1em]tag3.east){\textbf{Gap tags}};
\end{tikzpicture}
\ No newline at end of file
\begin{tikzpicture}
\tikzstyle{unit1} = [inner sep=1pt,align=center,font=\footnotesize]
\tikzstyle{unit2} = [inner sep=1pt,align=center,font=\scriptsize]
\node[unit1] (n1) at (0,0){单词分布式表示};
\node[unit2,anchor=west] (n11) at ([xshift=1em,yshift=4em]n1.east){one-hot词向量};
\node[unit2,anchor=west] (n12) at ([xshift=1em,yshift=2.4em]n1.east){Word2Vec词向量};
\node[unit2,anchor=west] (n13) at ([xshift=1em,yshift=0.8em]n1.east){GloVe词向量};
\node[unit2,anchor=west] (n14) at ([xshift=1em,yshift=-0.8em]n1.east){};
\node[unit2,anchor=west] (n15) at ([xshift=1em,yshift=-2.4em]n1.east){ELMO预训练词向量};
\node[unit2,anchor=west] (n16) at ([xshift=1em,yshift=-4em]n1.east){BERT预训练词向量};
\draw[decorate,decoration={brace,mirror,amplitude=2mm}] ([xshift=-0.3em]n11.west) -- ([xshift=-0.3em]n16.west);
\node[unit1,anchor=west] (n2) at ([xshift=9em]n1.east){句子分布式表示};
\node[unit2,anchor=west] (n21) at ([xshift=1em,yshift=4.2em]n2.east){RAE编码};
\node[unit2,anchor=west] (n22) at ([xshift=1em,yshift=2.8em]n2.east){Doc2Vec向量};
\node[unit2,anchor=west] (n23) at ([xshift=1em,yshift=1.4em]n2.east){ELMO预训练句子表示};
\node[unit2,anchor=west] (n24) at ([xshift=1em,yshift=0em]n2.east){};
\node[unit2,anchor=west] (n25) at ([xshift=1em,yshift=-1.4em]n2.east){GPT句子表示};
\node[unit2,anchor=west] (n26) at ([xshift=1em,yshift=-2.8em]n2.east){BERT预训练句子表示};
\node[unit2,anchor=west] (n27) at ([xshift=1em,yshift=-4.2em]n2.east){skip-thought向量};
\draw[decorate,decoration={brace,mirror,amplitude=2mm}] ([xshift=-0.3em]n21.west) -- ([xshift=-0.3em]n27.west);
\end{tikzpicture}
\definecolor{ugreen}{rgb}{0,0.5,0}
\begin{tikzpicture}[scale=0.5]
\tikzstyle{cand} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=green!30]
\tikzstyle{ref} = [draw,line width=1pt,align=center,minimum width=2.6em,minimum height=1.6em,drop shadow={shadow xshift=0.15em},fill=red!30]
\node[align=center,minimum width=2.4em,minimum height=1.6em,minimum width=6em] (n11) at (0,0){\small\bfnew{Candidate :}};
\node[cand,anchor=west] (n12) at ([xshift=0.0em]n11.east){Can};
\node[cand,anchor=west] (n13) at ([xshift=1em]n12.east){I};
\node[cand,anchor=west] (n14) at ([xshift=1em]n13.east){have};
\node[cand,anchor=west] (n15) at ([xshift=1em]n14.east){this};
\node[cand,anchor=west] (n16) at ([xshift=1em]n15.east){like};
\node[cand,anchor=west] (n17) at ([xshift=1em]n16.east){he};
\node[cand,anchor=west] (n18) at ([xshift=1em]n17.east){do};
\node[cand,anchor=west] (n19) at ([xshift=1em]n18.east){it};
\node[cand,anchor=west] (n20) at ([xshift=1em]n19.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n21) at ([yshift=-6em]n11.south){\small\bfnew{Reference :}};
\node[ref,anchor=west] (n22) at ([xshift=0.0em]n21.east){Can};
\node[ref,anchor=west] (n23) at ([xshift=1em]n22.east){I};
\node[ref,anchor=west] (n24) at ([xshift=1em]n23.east){eat};
\node[ref,anchor=west] (n25) at ([xshift=1em]n24.east){this};
\node[ref,anchor=west] (n26) at ([xshift=1em]n25.east){Can};
\node[ref,anchor=west] (n27) at ([xshift=1em]n26.east){like};
\node[ref,anchor=west] (n28) at ([xshift=1em]n27.east){he};
\node[ref,anchor=west] (n29) at ([xshift=1em]n28.east){did};
\node[ref,anchor=west] (n30) at ([xshift=1em]n29.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n31) at ([yshift=-5em]n21.south){\small\bfnew{Candidate :}};
\node[cand,anchor=west] (n32) at ([xshift=0.0em]n31.east){Can};
\node[cand,anchor=west] (n33) at ([xshift=1em]n32.east){I};
\node[cand,anchor=west] (n34) at ([xshift=1em]n33.east){have};
\node[cand,anchor=west] (n35) at ([xshift=1em]n34.east){this};
\node[cand,anchor=west] (n36) at ([xshift=1em]n35.east){like};
\node[cand,anchor=west] (n37) at ([xshift=1em]n36.east){he};
\node[cand,anchor=west] (n38) at ([xshift=1em]n37.east){do};
\node[cand,anchor=west] (n39) at ([xshift=1em]n38.east){it};
\node[cand,anchor=west] (n40) at ([xshift=1em]n39.east){?};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n41) at ([yshift=-6em]n31.south){\small\bfnew{Candidate :}};
\node[ref,anchor=west] (n42) at ([xshift=0.0em]n41.east){Can};
\node[ref,anchor=west] (n43) at ([xshift=1em]n42.east){I};
\node[ref,anchor=west] (n44) at ([xshift=1em]n43.east){eat};
\node[ref,anchor=west] (n45) at ([xshift=1em]n44.east){this};
\node[ref,anchor=west] (n46) at ([xshift=1em]n45.east){Can};
\node[ref,anchor=west] (n47) at ([xshift=1em]n46.east){like};
\node[ref,anchor=west] (n48) at ([xshift=1em]n47.east){he};
\node[ref,anchor=west] (n49) at ([xshift=1em]n48.east){did};
\node[ref,anchor=west] (n50) at ([xshift=1em]n49.east){?};
\draw[line width=1.6pt,blue!40] (n12.south) -- (n22.north);
\draw[line width=1.6pt,blue!40] (n13.south) -- (n23.north);
\draw[line width=1.6pt,blue!40] (n15.south) -- (n25.north);
\draw[line width=1.6pt,blue!40] (n16.south) -- (n27.north);
\draw[line width=1.6pt,blue!40] (n17.south) -- (n28.north);
\draw[line width=1.6pt,blue!40] (n20.south) -- (n30.north);
\draw[line width=1.6pt,orange!40] (n18.south) -- (n29.north);
\draw[line width=2pt,ugreen!40](n14.south) -- (n24.north);
\draw[line width=1.6pt,blue!40] (n32.south) -- (n46.north);
\draw[line width=1.6pt,blue!40] (n33.south) -- (n43.north);
\draw[line width=1.6pt,blue!40] (n35.south) -- (n45.north);
\draw[line width=1.6pt,blue!40] (n36.south) -- (n47.north);
\draw[line width=1.6pt,blue!40] (n37.south) -- (n48.north);
\draw[line width=1.6pt,blue!40] (n40.south) -- (n50.north);
\draw[line width=1.6pt,orange!40] (n38.south) -- (n49.north);
\draw[line width=2pt,ugreen!40](n34.south) -- (n44.north);
\end{tikzpicture}
......@@ -15,7 +15,7 @@
\renewcommand\figurename{}%将figure改为图
\renewcommand\tablename{}%将figure改为图
\chapterimage{fig-NEU-4.jpg} % Chapter heading image
\chapterimage{fig-NEU-2.jpg} % Chapter heading image
%----------------------------------------------------------------------------------------
% CHAPTER 4
......@@ -23,8 +23,868 @@
\chapter{翻译质量评价}
\parinterval 人们在使用机器翻译系统时需要评估系统输出结果的质量。这个过程也被称作机器翻译译文质量评价,简称为{\small\sffamily\bfseries{译文质量评价}}\index{译文质量评价}(Quality Evaluation of Translation)\index{Quality Evaluation of Translation}。在机器翻译的发展进程中,译文质量评价有着非常重要的作用。不论在系统研发的反复迭代中,还是在诸多的机器翻译应用场景中,都存在大量的译文质量评价环节。从某种意义上说,没有译文质量评价,机器翻译也不会发展成今天的样子。比如,本世纪初研究人员提出了译文质量自动评价方法BLEU\upcite{DBLP:conf/acl/PapineniRWZ02}。该方法使得机器系统的评价变得自动、快速、便捷,而且评价过程可以重复。正是由于BLEU等自动评价方法的提出,机器翻译研究人员可以在更短的时间内得到译文质量的评价结果,加速系统研发的进程。
\parinterval 时至今日,译文质量评价方法已经非常丰富,针对不同的使用场景研究人员陆续提出了不同的方法。本章将会对其中的典型方法进行介绍,包括:人工评价、有参考答案自动评价、无参考答案自动评价等。相关方法及概念也会在本章的后续章节中被广泛使用。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{译文质量评价所面临的挑战}
\parinterval 一般来说,译文质量评价可以被看作是一个对译文进行打分或者排序的过程,打分或者排序的结果代表了翻译质量的好坏。比如,表\ref{tab:4-1}展示一个汉译英的译文质量评价结果。这里采用了5分制打分,1代表最低分,5代表最高分。可以看出,流畅的高质量译文分较高,相反,存在问题的译文得分较低。
\begin{table}[htp]{
\begin{center}
\caption{汉译英译文质量评价实例}
{
\begin{tabular}{c|l|c}
源文 & 那只敏捷的棕色狐狸跳过了那只懒惰的狗。 & 评价得分 \\
\hline
\rule{0pt}{10pt} 机器译文1 & The quick brown fox jumped over the lazy dog. & 5 \\
\rule{0pt}{10pt} 机器译文2 & The fast brown fox jumped over a sleepy dog. & 4 \\
\rule{0pt}{10pt} 机器译文3 & The fast brown fox jumps over the dog. & 3 \\
\rule{0pt}{10pt} 机器译文4 & The quick brown fox jumps over dog. & 2 \\
\rule{0pt}{10pt} 机器译文5 & A fast fox jump dog. & 1 \\
\end{tabular}
\label{tab:4-1}
}
\end{center}
}\end{table}
\parinterval 这里的一个核心问题是:从哪个角度对译文质量进行评价呢?常用的标准有:{\small\sffamily\bfseries{流畅度}}\index{流畅度}(Fluency)\index{Fluency}{\small\sffamily\bfseries{忠实度}}\index{忠实度}(Adequacy)\index{Adequacy}\upcite{DBLP:journals/mt/ChurchH93}。其中流畅度是指译文在目标语言中的流畅程度,越通顺的译文流畅度越高;忠实度是指译文表达源文意思的程度,如果译文能够全面、准确的表达源文的意思,那么它具有较高的翻译忠实度。在一些极端的情况下,译文可以非常流畅,但是与源文完全不对应。或者,译文可以非常好的对应源文,但是读起来非常不连贯。这些译文都不是很好的译文。
\parinterval 传统观点把翻译分为``信''、``达''、``雅''三个层次,而忠实度体现的是一种``信''的思想,而流畅度体现的是一种``达''的思想。不过``雅''在机器翻译评价中还不是一个常用的标准,而且机器翻译还没有达到``雅''的水平,是未来所追求的目标。
\parinterval 给定评价标准,译文质量评价有很多实现方式。比如,可以使用人工评价的方式让评委对每个译文进行打分(\ref{Manual evaluation}节),也可以用自动评价的方式让计算机比对译文和参考答案之间的匹配的程度(\ref{Automatic evaluation with reference answers}节)。但是,自然语言的翻译是最复杂的人工智能问题之一。这不仅仅体现在相关问题的建模和系统实现的复杂性上,译文质量评价也同样面临着诸多挑战。
\begin{itemize}
\vspace{0.5em}
\item {\small\sffamily\bfseries{译文不唯一}}。自然语言表达的丰富性决定了同一个意思往往有很多种表达方式。同一句话,由不同译者的翻译也往往存在差异。译者的背景、翻译水平、翻译所处的语境,甚至译者的情绪都会对译文产生影响。如何在评价过程中尽可能考虑多样的译文,是译文质量评价中最具挑战的问题之一。
\vspace{0.5em}
\item {\small\sffamily\bfseries{评价标准不唯一}}。虽然流畅度和忠实度给译文质量评价提供了很好的参考依据,但是在实践中往往会有更多样的需求。比如,在专利翻译中,术语翻译的准确性就是必须要考虑的因素,一个术语的翻译错误会导致整个译文不可用。此外,术语翻译的一致性也是非常重要的,即使同一个术语有多种正确的译文,但是在同一个专利文档中,术语翻译需要保持一致。不同的需求使得很难用统一的标准对译文质量进行评价。在实践中,往往需要针对不同应用场景设计不同的评价标准。
\vspace{0.5em}
\item {\small\sffamily\bfseries{自动评价与人工评价存在着偏差}}。固然使用人工的方式可以准确地评估译文质量,但是这种方式费时、费力。而且由于人工评价的主观性,其结果不易重现,也就是不同人的评价结果会有差异。这些因素也造成了人工评价不能被过于频繁的使用。翻译质量的自动评价可以充分利用计算机的计算能力,对译文与参考答案进行比对,具有速度快、结果可重现的优点,但是其精度不如人工评价。使用何种评价方法也是实践中需要考虑的重要问题之一。
\vspace{0.5em}
\item {\small\sffamily\bfseries{参考答案不容易获得}}。很多情况下,译文的正确答案并不容易获取。甚至对于某些低资源语种,相关的语言学家都很稀缺。这时很难进行基于标准答案的评价。如何在没有参考答案的情况下对译文质量进行估计是极具应用前景且颇具挑战的方向。
\vspace{0.5em}
\end{itemize}
\parinterval 针对以上问题,研究人员设计出多种不同的译文质量评价方法。根据人工参与方式的不同,可以分为人工评价、有参考答案的自动评价、无参考答案的自动评价。这些方法也对应了不同的使用场景。
\begin{itemize}
\vspace{0.5em}
\item {\small\sffamily\bfseries{人工评价}}。当需要对系统进行准确的评估时,往往采用人工评价。比如,对于机器翻译的一些互联网应用,在系统上线前都会采用人工评价对机器翻译系统性能进行测试。当然,这种方法的时间和人力成本是最高的。
\vspace{0.5em}
\item {\small\sffamily\bfseries{有参考答案的自动评价}}。由于机器翻译系统研发过程中需要频繁地对系统性能进行评价,这时可以让人标注一些正确的译文,之后把这些译文作为参考答案与机器翻译系统输出的结果进行比对。这种自动评价的结果获取成本低,可以多次重复,而且可以用于对系统结果的快速反馈,指导系统优化的方向。
\vspace{0.5em}
\item {\small\sffamily\bfseries{无参考答案的自动评价}}。在很多应用场景中,在系统输出译文时,使用者希望提前知道译文的质量,即使这时并没有可比对的参考答案。这样,系统使用者可以根据这个对质量的``估计''结果有选择地使用机器翻译译文。严格意义上说,这并不是一个传统的译文质量评价方法,而是一种对译文置信度和可能性的估计。
\vspace{0.5em}
\end{itemize}
\parinterval\ref{fig:4-2}给出了机器翻译译文评价方法的逻辑关系图。需要注意的是,很多时候,译文质量评价结果是用于机器翻译系统优化的。在随后的章节中也会看到,译文评价的结果会被用于不同的机器翻译模型优化中。甚至说,很多统计指标(如极大似然)也可以被看作是一种对译文的``评价'',这样也就把机器翻译的建模和译文评价联系在了一起。本章的后半部分将重点介绍传统的译文质量评价方法。与译文质量评价相关的模型优化方法将会在后续章节详细论述。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter4/Figures/logic-diagram-of-translation-quality-evaluation-method}
\caption{译文质量评价方法逻辑图}
\label{fig:4-2}
\end{figure}
%----------------------------------------------
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{人工评价}\label{Manual evaluation}
\parinterval 顾名思义,人工评价是指评价者根据翻译结果好坏对译文进行评价。例如,可以根据句子的忠实度和流畅度对其进行打分,这样能够准确评定出译文是否准确翻译出源文的意思以及译文是否通顺。在人工评价时,一般由多个评价者匿名对译文打分,之后综合所有评价者的评价结果给出最终的得分。人工评价可以准确反映句子的翻译质量,是最权威、可信度最高的评价方法,但是其缺点也十分明显:需要耗费人力物力,而且评价的周期长,不能及时得到有效的反馈。因此在实际系统开发中,纯人工评价不会过于频繁的被使用,它往往和自动评价一起配合,帮助系统研发人员准确的了解当前系统的状态。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{评价策略}
\parinterval 合理的评价指标是人工评价得以顺利进行的基础。机器译文质量的人工评价可以追溯到1966年,自然语言处理咨询委员会提出{\small\sffamily\bfseries{可理解度}}\index{可理解度}(Intelligibility)\index{Intelligibility}{\small\sffamily\bfseries{忠诚度}}\index{忠诚度}(Fidelity)\index{Fidelity}作为机器译文质量人工评价指标\upcite{DBLP:journals/mtcl/Carroll66}。1994 年,{\small\sffamily\bfseries{充分性}}\index{充分性}(Adequacy)\index{Adequacy}{\small\sffamily\bfseries{流利度}}\index{流利度}(Fluency)\index{Fluency}{\small\sffamily\bfseries{信息性}}\index{信息性}(Informativeness)\index{Informativeness}成为为ARPA MT\footnote{ARPA MT计划是美国高级研究计划局软件和智能系统技术处人类语言技术计划的一部分。}的人工评价标准\upcite{DBLP:conf/amta/WhiteOO94}。此后,有不少研究者提出了更多的机器译文质量人工评估指标,例如将{\small\sffamily\bfseries{清晰度}}\index{清晰度}(Clarity)\index{Clarity}{\small\sffamily\bfseries{连贯性}}\index{连贯性}(Coherence)\index{Coherence}加入人工评价指标中\upcite{Miller:2005:MTS}。甚至有人将各种人工评价指标集中在一起,组成了尽可能全面的机器翻译评估框架\upcite{king2003femti}
\parinterval 人工评价的策略非常多。考虑不同的因素,往往会使用不同的评价方案,比如:
\begin{itemize}
\vspace{0.5em}
\item {\small\sffamily\bfseries{是否呈现源语言文本}}。在进行人工评价时,可以向评价者提供源语言文本或参考答案,也可以同时提供源语言文本和参考答案。从评价的角度,参考答案已经能够帮助评价者进行正确评价,但是源语言文本可以提供更多信息帮助评估译文的准确性。
\vspace{0.5em}
\item {\small\sffamily\bfseries{评价者选择}}。理想情况下,评价者应同时具有源语言和目标语言的语言能力。但是,很多时候双语能力的评价者很难招募,因此这时会考虑使用目标语为母语的评价者。配合参考答案,单语评价者也可以准确地评价译文质量。
\vspace{0.5em}
\item {\small\sffamily\bfseries{多个系统同时评价}}。如果有多个不同系统的译文需要评价,可以直接使用每个系统单独打分的方法。但是,如果仅仅是想了解不同译文之间的相对好坏,也可以采用竞评的方式,即对于每个句子,对不同系统根据译文质量进行排序,这样做的效率会高于直接打分,而且评价准确性也能够得到保证。
\vspace{0.5em}
\item {\small\sffamily\bfseries{数据选择}}。评价数据一般需要根据目标任务进行采集,为了避免和系统训练数据重复,往往会搜集最新的数据。而且,评价数据的规模越大,评价结果越科学。常用的做法是搜集一定量的评价数据,之后从中采样出所需的数据。由于不同的采样会得到不同的评价集合,这样的方法可以复用多次,得到不同的测试集。
\vspace{0.5em}
\item {\small\sffamily\bfseries{面向应用的评价}}。除了人工直接打分,一种更有效的方法是把机器翻译的译文嵌入到下游应用中,通过机器翻译对下游应用的改善效果评估机器翻译译文质量。比如,可以把机器翻译放入译后编辑流程中,通过对比译员翻译效率的提升来评价译文质量。再比如,把机器翻译放入线上应用中,通过点击率或者用户反馈来评价机器翻译的品质。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{打分标准} \label{sec:human-eval-scoring}
\parinterval 如何对译文进行打分是机器翻译评价的核心问题。在人工评价方法中,一种被广泛使用的方法是{\small\sffamily\bfseries{直接评估}}\index{直接评估}(Direct Assessment,DA)\index{Direct Assessment}\upcite{DBLP:conf/amta/WhiteOO94},这种评价方法需要评价者给出对机器译文的绝对评分:在给定一个机器译文和一个参考答案的情况下,评价者直接给出1-100的分数用来表征机器译文的质量。与其类似的策略是对机器翻译质量进行等级评定\upcite{DBLP:journals/mt/PrzybockiPBS09},常见的是在5级或7级标准中指定单一等级用以反映机器翻译质量。也有研究者提出利用语言测试技术对机器翻译质量进行评价\upcite{reeder2006direct},其中涉及多等级内容的评价:第一等级测试简单的短语、成语、词汇等;第二等级利用简单的句子测试机器翻译在简单文本上的表现;第三等级利用稍复杂的句子测试机器翻译在复杂语法结构上的表现;第四等级测试引入更加复杂的补语结构和附加语等等。
\parinterval 除了对译文进行简单的打分,另一种经典的人工评价方法是{\small\sffamily\bfseries{相对排序}}\index{相对排序}(Relative Ranking,RR)\index{Relative Ranking}\upcite{DBLP:conf/wmt/Callison-BurchF07}。这种方法通过对不同机器翻译的译文质量进行相对排序得到最终的评价结果。举例来说:
\parinterval (1)在每次评价过程中,若干个等待评价的机器翻译系统被分为5个一组,评价者被提供3个连续的源文片段和1组机器翻译系统的相应译文;
\parinterval (2)评价者需要对本组的机器译文根据其质量进行排序,不过评价者并不需要一次性将5个译文排序,而是将其两两进行比较,判出胜负或是平局。在评价过程中,由于排序是两两一组进行的,为了评价的公平性,将采用排列组合的方式进行分组和比较,若共有$n$个机器翻译系统,则会为被分为 $\mathrm{C}_n^5$组,组内每个系统都将与其他4个系统进行比较,由于需要针对3个源文片段进行评价对比,则意味着每个系统都需要被比较$\mathrm{C}_n^5 \times 4 \times 3$次;
\parinterval (3)最终根据多次比较的结果,对所有参与评价的系统进行总体排名。对于如何获取合理的总体排序,有三种常见的策略:
\begin{itemize}
\vspace{0.5em}
\item {\small\sffamily\bfseries{根据系统胜出的次数进行排序}}\upcite{DBLP:conf/wmt/Callison-BurchK12}。以系统${S}_j$和系统${S}_k$为例,两个系统都被比较了$\mathrm{C}_n^5 \times 4 \times 3$ 次,其中系统${S}_j$获胜20次,系统${S}_k$获胜30次,总体排名中系统${S}_k$优于系统${S}_j$
\vspace{0.5em}
\item {\small\sffamily\bfseries{根据冲突次数进行排序}}\upcite{DBLP:conf/wmt/Lopez12}。第一种排序策略中存在冲突现象:例如在每次两两比较中,系统${S}_j$胜过系统${S}_k$ 的次数比系统${S}_j$不敌系统${S}_k$的次数多,若待评价系统仅有系统${S}_j$${S}_k$,显然系统${S}_j$的排名高于系统${S}_k$。但当待评价系统很多时,可能系统${S}_j$在所有比较中获胜的次数低于系统${S}_k$,此时就出现了总体排序与局部排序不一致的冲突。因此,有研究者提出,能够与局部排序冲突最少的总体排序才是最合理的。令$R$表示一个对若干个系统的排序,该排序所对应的冲突得分为:
\begin{eqnarray}
\mathrm{score}(R) = \sum\limits_{{{S}_j} \in R,{{S}_k} \in R,j \ne k} {{\rm{max}}(0,\mathrm{Count}_{win}({{S}_j},{{S}_k}) - \mathrm{Count}_{loss}({{S}_j},{{S}_k}))}
\label{eq:4-1}
\end{eqnarray}
其中,${S}_j$${S}_k$是成对比较的两个系统,$\mathrm{Count}_{win}({S}_j,{S}_k)$$\mathrm{Count}_{loss}({S}_j,{S}_k)$分别是${S}_j$${S}_k$进行成对比较时系统${S}_j$ 胜利和失败的次数。而使得$\textrm{score}(R)$得分最低的$R$就是最终的系统排序结果。
\vspace{0.5em}
\item {\small\sffamily\bfseries{根据某系统最终获胜的期望进行排序}}\upcite{DBLP:conf/iwslt/Koehn12}。以系统$\mathrm{S}_j$为例,若共有$n$个待评价的系统,则进行总体排序时系统 $\mathrm{S}_j$ 的得分为其最终获胜的期望,即:
\begin{eqnarray}
\mathrm{score}({{S}_j}) = \frac{1}{n}\sum\limits_{k,k \ne j} {\frac{\mathrm{Count}_{win}({{S}_j},{{S}_k})}{{\mathrm{Count}_{win}({{S}_j},{{S}_k}) + \mathrm{Count}_{loss}({{S}_j},{{S}_k})}}}
\label{eq:4-2}
\end{eqnarray}
根据公式\ref{eq:4-2}可以看出,该策略去除了平局的影响。
\vspace{0.5em}
\end{itemize}
\parinterval 与相对排序相比,直接评估方法虽然更加直观,但是过度依赖评价者的主观性,因而直接评估适用于直观反映某机器翻译系统性能,而不适合用来比较机器翻译系统之间的性能差距。在需要对大量系统的进行快速人工评价时,找出不同译文质量之间的相关关系要比直接准确评估译文质量简单的多,基于排序的评价方法可以大大降低评价者的工作量,所以也被系统研发人员经常使用。
\parinterval 在实际应用中,研究者可以根据实际情况选择不同的人工评价方案,人工评价也没有统一的标准。WMT 和CCMT 机器翻译评测都有配套的人工评价方案\upcite{DBLP:conf/wmt/BojarCFHHHKLMNP15},可以作为业界的参考标准。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{有参考答案的自动评价}\label{Automatic evaluation with reference answers}
\parinterval 人工评价费事费力,同时具有一定的主观性,甚至不同人在不同时刻面对同一篇文章的理解都会不同。为了克服这些问题,另一种思路是将人类专家翻译的结果看作是参考答案,将译文与答案的近似程度作为评价结果。即译文与答案越接近,评价结果越好;反之,评价结果较差。这种评价方式叫做{\small\bfnew{自动评价}}\index{自动评价}(Automatic Evaluation)。自动评价具有速度快,成本低、一致性高的优点,因此自动评价是也是机器翻译系统研发人员所青睐的方法。
\parinterval 随着评价技术的不断发展,自动评价结果已经具有了比较好的指导性,可以帮助使用者快速了解当前译文的质量。在机器翻译领域,自动评价已经成为了一个重要的研究分支。至今,已经有不下几十种自动评价方法被提出。这里无法对这些方法一一列举,为了便于后续章节中对自动评价方法的使用,这里仅对一些代表性的方法进行简要介绍。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{基于词串比对的方法}
\parinterval 这种方法比较关注译文单词及$n$-gram的翻译准确性。其思想是将译文看成是符号序列,通过计算参考答案和机器译文间的序列相似性来评价机器翻译的质量。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{1.基于距离的方法}
\parinterval 基于距离的自动评价方法的基本思想是:将机器译文转化为参考答案所需要的最小编辑步骤数作为译文质量的度量,基于此类思想的自动评价方法主要有{\small\sffamily\bfseries{单词错误率}}\index{单词错误率}(Word Error Rate,WER)\index{Word Error Rate}\upcite{DBLP:conf/coling/SuWC92}{\small\sffamily\bfseries{与位置无关的单词错误率}}\index{与位置无关的单词错误率}(Position-independent word Error Rate,PER)\index{Position-independent word Error Rate}\upcite{DBLP:conf/interspeech/TillmannVNZS97}{\small\sffamily\bfseries{翻译错误率}}\index{翻译错误率}(Translation Error Rate,TER)\index{Translation Error Rate}\upcite{snover2006study}等。下面介绍其中比较有代表性的方法\ \dash \ 翻译错误率,即TER。
\parinterval TER是一种典型的基于距离的评价方法,通过评定机器译文的译后编辑工作量来衡量机器译文质量。在这里``距离''被定义为将一个序列转换成另一个序列所需要的最少编辑操作次数,操作次数越多,距离越大,序列之间的相似性越低;相反距离越小,表示一个句子越容易改写成另一个句子,序列之间的相似性越高。TER 使用的编辑操作包括:增加、删除、替换和移位。其中增加、删除、替换操作计算得到的距离被称为编辑距离。TER根据错误率的形式给出评分:
\begin{eqnarray}
\mathrm{score}= \frac{\mathrm{edit}(o,g)}{l}
\label{eq:4-3}
\end{eqnarray}
\noindent 其中,$\mathrm{edit}(o,g)$表示系统生成的译文$o$和参考答案$g$之间的距离,$l$是归一化因子,通常为参考答案的长度。在距离计算中所有的操作的代价都为1。在计算距离时,优先考虑移位操作,再计算编辑距离(即增加、删除和替换操作的次数)。直到增加、移位操作无法减少编辑距离时,将编辑距离和移位操作的次数累加得到TER计算的距离。
\begin{example}
Candidate:cat is standing in the ground
\qquad\ Reference:The cat is standing on the ground
\label{eg:4-1}
\end{example}
\parinterval 在这个实例中,将Candidate序列 转换为Reference序列,需要进行一次增加操作,在句首增加``The'';一次替换操作,将``in'' 替换为``on''。所以$\mathrm{edit}(c,r)$ = 2,归一化因子$l$为Reference的长度7,所以该机器译文的TER 结果为2/7。
\parinterval PER与TER的基本思想与WER相同,这三种方法的主要区别在于对``错误'' 的定义和考虑的操作类型略有不同。WER使用的编辑操作包括:增加、删除、替换,由于没有移位操作,当机器译文出现词序问题时,会发生多次替代,因而一般会低估译文质量;而PER只考虑增加和删除两个动作,在不考虑词序的情况下,PER计算两个句子中出现相同单词的次数,根据翻译句子比参考答案长或短,其余操作无非是插入词或删除词,这样往往会高估译文质量。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{2.基于$\bm{n}$-gram的方法} \label{sec:ngram-eval}
\parinterval BLEU是目前使用最广泛的自动评价指标。BLEU 是Bilingual Evaluation Understudy的缩写,由IBM 的研究人员在2002 年提出\upcite{DBLP:conf/acl/PapineniRWZ02}。通过采用$n$-gram匹配的方式评定机器翻译结果和参考答案之间的相似度,机器译文越接近参考答案就认定它的质量越高。$n$-gram是指$n$个连续单词组成的单元,称为{\small\sffamily\bfseries{$\bm{n}$元语法单元}}\index{$\bm{n}$元语法单元}(见{\chapterthree})。$n$越大表示评价时考虑的匹配片段越大。
\parinterval BLEU 的计算首先考虑待评价机器译文中$n$-gram在参考答案中的匹配率,称为{\small\sffamily\bfseries{$\bm{n}$-gram准确率}}\index{$\bm{n}$-gram准确率}$n$-gram Precision)\index{$n$-gram Precision}。其计算方法如下:
\begin{eqnarray}
\mathrm P_{n} = \frac{{{\rm{Coun}}{{\rm{t}}_{{\rm{hit}}}}}}{{{\rm{Coun}}{{\rm{t}}_{{\rm{output}}}}}}
\label{eq:4-4}
\end{eqnarray}
\noindent 其中,$\mathrm{Count_{hit}}$表示机器译文中$n$-gram在参考答案中命中的次数,$\mathrm{Count_{output}}$表示机器译文中总共有多少$n$-gram。为了避免同一个词被重复计算,BLEU的定义中使用了截断的方式定义$\mathrm{Count_{hit}}$$\mathrm{Count_{output}}$
\begin{example}
Candidate:the the the the
\qquad \ Reference:The cat is standing on the ground
\label{eg:4-bleu-example}
\end{example}
\parinterval 在引入截断方式之前,该译文的1-gram准确率为4/4 = 1,这显然是不合理的。在引入截断的方式之后,``the'' 在译文中出现4 次,在参考答案中出现2 次,截断操作则是取二者的最小值,即$\mathrm{Count_{hit}}$= 2,$\mathrm{Count_{output}}$= 4,该译文的1-gram准确率为2/4。
\parinterval$N$表示考虑的最大$n$-gram的大小,则译文整体的准确率等于各$n$-gram的加权平均:
\begin{eqnarray}
{\rm P_{{\rm{avg}}}} = \exp (\sum\limits_{n = 1}^N {{w_n} \cdot {{{\mathop{\rm logP}\nolimits} }_n}} )
\label{eq:4-5}
\end{eqnarray}
\parinterval 但是,该方法更倾向于对短句子打出更高的分数。一个极端的例子是译文只有很少的几个词,但是都命中答案,准确率很高可显然不是好的译文。因此,BLEU 引入{\small\sffamily\bfseries{短句惩罚因子}}\index{短句惩罚因子}(Brevity Penalty, BP)\index{Brevity Penalty}的概念,对短句进行惩罚:
\begin{eqnarray}
\rm BP = \left\{ \begin{array}{l}
1\quad \quad \;\;c > r\\
{\rm{exp}}(1 - \frac{r}{v})\quad c \le r
\end{array} \right.
\label{eq:4-6}
\end{eqnarray}
\noindent 其中,$c$表示机器译文的句子长度,$r$表示参考答案的句子长度。最终BLEU的计算公式为:
\begin{eqnarray}
\mathrm {BLEU} = \mathrm {BP} \cdot \exp(\sum\limits_{n = 1}^N {{w_n} \cdot {{{\mathop{\mathrm {log}}\nolimits} }\mathrm P_n}} )
\label{eq:4-7}
\end{eqnarray}
\parinterval 实际上,BLEU的计算也是一种综合考虑{\small\sffamily\bfseries{准确率}}\index{准确率}(Precision)\index{Precision}{\small\sffamily\bfseries{召回率}}\index{召回率}(Recall)\index{Recall}的方法。公式中,$\exp(\sum\limits_{n = 1}^N {{w_n} \cdot {{{\mathop{\mathrm {log}}\nolimits} }\mathrm P_n}} )$是一种准确率的表示。BP本是一种召回率的度量,它会惩罚过短的结果。这种设计同分类系统中评价指标F1值是有相通之处的\upcite{DBLP:conf/muc/Chinchor92}
\parinterval 从机器翻译的发展来看,BLEU 的意义在于它给系统研发人员提供了一种简单、高效、可重复的自动评价手段,在研发机器翻译系统时可以不需要依赖人工评价。同时,BLEU 也有很多创新之处,包括引入$n$-gram的匹配,截断计数和短句惩罚等等,包括NIST 等很多评价指标都是受到BLEU 的启发。此外,BLEU本身也有很多不同的实现方式,包括IBM-BLEU\upcite{DBLP:conf/acl/PapineniRWZ02}、NIST-BLEU\footnote{NIST-BLEU是指美国国家标准与技术研究院(NIST)开发的机器翻译评价工具mteval中实现的一种BLEU计算的方法。}、BLEU-SBP\upcite{DBLP:conf/emnlp/ChiangDCN08}、ScareBLEU等,使用不同实现方式得到评价结果会有差异。因此在实际使用BLEU进行评价时需要确认其实现细节,以保证结果与相关工作评价要求相符。
\parinterval 还需要注意的是,BLEU的评价结果与所使用的参考答案数量有很大相关性。如果参考答案数量多,$n$-gram匹配的几率变大,BLEU的结果也会偏高。同一个系统,在不同数量的参考答案下进行BLEU评价,结果相差10个点都十分正常。此外,考虑测试的同源性等因素,相似系统在不同测试条件下的BLEU结果差异可能会更大,这时可以采用人工评价的方式会得到更准确的评价结果。
\parinterval 虽然BLEU被广泛使用,但也并不完美,甚至经常被人诟病。比如,它需要依赖参考答案,而且评价结果有时与人工评价不一致,同时BLEU 评价只是单纯地从词串匹配的角度思考翻译质量的好坏,并没有真正考虑句子的语义是否翻译正确。但是,毫无疑问,BLEU 仍然是机器翻译中最常用的评价方法。在没有找到更好的替代方案之前,BLEU 还是机器翻译研究中最重要的评价指标之一。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{基于词对齐的方法}
\parinterval 基于词对齐的方法,顾名思义就是根据参考答案中的单词与译文中的单词之间的对齐关系对机器翻译译文进行评价。词对齐的概念也被用于统计机器翻译的建模(\chapterfive),这里借用了相同的思想来度量机器译文与参考答案之间的匹配程度。在基于$n$-gram匹配的评价方法中(如BLEU),BP可以起到一些度量召回率的作用,但是这类方法并没有对召回率进行准确的定义。与其不同的是,基于词对齐的方法在机器译文和参考答案的单词之间建立一对一的对应关系,这种评价方法在引入准确率的同时还能显性引入召回率作为评价所考虑的因素。
\parinterval 在基于词对齐的自动评价方法中,一种典型的方法是Meteor。该方法通过计算精确的{\small\bfnew{单词到单词}}\index{单词到单词}(Word-to-Word\index{Word-to-Word})的匹配来度量一个译文的质量\upcite{DBLP:conf/acl/BanerjeeL05},并且在`` 绝对''匹配之外,还引入了`` 波特词干匹配''和``同义词''匹配。在下面的内容中,将利用实例对Meteor方法进行介绍。
\begin{example}
Candidate:Can I have it like he ?
\qquad\ Reference:Can I eat this can like him ?
\label{eg:4-2}
\end{example}
\parinterval 在Meteor方法中,首先在机器译文与参考答案之间建立单词之间的对应关系,再根据其对应关系计算准确率和召回率。
\parinterval (1)单词之间的对应关系在建立过程中主要涉及三个模型,在对齐过程中依次使用这三个模型进行匹配:\\\\\\
\begin{itemize}
\vspace{0.5em}
\item {\small\sffamily\bfseries{``绝对''匹配模型}}\index{``绝对''匹配模型}(Exact Module)\index{Exact Module}。绝对匹配模型在建立单词对应关系时,要求机器译文端的单词与参考答案端的单词完全一致,并且在参考答案端至多有1个单词与机器译文端的单词对应,否则会将其视为多种对应情况。对于实例\ref{eg:4-2},使用``绝对''匹配模型,共有两种匹配结果,如图\ref{fig:4-3}所示。
%----------------------------------------------
\begin{figure}[htp]
\centering
\subfigure[``绝对''匹配词对齐-1]{\input{./Chapter4/Figures/absolute-match-word-alignment-1}}
\subfigure[``绝对''匹配词对齐-2]{\input{./Chapter4/Figures/absolute-match-word-alignment-2}}
\caption{``绝对''匹配模型}
\label{fig:4-3}
\end{figure}
%----------------------------------------------
\vspace{0.5em}
\item {\small\sffamily\bfseries{``波特词干''匹配模型}}\index{``波特词干''匹配模型}(Porter Stem Module)\index{Porter Stem Module}。该模型在``绝对''匹配结果的基础上,对尚未对齐的单词进行基于词干的匹配,只需机器译文端单词与参考答案端单词的词干相同即可,如上文中的``do''和``did''。对于图\ref{fig:4-3}的结果,再使用``波特词干'' 匹配模型,得到如图\ref{fig:4-4}所示的结果。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter4/Figures/match-words-with-stem}
\caption{同词干匹配词对齐}
\label{fig:4-4}
\end{figure}
%----------------------------------------------
\vspace{0.5em}
\item {\small\sffamily\bfseries{``同义词''匹配模型}}\index{``同义词''匹配模型}(WN synonymy module)\index{WN Synonymy Module}。该模型在前两个模型匹配结果的基础上,对尚未对齐的单词进行同义词的匹配,即基于WordNet词典匹配机器译文与参考答案中的同义词。如上例中的``eat''和``have''。图\ref{fig:4-5}给出了一个真实的例子。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter4/Figures/synonym-matching-word-alignment}
\caption{同义词匹配词对齐}
\label{fig:4-5}
\end{figure}
%----------------------------------------------
\vspace{0.5em}
\end{itemize}
\parinterval 经过上面的处理,可以得到机器译文与参考答案之间的单词对齐关系。下一步需要从中确定一个拥有最大的子集的对齐关系,即机器译文中被对齐的单词个数最多的对齐关系。但是在上例中的两种对齐关系子集基数相同,这种情况下,需要选择一个对齐关系中交叉现象出现最少的对齐关系。于是,最终的对齐关系如图\ref{fig:4-6}所示。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter4/Figures/determine-final-word-alignment}
\caption{确定最终词对齐}
\label{fig:4-6}
\end{figure}
%----------------------------------------------
\parinterval (2)在得到机器译文与参考答案的对齐关系后,需要基于对齐关系计算准确率和召回率。
\parinterval 准确率:机器译文中命中单词数与机器译文单词总数的比值。即:
\begin{eqnarray}
\mathrm P = \frac {\rm{Count}_{hit}}{\rm{Count}_{candidate}}
\label{eq:4-8}
\end{eqnarray}
\parinterval 召回率:机器译文中命中单词数与参考答案单词总数的比值。即:
\begin{eqnarray}
\mathrm R = \frac {\rm{Count}_{hit}}{\rm{Count}_{reference}}
\label{eq:4-9}
\end{eqnarray}
\parinterval 接下来,计算机器译文的得分。利用{\small\sffamily\bfseries{调和均值}}\index{调和均值}(Harmonic-mean)\index{Harmonic-mean}将准确率和召回率结合起来,并加大召回率的重要性将其权重调大,例如将召回率的权重设置为9:
\begin{eqnarray}
\rm F_{mean} = \frac {\rm 10PR}{\rm{R+9P}}
\label{eq:4-10}
\end{eqnarray}
\parinterval 在上文提到的评价指标中,无论是准确率、召回率还是$\rm F_{mean}$,都是基于单个词汇信息衡量译文质量,而忽略了语序问题。为了将语序问题考虑进来,Meteor会考虑更长的匹配:将机器译文按照最长匹配长度分块,并对``块数''较多的机器译文给予惩罚。例如上例中,机器译文被分为了三个``块''——``Can I have this''、``like he do''、``?''在这种情况下,看起来上例中的准确率、召回率都还不错,但最终会受到很严重的惩罚。这种罚分机制能够识别出机器译文中的词序问题,因为当待测译文词序与参考答案相差较大时,机器译文将会被分割得比较零散,这种惩罚机制的计算公式如式\ref{eq:4-11},其中$\rm Count_{chunks}$表示匹配的块数。
\begin{eqnarray}
\rm P = 0.5 \cdot {\left({\frac{\rm Count_{chunks}}{\rm Count_{hit}}} \right)^3}
\label{eq:4-11}
\end{eqnarray}
\parinterval Meteor评价方法的最终评分为:
\begin{eqnarray}
\rm score = {F_{mean}} \cdot (1 - P)
\label{eq:4-12}
\end{eqnarray}
\parinterval Meteor方法是经典的自动评价方法之一。它的创新点在于引入了词干匹配和同义词匹配,扩大了词汇匹配的范围。Meteor方法被提出后,很多人尝试对其进行了改进,使其评价结果与人工评价结果更相近。例如Meteor-next在Meteor的基础上增加{\small\sffamily\bfseries{释义匹配器}}\index{释义匹配器}(Paraphrase Matcher)\index{Paraphrase Matcher},利用该匹配器能够捕获机器译文中与参考答案意思相近的短语,从而在短语层面进行匹配。此外这种方法还引入了{\small\sffamily\bfseries{可调权值向量}}\index{可调权值向量}(Tunable Weight Vector)\index{Tunable Weight Vector},用于调节每个匹配类型的相应贡献\upcite{DBLP:conf/wmt/DenkowskiL10};Meteor 1.3在Meteor的基础上增加了改进的{\small\sffamily\bfseries{文本规范器}}\index{文本规范器}(Meteor Normalizer)\index{Meteor Normalizer}、更高精度的释义匹配以及区分内容词和功能词等指标,其中文本规范器能够根据一些规范化规则,将机器译文中意义等价的标点减少到通用的形式。而区分内容词和功能词则能够得到更为准确地词汇对应关系\upcite{DBLP:conf/wmt/DenkowskiL11};Meteor Universial则通过机器学习方法学习不同语言的可调权值,在对低资源语言进行评价时可对其进行复用,从而实现对低资源语言的译文更准确的评价\upcite{DBLP:conf/wmt/DenkowskiL14}
\parinterval 由于召回率反映参考答案在何种程度上覆盖目标译文的全部内容,而Meteor在评价过程中显式引入召回率,所以Meteor的评价与人工评价更为接近。但Meteor方法需要借助同义词表、功能词表等外部数据,当外部数据中的目标词对应不正确或缺失相应的目标词时,评价水准就会降低。特别是,针对汉语等于英语差异较大的语言,使用Meteor方法也会面临很多挑战。不仅如此,超参数的设置和使用,对于评分也有较大影响。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{基于检测点的方法}
\parinterval 基于词串比对和基于词对齐的自动评价方法中提出的BLEU、TER 等评价指标可以对译文的整体质量进行评估,但是缺乏对具体问题的细致评价。很多情况下,研究人员需要知道系统是否能够处理特定类型的翻译问题,而不是得到一个笼统的评价结果。基于检测点的方法正是基于此想法\upcite{DBLP:journals/mt/Shiwen93}。这种评价方法的优点在于对机器翻译系统给出一个总体评价的同时针对系统在各个具体问题上的翻译能力进行评估,方便比较不同翻译模型的性能。这种方法也被多次用于机器翻译比赛的译文质量评估。
\parinterval 基于检测点的评价根据事先定义好的语言学检测点对译文的相应部分进行打分。如下是几个英中翻译中的检测点实例:
\begin{example}
They got up at six this morning.
\qquad\ \ 他们今天早晨六点钟起床。
\qquad\ \ 检测点:时间词的顺序
\label{eg:4-3}
\end{example}
\begin{example}
There are nine cows on the farm.
\qquad\ \ 农场里有九头牛。
\qquad\ \ 检测点:量词``头''
\label{eg:4-4}
\end{example}
\begin{example}
His house is on the south bank of the river.
\qquad\ \ 他的房子在河的南岸。
\qquad\ \ We keep our money in a bank.
\qquad\ \ 我们在一家银行存钱。
\qquad\ \ 检测点:bank 的多义翻译
\label{eg:4-5}
\end{example}
\parinterval 该方法的关键在于检测点的获取。有工作曾提出一种从平行双语句子中自动提取检查点的方法\upcite{DBLP:conf/coling/ZhouWLLZZ08},借助大量的双语词对齐平行语料,利用自然语言处理工具对其进行词性标注、句法分析等处理,利用预先构建的词典和人工定义的规则,识别语料中不同类别的检查点,从而构建检查点数据库。其中,将检查点分别设计为单词级(如介词、歧义词等)、短语级(如固定搭配)、句子级(特殊句型、复合句型等)三个层面,在对机器翻译系统进行评价时,在检查点数据库中分别选取不同类别检查点对应的测试数据进行测试,从而了解机器翻译系统在各种重要语言现象方面的翻译能力。除此之外,这种方法也能应用于机器翻译系统之间的性能比较中,通过为各个检查点分配合理的权重,用翻译系统在各个检查点得分的加权平均作为系统得分,从而对机器翻译系统的整体水平作出评价。
\parinterval 基于检测点的评价方法的意义在于,它并不是简单给出一个分数,反而更像是一种诊断型评估方法,能够帮助系统研发人员定位系统问题。因此这类方法更多地使用在对机器翻译系统的翻译能力进行分析上,是对BLEU 等整体评价指标的一种很好的补充。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{多策略融合的评价方法}\label{Evaluation method of Multi Strategy fusion}
\parinterval 前面介绍的几种自动评价方法中,大多是从某个单一的角度比对机器译文与参考答案之间的相似度,例如BLEU更关注$n$-gram是否命中、Meteor更关注机器译文与参考答案之间的词对齐信息、WER、PER 与TER等方法只关注机器译文与参考译文之间的编辑距离,此外还有一些方法比较关注机器译文和参考译文在语法、句法方面的相似度。但无一例外的是,每种自动评价的关注点都是单一的,无法对译文质量进行全面、综合的评价。为了克服这种限制,研究人员们提出了一些基于多策略融合的译文质量评估方法,以期提高自动评价与人工评价结果的一致性。
\parinterval 基于策略融合的自动评价方法往往会将多个基于词汇、句法和语义的自动评价方法融合在内,其中比较核心的问题是如何将多个评价方法进行合理地组合。目前提出的方法中颇具代表性的是使用参数化方式和非参数化方式对多种自动评价方法进行筛选和组合。
\parinterval 参数化组合方法的实现主要有两种方式:一种方式是广泛使用不同的译文质量评价作为特征,借助回归算法实现多种评价策略的融合\upcite{DBLP:conf/acl/AlbrechtH07a,DBLP:conf/acl/AlbrechtH07};另一种方式则是对各种译文质量评价方法的结果进行加权求和,并借助机器学习算法更新内部的权重参数,从而实现多种评价策略的融合\upcite{DBLP:conf/naacl/LiuG07}
\parinterval 非参数化组合方法的思想与贪心算法异曲同工:将多个自动评价方法以与人工评价的相关度为标准进行降序排列,依次尝试将其加入最优策略集合中,如果能提高最优策略集合的``性能'',则将该自动评价方法加入最优策略集合中,否则不加入。其中最优策略集合的``性能''用QUEEN定义\upcite{DBLP:conf/ijcnlp/GimenezM08}。该方法是首次尝试使用非参数的组合方式将多种自动评价方法进行融合,也不可避免的存在一些瑕疵。一方面在评价最优策略集合性能时,对于一个源文需要至少三个参考答案;另一方面,这种``贪心''的组合策略很有可能会得到局部最优的组合。
\parinterval 与单一的译文评价方法相比,多策略融合的评价方法能够对机器译文从多角度进行综合评价,这显然是一个模拟人工评价的过程,因而多策略融合的评价结果也与人工评价结果更加接近。但是对于不同的语言,多策略融合的评价方法需要不断调整最优策略集合或是调整组合方法内部的参数才能达到最佳的评价效果,这个过程势必要比单一的自动评价方法更繁琐些。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{译文多样性}
\parinterval 在自然语言中,由于句子的灵活排序和大量同义词的存在,导致同一个源语言句子可能对应几百个合理的目标语言译文,甚至更多。然而上文提到的几种人工评价仅仅比较机器译文与有限数量的参考答案之间的差距,得出的评价结果往往会低估了机器译文的质量。为了改变这种窘况,比较直观的想法是增大参考答案集或是直接比较机器译文与参考答案在词法、句法和语义等方面的差距。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{1.增大参考答案集}
\parinterval BLEU、Meteor、TER等自动评价方法的结果往往与人工评价结果存在差距,一个主要原因是这些自动评价方法通过直接比对机器译文与有限的参考答案之间的``外在差异'',由于参考答案集可覆盖的人类译文数量过少,当机器译文本来十分合理但却未被包含在参考答案集中时,就会将其质量过分低估。
\parinterval 针对这个问题,HyTER自动评价方法致力于得到所有可能译文的紧凑编码,从而实现自动评价过程中访问所有合理的译文\upcite{DBLP:conf/naacl/DreyerM12}。这种评价方法的原理非常简单直观:
\begin{itemize}
\vspace{0.5em}
\item 通过注释工具标记出一个短语的所有备选含义(同义词)并存储在一起作为一个同义单元。可以认为每个同义单元表达了一个语义概念。在生成参考答案时,可以通过对某参考答案中的短语用同义单元进行替换生成一个新的参考答案。例如,将中文句子``对提案的支持率接近于0''翻译为英文,同义单元有以下几种:
\noindent [THE-SUPPORT-RATE]:
\parinterval <the level of approval; the approval level; the approval rate ; the support rate>
\noindent [CLOSE-TO]:
\parinterval <close to; about equal to; practically>
\vspace{0.5em}
\item 通过已有同义单元和附加单词的组合用于覆盖更大的语言片段。在生成参考答案时就是采用这种方式不断覆盖更大的语言片段,直到将所有可能的参考答案覆盖进去。例如可以将短语[THE-SUPPORT-RATE]与``national football team''组合为``[THE-SUPPORT-RATE] for national football team''。
\vspace{0.5em}
\item 利用同义单元的组合将所有所有合理的人类译文都编码出来。中文句子``对国足的支持率接近于0''翻译为英文,其可能的参考答案被编码成:
\vspace{0.5em}
\end{itemize}
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter4/Figures/representation-of-reference-answer-set-in-hyter}
\caption{HyTER中参考答案集的表示方式}
\label{fig:4-7}
\end{figure}
%----------------------------------------------
\parinterval 从上面的例子中可以看出,HyTER方法通过构造同义单元的方式,可以列举出译文中每个片段的所有可能的表达方式,从而增大参考答案的数量,上例中的每一条路径都代表一个参考答案。但是这种对参考答案集的编码方式存在问题,同义单元之间的组合往往存在一定的限制关系\upcite{DBLP:conf/tsd/BojarMTZ13},使用HyTER方法会导致参考答案集中包含有错误的参考答案。
\begin{example}
将中文``市政府批准了一项新规定''分别翻译为英语和捷克语,使用HyTER构造的参考答案集如下图所示:
\label{eg:4-6}
\end{example}
%----------------------------------------------
\begin{figure}[htp]
\centering
\subfigure[英语参考答案集表示]{\input{./Chapter4/Figures/representation-of-english-reference-answer-set}}
\subfigure[捷克语参考答案集表示]{\input{./Chapter4/Figures/representation-of-czech-reference-answer-set}}
\caption{使用HyTER构造的参考答案集}
\label{fig:4-8}
\end{figure}
%----------------------------------------------
\parinterval 但是在捷克语中主语``městská rada''或是``zastupitelstvo města''的性别必须由动词来反映,那么上述捷克语的参考答案集中有部分存在语法错误。为了避免此类现象的出现,研究人员在同义单元中加入了将同义单元组合在一起必须满足的限制条件\upcite{DBLP:conf/tsd/BojarMTZ13},从而在增大参考答案集的同时确保了每个参考答案的准确性
\parinterval 将参考答案集扩大后,可以继续沿用BLEU或NIST等基于$n$元语法的方法进行自动评价,但是传统方法往往会忽略多重参考答案中的重复信息,于是对每个$n$元语法进行加权的自动评价方法被提出\upcite{DBLP:conf/eamt/QinS15}。该方法根据每个$n$元语法单元的长度、在参考答案集中出现的次数、被虚词(如“the”,“by”,“a”等)分开后的分散度等方面,确定其在计算最终分数时所占的权重。以BLEU方法为例(\ref{sec:ngram-eval}节),可以将式\ref{eq:4-7}改写为:
\begin{eqnarray}
\mathrm{BLEU} &=& \mathrm {BP} \cdot {\rm{exp}}(\sum\limits_{n = 1}^N {{w_n} \cdot \log (\mathrm{S}_n \times \mathrm{P}_n} ))
\label{eq:4-14}\\
\mathrm{S}_n &=& n\mathrm{-gram_{diver}} \cdot \log (n + \frac{M}{\rm{Count_{ref}}})
\label{eq:4-15}
\end{eqnarray}
\noindent 其中,$\mathrm{S}_n$即为为某个$n$元语法单元分配的权重,$M$为参考答案集中出现该$n$-gram中的参考答案数量,$\rm{Count_{ref}}$ 为参考答案集大小。$n\mathrm{-gram_{diver}}$为该$n$-gram的分散度,用$n$-gram种类数量与语法单元总数的比值计算。
\parinterval 需要注意的是,HyTER方法对参考译文的标注有特殊要求,因此需要单独培训译员并开发相应的标注系统。这在一定程度上也增加了该方法被使用的难度。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{2.利用分布式表示进行质量评价}
\parinterval {\small\bfnew{词嵌入}}\index{词嵌入}(Word Embedding\index{Word Embedding})技术是近些年自然语言处理中的重要成果,其思想是把每个单词映射为多维实数空间中的一个点(具体表现为一个实数向量),这种技术也被称作单词的{\small\bfnew{分布式表示}}\index{分布式表示}(Distributed Representation\index{Distributed Representation})。在这项技术中,单词之间的关系可以通过空间的几何性质进行刻画,意义相近的单词之间的欧式距离也十分相近(单词分布式表示的具体内容,将在书的{\chapternine} 详细介绍,在此不再赘述)。
\parinterval 受词嵌入技术的启发,研究人员尝试借助参考答案和机器译文的分布式表示来进行译文质量评价,为译文质量评价提供了新思路。在自然语言的上下文中,表示是与每个单词、句子或文档相关联的数学对象。这个对象通常是一个向量,其中每个元素的值在某种程度上描述了相关单词、句子或文档的语义或句法属性。基于这个想法,研究人员提出了{\small\sffamily\bfseries{分布式表示评价度量}}\index{分布式表示评价度量}(Distributed Representations Evaluation Metrics,DREEM)\index{Distributed Representations Evaluation Metrics}\upcite{chen-guo-2015-representation}。这种方法将单词或句子的分布式表示映射到连续的低维空间,发现在该空间中,具有相似句法和语义属性的单词彼此接近,类似的结论也出现在相关工作中\upcite{bengio2003a,DBLP:conf/emnlp/SocherPHNM11,DBLP:conf/emnlp/SocherPWCMNP13}。而这个特点可以被应用到译文质量评估中。
\parinterval 在DREEM中,分布式表示的选取是一个十分关键的问题,理想的情况下,分布式表示应该涵盖句子在词汇、句法、语法、语义、依存关系等各个方面的信息。目前常见的分布式表示方式如表\ref{tab:4-2}所示。除此之外,还可以通过词袋模型、循环神经网路等将词向量表示转换为句子向量表示。
\begin{table}[htp]{
\begin{center}
\caption{常见的单词及句子分布表示}
{
\begin{tabular}{l|l}
单词分布表示 & 句子分布表示 \\
\hline
\rule{0pt}{10pt} One-hot词向量 & RAE编码\upcite{DBLP:conf/emnlp/SocherPHNM11} \\
\rule{0pt}{10pt} Word2Vec词向量\upcite{DBLP:journals/corr/abs-1301-3781} & Doc2Vec向量\upcite{DBLP:conf/icml/LeM14} \\
\rule{0pt}{10pt} Prob-fasttext词向量\upcite{DBLP:conf/acl/AthiwaratkunW17} & ELMO预训练句子表示\upcite{DBLP:conf/naacl/PetersNIGCLZ18} \\
\rule{0pt}{10pt} GloVe词向量\upcite{DBLP:conf/emnlp/PenningtonSM14} & GPT句子表示\upcite{radford2018improving} \\
\rule{0pt}{10pt} ELMO预训练词向量\upcite{DBLP:conf/naacl/PetersNIGCLZ18} & BERT预训练句子表示\upcite{devlin2018bert} \\
\rule{0pt}{10pt} BERT预训练词向量\upcite{devlin2018bert} & Skip-thought向量\upcite{DBLP:conf/nips/KirosZSZUTF15} \\
\end{tabular}
\label{tab:4-2}
}
\end{center}
}\end{table}
\parinterval DREEM方法中选取了能够反映句子中使用的特定词汇的One-hot向量、能够反映词汇信息的词嵌入向量\upcite{bengio2003a}、能够反映句子的合成语义信息的{\small\sffamily\bfseries{递归自动编码}}\index{递归自动编码}(Recursive Autoencoder Embedding, RAE)\index{Recursive Autoencoder Embedding},这三种表示级联在一起,最终形成句子的向量表示。在得到机器译文和参考答案的上述分布式表示后,利用余弦相似度和长度惩罚对机器译文质量进行评价。机器译文$o$和参考答案$g$之间的相似度如公式\ref{eq:4-16}所示,其中${v_i}(o)$${v_i}(g)$分别是机器译文和参考答案的向量表示中的第$i$个元素,$N$是向量表示的维度大小。
\begin{eqnarray}
\mathrm {cos}(t,r) = \frac{{\sum\limits_{i = 1}^N {{v_i}(o) \cdot {v_i}(g)} }}{{\sqrt {\sum\limits_{i = 1}^N {v_i^2(o)} } \sqrt {\sum\limits_{i = 1}^N {v_i^2(g)} } }}
\label{eq:4-16}
\end{eqnarray}
\parinterval 在此基础上,DREEM方法还引入了长度惩罚项,对与参考答案长度相差太多的机器译文进行惩罚,长度惩罚项如公式\ref{eq:4-17}所示,其中${l_o}$${l_g}$分别是机器译文和参考答案长度:
\begin{eqnarray}
\mathrm{BP} = \left\{ \begin{array}{l}
\exp (1 - {{{l_g}} \mathord{\left/
{\vphantom {{{l_g}} {{l_o}}}} \right.
\kern-\nulldelimiterspace} {{l_o}}})\quad {l_o} < {l_g}\\
\exp (1 - {{{l_o}} \mathord{\left/
{\vphantom {{{l_o}} {{l_g}}}} \right.
\kern-\nulldelimiterspace} {{l_g}}})\quad {l_o} \ge {l_g}
\end{array} \right.
\label{eq:4-17}
\end{eqnarray}
\parinterval 机器译文的最终得分如下,其中$\alpha$是一个需要手动设置的参数:
\begin{eqnarray}
\mathrm{score}(o,g) = \mathrm{cos}{^\alpha }(o,g) \times \mathrm{BP}
\label{eq:4-18}
\end{eqnarray}
\parinterval 本质上,分布式表示是一种对句子语义的一种统计表示。因此,它可以帮助评价系统捕捉一些从简单的词或者句子片段中不易发现的现象,进而进行更深层的句子匹配。
\parinterval 在DREEM方法取得成功后,基于词嵌入的词对齐自动评价方法被提出\upcite{DBLP:journals/corr/MatsuoKS17},该方法中先得到机器译文与参考答案的词对齐关系后,通过对齐关系中两者的词嵌入相似度来计算机器译文与参考答案的相似度,公式如下:
\begin{eqnarray}
\mathrm{ASS}(o,g) = \frac{1}{{m \cdot l}}\sum\limits_{i = 1}^{m} {\sum\limits_{j = 1}^{l} {\varphi (o,g,i,j)} }
\label{eq:4-19}
\end{eqnarray}
\noindent 其中,$o$是机器译文,$g$是参考答案,$m$表示译文$o$的长度,$l$表示参考答案$g$的长度,函数$\varphi(o,g,i,j)$用来计算$o$中第$i$个词和$g$中第$j$个词之间对齐关系的相似度。
\parinterval 此外,将分布式表示与相对排序融合也是一个很有趣的想法\upcite{DBLP:journals/csl/GuzmanJMN17},在这个尝试中,研究人员利用分布式表示提取参考答案和多个机器译文中的句法信息和语义信息,利用神经网络模型对多个机器译文进行排序。
\parinterval 在基于分布式表示的这类译文质量评价方法中,译文和参考答案的所有词汇信息和句法语义信息都被包含在句子的分布式表示中,克服了单一参考答案的限制。但是同时也带来了新的问题,一方面将句子转化成分布式表示使评价过程变得不那么具有可解释性,另一方面分布式表示的质量也会对评价结果有较大的影响。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{自动评价与人工评价的相关性}
\parinterval {\small\sffamily\bfseries{相关性}}\index{相关性}(Correlation)\index{Correlation}是统计学中的概念,当两个变量之间存在密切的依赖或制约关系,但却无法确切地表示时,可以认为两个变量之间存在``相关关系'',并往往用``相关性''作为衡量关系密切程度的标准\upcite{pearson1920notes}。对于相关关系,虽然无法求解两个变量之间确定的函数关系,但是通过大量的观测数据,能够发现变量之间存在的统计规律性,而``相关性''也同样可以利用统计手段获取。
\parinterval 在机器译文质量评价工作中,相比人工评价,有参考答案的自动评价具有效率、成本低的优点,因而广受机器翻译系统研发人员青睐。在这种情况下,自动评价结果的可信度一般取决于它们与可靠的人工评价之间的相关性。随着越来越多有参考答案的自动评价方法的提出,``与人工评价之间的相关性''也被视为衡量一种新的自动评价方法是否可靠的衡量标准。
\parinterval 很多研究工作中都曾对BLEU、NIST等有参考答案的自动评价与人工评价的相关性进行研究和讨论,其中也有很多工作对``相关性''的统计过程作过比较详细的阐述。在``相关性''的统计过程中,一般是分别利用人工评价方法和某种有参考答案的自动评价方法对若干个机器翻译系统的输出进行等级评价\upcite{coughlin2003correlating}或是相对排序\upcite{popescu2003experiment},从而对比两种评价手段的评价结果是否一致。该过程中的几个关键问题会可能会对最终结果产生影响。
\begin{itemize}
\vspace{0.5em}
\item {\small\sffamily\bfseries{源语言句子的选择。}}。由于机器翻译系统一般以单句作为翻译单元,因而评价过程中涉及的源语言句子是脱离上下文语境的单句\upcite{coughlin2003correlating}
\vspace{0.5em}
\item {\small\sffamily\bfseries{人工评估结果的产生}}。人工评价过程中采用只提供标准高质量参考答案的单语评价方法,由多位评委对译文质量做出评价后进行平均作为最终的人工评价结果\upcite{coughlin2003correlating}
\vspace{0.5em}
\item {\small\sffamily\bfseries{自动评价中参考答案的数量}}。在有参考答案的自动评价过程中,为了使评价结果更加准确,一般会设置多个参考答案。参考答案数量的设置会对自动评价与人工评价的相关性产生影响,也有很多工作对此进行了研究。例如人们发现有参考答案的自动评价方法在区分人类翻译和机器翻译时,设置4个参考答案的区分效果远远高于2个参考答案\upcite{culy2003limits};也有人曾专注于研究怎样设置参考答案数量能够产生最高的相关性\upcite{finch2004using}
\vspace{0.5em}
\item {\small\sffamily\bfseries{自动评价中参考答案的质量}}。从直觉上,自动评价中参考答案的质量一般会影响最终的评价结果,从而对相关性的计算产生影响。然而,有相关实验表明,只要参考答案的质量不是过分低劣,很多情况下自动评价都能得到相同的评价结果\upcite{DBLP:conf/coling/HamonM08}
\vspace{0.5em}
\end{itemize}
\parinterval 目前在机器译文质量评价的领域中,有很多研究工作尝试比较各种有参考答案的自动评价方法(主要以BLEU、NIST等基于$n$元语法的方法为主)与人工评价方法的相关性。整体来看,这些方法与人工评价具有一定的相关性,自动评价结果能够较好地翻译译文质量\upcite{coughlin2003correlating,doddington2002automatic}
\parinterval 但是也有相关研究指出,不应该对有参考答案的自动评价方法过于乐观,而应该存谨慎态度,因为目前的自动评价方法对于流利度的评价并不可靠,同时参考答案的体裁和风格往往会对自动评价结果产生很大影响\upcite{culy2003limits}。同时,有研究者提出,在机器翻译研究过程中,忽略实际的示例翻译而仅仅通过BLEU等自动评价方式得分的提高来表明机器翻译质量的提高是不可取的,因为BLEU的提高并不足以反映翻译质量的真正提高,而在另一些情况下,为了实现翻译质量的显著提高,并不需要提高BLEU\upcite{callison2006re}
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{无参考答案的自动评价}
\parinterval 无参考答案自动评价在机器翻译领域又被称作{\small\sffamily\bfseries{质量评估}}\index{质量评估}(Quality Estimation,\\QE)\index{Quality Estimation,QE}。与传统的译文质量评价方法不同,质量评估旨在不参照标准译文的情况下,对机器翻译系统的输出在单词、短语、句子、文档等各个层次进行评价。
\parinterval 人们对于无参考答案自动评价的需求大多来源于机器翻译的实际应用。例如,在机器翻译的译后编辑过程中,译员不仅仅希望了解机器翻译系统的整体翻译质量,还需要了解该系统在某个句子上的表现如何:该机器译文的质量是否很差?需要修改的内容有多少?是否值得进行后编辑?这时,译员更加关注系统在单个数据点上(比如一段话)的可信度而非系统在测试数据集上的平均质量。这时,太多的人工介入就无法保证使用机器翻译所带来的高效性,因此在机器翻译输出译文的同时,需要质量评估系统给出对译文质量的预估结果。这些需求也促使研究人员在质量评估问题上投入了更多的研究力量。包括WMT、CCMT等知名机器翻译评测中也都设置了相关任务,受到了业界的关注。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{质量评估任务}
\parinterval 质量评估任务本质上是通过预测一个能够反映评价单元的质量标签,在各个层次上对译文进行质量评价。在上文中已经提到,质量评估任务通常被划分为单词级、短语级、句子级和文档级,在接下来的内容中,将对各个级别的任务进行更加详细的介绍。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{1.单词级质量评估}
\parinterval 机器翻译系统在翻译某个句子时,会出现各种类型的错误,这些错误多是一些单词翻译问题,例如单词出现歧义、单词漏译、单词错译、词形转化错误等等。单词级质量评价以单词为评估单元,目的是确定译文句子中每个单词的所在位置是否存在翻译错误和单词漏译现象。
\parinterval 单词级质量评估任务可以被定义为:参照源语言句子,以单词为评价单位,自动标记出机器译文中的错误。其中的``错误''包括单词错译、单词词形错误、单词漏译等。在单词级质量评估任务中,输入是机器译文和源语言句子,输出是一系列标签序列,即图\ref{fig:4-11}中的Source tags、MT tags、Gap tags,标签序列中的每个标签对应翻译中的每个单词(或其间隙),并表明该位置是否出现错误。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter4/Figures/schematic-diagram-of-word-level-quality-assessment-task}
\caption{单词级质量评估任务示意图}
\label{fig:4-11}
\end{figure}
%----------------------------------------------
\parinterval 下面以实例\ref{eg:4-7}为例介绍该任务的具体内容,在实例\ref{eg:4-7}中加入后编辑结果是方便读者理解任务内容,实际上质量评估任务在预测质量标签时并不依赖后编辑结果:
\begin{example}
单词级质量评估任务
源句:The Sharpen tool sharpens areas in an imag.(英语)
机器译文:Mit dem Scharfzeichner können Sie einzelne Bereiche in einem Bild
scharfzeichnen.(德语)
后编辑结果:Der Schärfen-Werkezug Bereiche in einem Bild Schärfer erscheint.
(德语)
\label{eg:4-7}
\end{example}
\parinterval 单词级质量评估主要通过以下三类错误评价译文好坏:
\begin{itemize}
\vspace{0.5em}
\item {\small\sffamily\bfseries{找出译文中翻译错误的单词}}。单词级质量评估任务要求预测一个与译文等长的质量标签序列,该标签序列反映译文端的每个单词是否能够准确表达出其对应的源端单词的含义,若是可以,则标签为``OK'',反之则为``BAD''。图\ref{fig:4-11}中的连线表示单词之间的对齐关系,图\ref{fig:4-11}中的MT tags即为该过程中需要预测的质量标签序列。
\vspace{0.5em}
\item {\small\sffamily\bfseries{找出源文中导致翻译错误的单词}}。单词级质量评估任务还要求预测一个与源文等长的质量标签序列,该标签序列反映源文端的每个单词是否会导致本次翻译出现错误,若是不会,则标签为``OK'',反之则为``BAD''。图\ref{fig:4-11}中的Source tags即为该过程中的质量标签序列。在具体应用时,质量评估系统往往先预测译文端的质量标签序列,并根据源文与译文之间的对齐关系,推测源端的质量标签序列。
\vspace{0.5em}
\item {\small\sffamily\bfseries{找出在翻译句子时出现漏译现象的位置}}。单词级质量评估任务同时也要求预测一个能够捕捉到漏译现象的质量标签序列,在译文端单词的两侧位置进行预测,若某位置未出现漏译,则该位置的质量标签为``OK'',否则为``BAD''。图\ref{fig:4-11}中的Gap tags即为该过程中的质量标签序列。为了检测句子翻译中的漏译现象,需要在译文中标记缺口,即译文中的每个单词两边都各有一个``GAP''标记,如图\ref{fig:4-11}所示。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{2.短语级质量评估}
\parinterval 短语级质量评估可以看做是单词级质量评估任务的扩展:机器翻译系统引发的错误往往都是相互关联的,解码过程中某个单词出错会导致更多的错误,特别是在其局部上下文当中,以单词的``局部上下文''为基本单元进行质量评估即为短语级质量评估。
\parinterval 短语级质量评估与单词级质量评估类似,其目标是找出短语中翻译错误、短语内部语序问题及漏译问题。短语级质量评估任务可以被定义为:以若干个连续单词组成的短语为基本评估单位,参照源语言句子,自动标记出短语内部短语错误以及短语之间的是否存在漏译。其中的短语错误包括短语内部单词的错译和漏译、短语内部单词的语序错误,而漏译问题则特指短语之间的漏译错误。在短语级质量评估任务中,输入是机器译文和源语言句子,输出是一系列标签序列,即图\ref{fig:4-12}中的Phrase-target tags、Gap tags,标签序列中的每个标签对应翻译中的每个单词,并表明该位置是否出现错误。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter4/Figures/schematic-diagram-of-phrase-level-quality-assessment-task}
\caption{短语级质量评估任务示意图}
\label{fig:4-12}
\end{figure}
%----------------------------------------------
\parinterval 下面以实例\ref{eg:4-8}为例介绍该任务的具体内容:
\begin{example}
短语级质量评估任务(短语间用 || 分隔)
源句:Bei Patienten mit || eingeschränkter Nierenfunktion kann || Insulinabbaus ||
\hspace{3em}der Insulinbedarf || infolge des || verminderten || verringert sein . (德语)
机器译文:In patients with || renal impairment , insulin requirements may || be ||
\hspace{5em}diminished || due to || reduced || . (英语)
\label{eg:4-8}
\end{example}
\parinterval 短语级质量评估任务主要通过以下两类类错误评价译文好坏:
\begin{itemize}
\vspace{0.5em}
\item 找出译文中翻译错误的短语。要求预测出一个能够捕捉短语内部单词翻译错误、单词漏译以及单词顺序错误的标签序列。该序列中每个标签都对应着一个短语,若是短语不存在任何错误,则标签为``OK'';若是短语内部存在单词翻译错误和单词漏译,则标签为``BAD'';若短语内部的单词顺序存在问题,则标签为``BAD\_word\_order''。图\ref{fig:4-12}中的连线表示单词之间的对齐关系,蓝色虚线框标出了每个短语的范围,图\ref{fig:4-12}中的Phrase-target tags即为该过程中需要预测的质量标签序列。
\vspace{0.5em}
\item 找出译文中短语之间漏译错误。短语级质量评估任务同时也要求预测一个能够捕捉到短语间的漏译现象的质量标签序列,在译文端短语的两侧位置进行预测,若某位置未出现漏译,则该位置的质量标签为``OK'',否则为``BAD\_omission''。图\ref{fig:4-12}中的Gap tags即为该过程中的质量标签序列。
\vspace{0.5em}
\end{itemize}
\parinterval 为了检测句子翻译中的漏译现象,参与者也被要求在译文中短语之间标记缺口,即译文中的每对短语之间都有两个``GAP''标记,一个在短语前面,一个在短语后面,与单词级类似。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{3.句子级质量评估}
\parinterval 迄今为止,质量评估的大部分工作都集中在句子层次的预测上,这是因为多数情况下机器翻译系统的处理都是逐句进行,系统用户也总是每次翻译一个句子或是以句子为单位组成的文本块(段落、文档等),因此以句子作为质量评估的基本单元是很自然的。
\parinterval 句子级质量评估的目标是生成能够反映译文句子整体质量的标签\ \dash \ 可以是离散型的表示某种质量等级的标签,也可以是连续型的基于评分的标签。虽然以不同的标准进行评估,同一个译文句子的质量标签可能有所不同,但可以肯定的是句子的最终质量绝不是句子中单词质量的简单累加。因为与词级的质量评估相比,句子级质量评估也会关注是否保留源句的语义、译文的语义是否连贯、译文中的单词顺序是否合理等因素。
\parinterval 句子级质量系统需要根据某种评价标准,通过建立预测模型来生成一个反映句子质量的标签。人们可以根据句子翻译的目的、后编辑的工作难度、是否达到发表要求或是是否能让非母语者读懂等各个角度、各个标准去设定句子级质量评估的标准。句子级质量评估任务有多种形式:
\begin{itemize}
\vspace{0.5em}
\item 区分``人工翻译''和``机器翻译''。在早期的工作中,研究人员试图训练一个能够区分人工翻译和机器翻译的二分类器完成句子级的质量评估\upcite{gamon2005sentence},将被分类器判断为``人工翻译''的机器译文视为优秀的译文,将被分类器判断为``机器翻译''的机器译文视为较差的译文。一方面,这种评估方式不够直观,另一方面,这种评估方式并不十分准确,因为通过人工比对发现很多被判定为``机器翻译''的译文具有与人们期望的人类翻译相同的质量水平。
\vspace{0.5em}
\item 预测反映译文句子质量的``质量标签''。在同一时期,研究人员们也尝试使用人工为机器译文分配能够反映译文质量的标签\upcite{DBLP:conf/lrec/Quirk04},例如``不可接受''、``一定程度上可接受''、`` 可接受''、`` 理想''等类型的质量标签,同时将获取机器译文的质量标签作为句子级质量评估的任务目标。
\vspace{0.5em}
\item 预测译文句子的相对排名。当相对排序(详见\ref{sec:human-eval-scoring}节)的译文评价方法被引入后,给出机器译文的相对排名成为句子级质量评估的任务目标。
\vspace{0.5em}
\item 预测译文句子的后编辑工作量。在最近的研究中,句子级地质量评估一直在探索各种类型的离散或连续的后编辑标签。例如,通过测量以秒为单位的后编辑时间对译文句子进行评分;通过测量预测后编辑过程所需的击键数对译文句子进行评分;通过计算{\small\sffamily\bfseries{人工译后编辑距离}}\index{人工译后编辑距离}(Human Translation Error Rate,HTER)\index{Human Translation Error Rate,HTER},即在后编辑过程中编辑(插入/删除/替换)数量与参考翻译长度的占比率对译文句子进行评分。HTER的计算公式为:
\vspace{0.5em}
\begin{eqnarray}
\rm{HTER}= \frac{\mbox{编辑操作数目}}{\mbox{翻译后编辑结果长度}}
\label{eq:4-20}
\end{eqnarray}
\parinterval 这种质量评估方式往往以单词级质量评估为基础,在其结果的基础上进行计算。以实例\ref{eg:4-7}中词级质量评估结果为例,与编辑后结果相比较,机器翻译译文中有四处漏译(``Mit''、``können''、``Sie''、``einzelne'')、三处误译(``dem''、\\``Scharfzeichner''、``scharfzeichnen''分别被误译为``Der''、``Schärfen-Werkezug''、``Schärfer'')、一处多译(``erscheint''),因而需要进行4次插入操作、3次替换操作和1次删除操作,而最终译文长度为12,则有$\rm HTER=(4+3+1)/12=0.667$。需要注意的是,即便这种评估方式以单词级质量评估为基础,也不意味这句子级质量评估只是在单词级质量评估的结果上通过简单的计算来获得其得分,在实际研究中,常将其视为一个回归问题,利用大量数据学习其评分规则。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
%----------------------------------------------------------------------------------------
\subsubsection{4.文档级质量评估}
\parinterval 文档级质量评估的主要目的是对机器翻译得到的整个译文文档进行打分。文档级质量评估中,``文档''很多时候并不单单指一整篇文档,而是指包含多个句子的文本,例如包含3到5个句子的段落或是像新闻文章一样的长文本。
\parinterval 传统的机器翻译任务中,往往以一个句子作为输入和翻译的单元,而忽略了文档中句子之间的联系,这可能会使文档的论述要素受到影响,最终导致整个文档的语义不连贯。如实例1所示,在第二句中``he''原本指代第一句中的``housewife'',这里出现了错误,但这种错误在句子级的质量评估中并不能被发现。
\begin{example}
文档级质量评估任务
Candidate: A {\red housewife} won the first prize in the supermarket's anniversary
\hspace{5em}celebration.
Reference: A few days ago, {\red he} contacted the News Channel and said that the
\hspace{5em}supermarket owner refused to give {\red him} the prize.
\label{eg:4-9}
\end{example}
\parinterval 在文档级质量评估中,有两种衡量文档译文的质量的方式:
\begin{itemize}
\vspace{0.5em}
\item 阅读理解测试得分情况。以往衡量文档译文质量的主要方法是采用理解测试\upcite{,DBLP:conf/icassp/JonesGSGHRW05},即利用提前设计好的与文档相关的阅读理解题目(包括多项选择题类型和问答题类型)对母语为目标语言的多个测试者进行测试,将代表测试者在给定文档上的问卷中的所有问题所得到的分数作为质量标签。
\vspace{0.5em}
\item 后编辑工作量。 最近的研究工作中,多是采用对文档译文进行后编辑的工作量评估文档译文的质量。为了准确获取文档后编辑的工作量,两阶段后编辑方法被提出\upcite{DBLP:conf/eamt/ScartonZVGS15},即第一阶段对文档中的句子单独在无语境情况下进行后编辑,第二阶段将所有句子重新合并成文档后再进行后编辑。两阶段中后编辑工作量的总和越多,意味着文档译文质量越差。
\vspace{0.5em}
\end{itemize}
\parinterval 在文档级质量评估任务中,需要对译文文档做一些更细粒度的注释,注释内容包括错误位置、错误类型和错误的严重程度,最终在注释的基础上对译文文档质量进行评估。
\parinterval 与更细粒度的词级和句子级的质量评价相比,文档级质量评估更加复杂。其难点之一在于文档级的质量评估过程中需要根据一些主观的质量标准去对文档进行评分,例如在注释的过程中,对于错误的严重程度并没有严格的界限和规定,只能靠评测人员主观判断,这就意味着随着出现主观偏差的注释的增多,文档级质量评估的参考价值会大打折扣。另一方面,根据所有注释(错误位置、错误类型及其严重程度)对整个文档进行评分本身就具有不合理性,因为译文中有些在抛开上下文环境的情况下可以并判定为``翻译的不错的''单词和句子,一旦被放在文档中的语境后就可能变得不合理,而某些在无语境条件下看起来翻译得`` 糟糕透了''的单词和句子,一旦被放在文档中的语境中可能会变得恰到好处。此外,构建一个质量评测模型势必需要大量的标注数据,而文档级质量评测所需要的带有注释的数据的获取代价相当高。
\parinterval 实际上,文档级集质量评估与其它文档级自然语言处理任务面临的问题是一样的。由于数据稀缺,无论是系统研发,还是结果评价都面临很大挑战。这些问题也会在本书的{\chaptersixteen}{\chapterseventeen}进行讨论。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{怎样构建质量评估模型}
\parinterval 不同于有参考答案的自动评价,质量评估方法的实现较为复杂。质量评估可以被看作是一个统计推断问题,即:如何根据以往得到的经验对从未见过的机器译文的质量做出预测。从这个角度说,质量评估和机器翻译问题一样,都需要设计模型进行求解,而不是像BLEU计算一样直接使用指标性的公式计算就能得到结果。
\parinterval 实际上,质量评估的灵感最初来源于语音识别中的置信度评价,所以最初研究人员也尝试通过翻译模型中的后验概率来直接评价翻译质量\upcite{DBLP:conf/interspeech/FetterDR96},然而仅仅依靠概率值作为评价标准显然是远远不够的,其效果也让人大失所望。之后,质量评估被定义为一个有监督的预测类机器学习问题。这也导致质量评估的新范式:使用机器学习算法从描述句子的某种表示中归纳出评估模型。
\parinterval 研究人员将质量评估模型的基本框架设计为两部分:
\begin{itemize}
\vspace{0.5em}
\item 表示/特征学习模块:用于在数据中提取能够反映翻译结果质量的“特征”;
\vspace{0.5em}
\item 质量评估模块:基于句子的表示结果,利用机器学习算法预测翻译结果的质量。
\vspace{0.5em}
\end{itemize}
\parinterval 在传统机器学习的观点下,句子都是由某些特征表示的。因此需要从句子中“抽取”出能代表句子的特征{\color{red}(参考文献!)},常用的特征有:
\begin{itemize}
\vspace{0.5em}
\item 复杂度特征:反映了翻译一个源文的难易程度,翻译难度越大,译文质量低的可能性就越大;
\vspace{0.5em}
\item 流畅度特征:反映了译文的自然度、流畅度、语法合理程度;
\vspace{0.5em}
\item 置信度特征:反映了机器翻译系统对输出的译文的置信程度;
\vspace{0.5em}
\item 充分度特征:反映了源文和机器译文在不同语言层次上的密切程度或关联程度。
\vspace{0.5em}
\end{itemize}
\parinterval 随着深度学习技术的发展,另一种思路是使用表示学习技术生成句子的分布式表示,这样就避免了人工设计特征的代价。同时,由于表示学习所得到的分布式表示可以更全面的反应句子的特点,因此在质量评估任务上也取得了很好的效果{\color{red}(参考文献!)}。比如,最近的一些工作中大量使用了神经机器翻译模型来获得双语句子的表示结果,并用于质量评估。这么做的好处在于,质量评估可以直接复用机器翻译的模型,从某种意义上降低了质量评估系统开发的代价。关于表示学习和神经机器翻译的内容在{\chapternine}{\chapterten}会有进一步描述。
\parinterval 在得到句子表示之后,可以使用质量评估模块对译文质量进行预测。质量评估模型通常由分类算法或回归算法实现:
\begin{itemize}
\vspace{0.5em}
\item 句子级和文档级质量评估多由回归算法实现。由于在句子级和文档级的质量评估中,标签是使用连续数字表示的,因此回归算法是最合适的选择;
\vspace{0.5em}
\item 单词级和短语级质量评估多由分类算法实现。对于单词级质量评估任务中标记``OK''或``BAD'',这对应了经典的二分类问题,因此经常使用分类算法对其进行预测,自动分类算法在{\chapterthree}已经涉及,质量评估中直接使用成熟的分类器即可。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{质量评估的应用场景}
\parinterval 很多情况下参考答案是很难获取的,例如,在很多人工翻译生产环节中,译员的任务就是“创造”翻译。如果已经有了答案,译员根本不需要工作,也谈不上应用机器翻译技术了。这时更多的是希望通过质量评估帮助译员有效的选择机器翻译结果。质量评估的应用场景还有很多,例如:
\begin{itemize}
\vspace{0.5em}
\item 判断人工后编辑的工作量。人工后编辑工作中有两个不可避免的问题:1)待编辑的机器译文是否值得改?2)待编辑的机器译文需要修改哪里?对于一些质量较差的机器译文来说,人工重译远远比修改译文的效率高,后编辑人员可以借助质量评估系统提供的指标筛选出值得进行后编辑的机器译文,另一方面,质量评估模型可以为每条机器译文提供{错误内容、错误类型、错误严重程度}的注释,这些内容将帮助后编辑人员准确定位到需要修改的位置,同时在一定程度上提示后编辑人员采取何种修改策略,势必能大大减少后编辑的工作内容。
\vspace{0.5em}
\item 自动识别并更正翻译错误。质量评估模型和{\small\sffamily\bfseries{自动后编辑模型}}\index{自动后编辑模型}(Automatic Podt-Editing,APE)\index{Automatic Podt-Editing, APE}也是很有潜力的应用方向。因为质量评估可以预测出错的位置,进而可以使用自动方法修正这些错误。但是,在这种应用模式中,质量评估的精度是非常关键的,因为如果预测错误可能会产生错误的修改,甚至带来整体译文质量的下降。
\vspace{0.5em}
\item 辅助外语交流和学习。例如,在很多社交网站上,用户会利用外语进行交流。质量评估模型可以提示该用户输入的内容中存在的用词、语法等问题,这样用户可以重新对内容进行修改。甚至质量评估可以帮助外语学习者发现外语使用中的问题,例如,对于一个英语初学者,如果能提示他/她写的句子中的明显错误,对他/她的外语学习是非常有帮助的。
\vspace{0.5em}
\end{itemize}
\parinterval 需要注意的是,质量评估的应用模式还没有完全得到验证。这一方面是由于,质量评估的应用非常依赖与人的交互过程。但是,改变人的工作习惯是很困难的,因此质量评估系统在应用时往往需要很长的时间适应到场景中,或者说人也要适应质量评估系统的行为。另一方面,质量评估的很多应用场景还没有完全被发觉出来,需要更长的时间进行探索。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{}
\sectionnewpage
\section{小结及深入阅读}
\parinterval 译文的质量评价是机器翻译研究中不可或缺的环节。与其他任务不同,由于自然语言高度的歧义性和表达方式的多样性,机器翻译的参考答案本身就不唯一。此外,对译文准确、全面的评价准则很难制定,导致译文质量的自动评价变得异常艰难,因此也成为了广受关注的研究课题。本章系统阐述了译文质量评估的研究现状和主要挑战。从人类参与程度和标注类型两个角度对译文质量评价中的经典方法进行介绍,力求让读者对领域内的经典及热点内容有更加全面的了解。不过,由于篇幅限制笔者无法对译文评价的相关工作进行面面俱到的描述,还有很多研究方向值得关注:
\begin{itemize}
\vspace{0.5em}
\item 基于句法和语义的机器译文质量自动评价方法。本章内容中介绍的自动评价多是基于表面字符串形式判定机器翻译结果和参考译文之间的相似度,而忽略了更抽象的语言层次的信息。基于句法和语义的机器译文质量自动评价方法在在评价度量标准中加入能反映句法信息\upcite{DBLP:conf/acl/LiuG05}和语义信息\upcite{DBLP:conf/wmt/GimenezM07a}的相关内容,通过比较机器译文与参考答案之间的句法相似度和语义等价性\upcite{DBLP:journals/mt/PadoCGJM09},能够大大提高自动评价与人工评价之间的相关性。其中句法信息往往能够对机器译文流利度方面的评价起到促进作用\upcite{DBLP:conf/acl/LiuG05},常见的句法信息包括语法成分\upcite{DBLP:conf/acl/LiuG05}、依存关系\upcite{DBLP:conf/ssst/OwczarzakGW07}\upcite{DBLP:conf/wmt/OwczarzakGW07}\upcite{DBLP:conf/coling/YuWXJLL14}等。语义信息则对机器翻译的充分性评价更有帮助\upcite{DBLP:conf/acl/BanchsL11}\upcite{reeder2006measuring},近年来也有很多很多用于机器译文质量评估的语义框架被提出,如AM-FM\upcite{DBLP:conf/acl/BanchsL11}、XMEANT\upcite{DBLP:conf/acl/LoBSW14}等。
\vspace{0.5em}
\item 对机器译文中的错误分析和错误分类。无论是人工评价还是自动评价手段,其评价结果只能反映机器翻译系统性能,而无法确切表明机器翻译系统的优点和弱点是什么、系统最常犯什么类型的错误、一个特定的修改是否改善了系统的某一方面、排名较差的系统是否在任何方面都优于排名较好的系统等等。对机器译文进行错误分析和错误分类有助于找出机器翻译系统中存在的主要问题,以便集中精力进行研究改进\upcite{DBLP:conf/lrec/VilarXDN06}。相关的研究工作中,一些致力于错误分类方法的设计,如手动的机器译文错误分类框架\upcite{DBLP:conf/lrec/VilarXDN06}、自动的机器译文错误分类框架\upcite{popovic2011human}、基于语言学的错误分类方法\upcite{DBLP:journals/mt/CostaLLCC15}以及目前被用作篇章级质量评估注释标准的MQM错误分类框架\upcite{lommel2014using};其他的研究工作则致力于对机器译文进行错误分析,如引入形态句法信息的自动错误分析框架\upcite{DBLP:conf/wmt/PopovicGGLNMFB06}、引入词错误率(WER)和位置无关词错误率(PER)的错误分析框架\upcite{DBLP:conf/wmt/PopovicN07}、基于检索的错误分析工具tSEARCH\upcite{DBLP:conf/acl/GonzalezMM13}等等。
\vspace{0.5em}
\item 译文质量的多角度评价。章节内主要介绍的几种经典方法如BLEU、TER、METEOR等,大都是从某个单一的角度计算机器译文和参考答案的相似性,如何对译文从多个角度进行综合评价是需要进一步思考的问题,\ref{Evaluation method of Multi Strategy fusion}节中介绍的多策略融合评价方法就可以看作是一种多角度评价方法,其思想是将各种评价方法下的译文得分通过某种方式进行组合,从而实现对译文的综合评价。译文质量多角度评价的另一种思路则是直接将BLEU、TER、Meteor等多种指标看做是某种特征,使用分类、回归、排序等机器学习手段形成一种综合度量。此外,也有相关工作专注于多等级的译文质量评价,使用聚类算法将大致译文按其质量分为不同等级,并对不同质量等级的译文按照不同权重组合几种不同的评价方法。
\vspace{0.5em}
\item 不同评价方法的应用场景有明显不同:人工评价主要用于需要对机器翻译系统进行准确的评估的场合。例如,在系统对比中利用人工评价方法对不同系统进行人工评价、给出最终排名,或上线机器翻译服务时对翻译品质进行详细的测试;有参考答案的自动评价则可以为机器翻译系统提供快速、相对可靠的评价。在机器翻译系统的快速研发过程中,一般都使用有参考答案的自动评价方法对最终模型的性能进行评估。有相关研究工作专注在机器翻译模型的训练过程中充分利用评价信息进行参数调优(如BLEU分数),其中比较有代表性的工作包括最小错误率训练\upcite{DBLP:conf/acl/Och03}、最小风险训练\upcite{DBLP:conf/acl/ShenCHHWSL16}等。这部分内容可以参考{\chapterseven}{\chapterthirteen}进行进一步阅读;无参考答案的质量评估主要用来对译文质量做出预测,经常被应用在是在一些无法提供参考译文的实时翻译场景中,例如人机交互过程、自动纠错、后编辑等\upcite{DBLP:conf/wmt/FreitagCR19}
\vspace{0.5em}
\item 另一个比较值得关注的一个研究问题是如何使模型更加鲁棒,因为通常情况下,一个质量评估模型会受语种、评价策略等问题的约束,设计一个能应用于任何语种,同时从单词、短语、句子等各个等级对译文质量进行评估的模型是很有难度的。Bicici等人最先关注质量评估的鲁棒性问题,并设计开发了一种与语言无关的机器翻译性能预测器\upcite{DBLP:journals/mt/BiciciGG13},此后又在该工作的基础上研究如何利用外在的、与语言无关的特征对译文进行句子级别的质量评估\upcite{DBLP:conf/wmt/BiciciW14},该项研究的最终成果是一个与语言无关,可以从各个等级对译文质量进行评估的模型——RTMs(Referential Translation Machines)\upcite{DBLP:conf/wmt/BiciciLW15a}
\vspace{0.5em}
\end{itemize}
......@@ -3,5 +3,5 @@
\multicolumn{1}{c|}{$x_1$} & 2 \\
\multicolumn{1}{c|}{$x_2$} & 1 \\
\multicolumn{1}{c|}{$x_3$} & 5 \\ \hline
\multicolumn{2}{c}{$c_{\mathbb{E}}(X)=8$}
\multicolumn{2}{c}{总频次$=8$}
\end{tabular}
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
%%% outline
%-------------------------------------------------------------------------
%%% 简易机器翻译系统 - step 3 decoding - example
\begin{tikzpicture}
\begin{scope}[scale=0.4]
{\footnotesize
\node [anchor=west,draw,thick,minimum width=2.8em, minimum height=2.0em,fill=green!30,drop shadow](num1) at (0,0) {C};
\node [anchor=north,circle,draw,thick,minimum width=2.0em,fill=red!30,drop shadow](num1-1) at ([yshift=-5.0em]num1.south) {};
\draw [->,very thick,ublue]([yshift=-0.2em]num1.south) -- ([yshift=0.2em]num1-1.north);
%%%%%%%%%%%%%%%%%%%%%%%%%%
\node [anchor=west,draw,thick,minimum width=2.8em, minimum height=2.0em,fill=green!30,drop shadow](num2) at ([xshift=5.2em]num1.east) {B};
\node [anchor=north,circle,draw,thick,minimum width=2.0em,fill=red!30,drop shadow](num2-1) at ([yshift=-5.0em]num2.south) {};
\draw [->,very thick]([xshift=0.2em]num1.east) -- ([xshift=-0.2em]num2.west);
\draw [->,very thick,ublue]([yshift=-0.2em]num2.south) -- ([yshift=0.2em]num2-1.north);
%%%%%%%%%%%%%%%%%%%%%%%%%%
\node [anchor=west,draw,thick,minimum width=2.8em, minimum height=2.0em,fill=green!30,drop shadow](num3) at ([xshift=5.2em]num2.east) {A};
\node [anchor=north,circle,draw,thick,minimum width=2.0em,fill=red!30,drop shadow](num3-1) at ([yshift=-5.0em]num3.south) {};
\draw [->,very thick]([xshift=0.2em]num2.east) -- ([xshift=-0.2em]num3.west);
\draw [->,very thick,ublue]([yshift=-0.2em]num3.south) -- ([yshift=0.2em]num3-1.north);
%%%%%%%%%%%%%%%%%%%%%%%%%%
\node [anchor=west,draw,thick,minimum width=2.8em, minimum height=2.0em,fill=green!30,drop shadow](num4) at ([xshift=5.2em]num3.east) {B};
\node [anchor=north,circle,draw,thick,minimum width=2.0em,fill=red!30,drop shadow](num4-1) at ([yshift=-5.0em]num4.south) {};
\draw [->,very thick]([xshift=0.2em]num3.east) -- ([xshift=-0.2em]num4.west);
\draw [->,very thick,ublue]([yshift=-0.2em]num4.south) -- ([yshift=0.2em]num4-1.north);
%%%%%%%%%%%%%%%%%%%%%%%%%%
\node [anchor=west,draw,thick,minimum width=2.8em, minimum height=2.0em,fill=green!30,drop shadow](num5) at ([xshift=5.2em]num4.east) {C};
\node [anchor=north,circle,draw,thick,minimum width=2.0em,fill=red!30,drop shadow](num5-1) at ([yshift=-5.0em]num5.south) {};
\draw [->,very thick]([xshift=0.2em]num4.east) -- ([xshift=-0.2em]num5.west);
\draw [->,very thick,ublue]([yshift=-0.2em]num5.south) -- ([yshift=0.2em]num5-1.north);
%%%%%%%%%%%%%%%%%%%%%%%%%%
\node [anchor=west,draw,thick,minimum width=2.8em, minimum height=2.0em,fill=green!30,drop shadow](num6) at ([xshift=5.2em]num5.east) {A};
\node [anchor=north,circle,draw,thick,minimum width=2.0em,fill=red!30,drop shadow](num6-1) at ([yshift=-5.0em]num6.south) {};
\draw [->,very thick]([xshift=0.2em]num5.east) -- ([xshift=-0.2em]num6.west);
\draw [->,very thick,ublue]([yshift=-0.2em]num6.south) -- ([yshift=0.2em]num6-1.north);
\node [anchor=north](word1) at ([xshift=2.5em,yshift=-3.0em]num1-1.south) {图示说明:};
\node [anchor=north,draw,thick,minimum width=2.8em, minimum height=2.0em,fill=green!30,drop shadow](word2) at ([xshift=-2.5em,yshift=-3.0em]word1.south) {C};
\node [anchor=west](word2-2) at ([xshift=1.5em]word2.east) {一个隐含状态};
\node [anchor=north,circle,draw,thick,minimum width=2.0em,fill=red!30,drop shadow](word3) at ([xshift=-2.5em,yshift=-12.2em]word1.south) {};
\node [anchor=west](word3-2) at ([xshift=2.1em]word3.east) {一个可见状态};
\draw [->,very thick]([xshift=6.4em]word2-2.east) -- ([xshift=11.6em]word2-2.east);
\node [anchor=west](word4) at ([xshift=13.1em]word2-2.east) {从一个隐含状态到下一个};
\node [anchor=west](word4-1) at ([xshift=13.1em,yshift=-4.0em]word2-2.east) {隐含状态的转换};
\draw [->,very thick,ublue]([xshift=30.7em,yshift=-0.2em]word3.north) -- ([xshift=30.7em,yshift=0.2em]word3.south);
\node [anchor=west](word5) at ([xshift=13.1em,yshift=-9.5em]word2-2.east) {从一个隐含状态到可见状};
\node [anchor=west](word5-1) at ([xshift=13.1em,yshift=-13.5em]word2-2.east) {态的输出};
}
\end{scope}
\end{tikzpicture}
......@@ -25,20 +25,20 @@
%% highlights
%\begin{pgfonlayer}{background}
{
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.71in] (line2highlight) at (line2.west) {};
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.65in] (line2highlight) at (line2.west) {};
}
{
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.71in] (line3highlight) at (line3.west) {};
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.71in] (line5highlight) at (line5.west) {};
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.65in] (line3highlight) at (line3.west) {};
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.65in] (line5highlight) at (line5.west) {};
}
{
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.71in] (line8highlight) at (line8.west) {};
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.65in] (line8highlight) at (line8.west) {};
}
{
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.71in] (line9highlight) at (line9.west) {};
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.65in] (line9highlight) at (line9.west) {};
}
{
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.71in] (line10highlight) at (line10.west) {};
\node[anchor=west,fill=blue!20,minimum height=0.16in,minimum width=1.65in] (line10highlight) at (line10.west) {};
}
%\end{pgfonlayer}
......@@ -71,7 +71,7 @@
\begin{pgfonlayer}{background}
{
\node[rectangle,draw,inner sep=0.2em,fill=blue!10,minimum width=2.2in] [fit = (remark1) (t5)] (remark1label) {};
\node[rectangle,draw,inner sep=0.2em,fill=blue!10,minimum width=2.25in] [fit = (remark1) (t5)] (remark1label) {};
}
\end{pgfonlayer}
}
......@@ -81,7 +81,7 @@
%% remark 2
\begin{scope}
{
\node [anchor=north west,draw,inner sep=2pt,fill=blue!10,minimum width=2.2in] (remark2) at ([yshift=-0.5em]remark1label.south west) {$best$用于保存当前最好的翻译结果 };
\node [anchor=north west,draw,inner sep=2pt,fill=blue!10,minimum width=2.25in] (remark2) at ([yshift=-0.5em]remark1label.south west) {$best$用于保存当前最好的翻译结果 };
}
\end{scope}
%% end of remark 2
......@@ -89,7 +89,7 @@
%% remark 3
\begin{scope}
{
\node [anchor=north west,draw,inner sep=2pt,fill=blue!10,minimum width=2.2in] (remark3) at ([yshift=-0.5em]remark2.south west) {$h$用于保存每步生成的所有译文候选 };
\node [anchor=north west,draw,inner sep=2pt,fill=blue!10,minimum width=2.25in] (remark3) at ([yshift=-0.5em]remark2.south west) {$h$用于保存每步生成的所有译文候选 };
}
\end{scope}
%% end of remark 3
......@@ -97,7 +97,7 @@
%% remark 4
\begin{scope}
{
\node [anchor=north west,inner sep=2pt,align=left] (remark4) at ([xshift=0.31em,yshift=-0.8em]remark3.south west) {\textsc{Join}($a,b$) 返回\\$a$$b$ 的所有组合 };
\node [anchor=north west,inner sep=2pt,align=left] (remark4) at ([xshift=0.35em,yshift=-0.8em]remark3.south west) {\textsc{Join}($a,b$) 返回\\$a$$b$ 的所有组合 };
{\scriptsize
\node [anchor=north west,inner sep=1pt,align=center,draw,minimum height=2.3em] (a1) at ([yshift=-0.5em]remark4.north east) {$a_1$\\$a_2$};
......@@ -109,7 +109,7 @@
\begin{pgfonlayer}{background}
{
\node[rectangle,draw,inner sep=2pt,fill=blue!10,minimum width=2.2in] [fit = (remark4) (result)] (remark4label) {};
\node[rectangle,draw,inner sep=2pt,fill=blue!10,minimum width=2.25in] [fit = (remark4) (result)] (remark4label) {};
}
\end{pgfonlayer}
}
......@@ -119,7 +119,7 @@
%% remark 5
\begin{scope}
{
\node [anchor=north west,align=left] (remark5) at ([xshift=0.72em,yshift=-1.6em]remark4.south west) {\textsc{PruneForTop1}\\保留得分最高的结果};
\node [anchor=north west,align=left] (remark5) at ([xshift=0.88em,yshift=-1.6em]remark4.south west) {\textsc{PruneForTop1}\\保留得分最高的结果};
\node [anchor=west,draw,inner sep=1pt] (s1) at ([yshift=-0.5em,xshift=1.2em]remark5.north east){\tiny{0.234}};
\node [anchor=north west,draw,inner sep=1pt] (s2) at ([yshift=-0.2em]s1.south west){\tiny{0.197}};
\node [anchor=north west,draw,inner sep=1pt] (s3) at ([yshift=-0.2em]s2.south west){\tiny{0.083}};
......@@ -129,7 +129,7 @@
\begin{pgfonlayer}{background}
{
\node[rectangle,draw,inner sep=0.2em,fill=blue!10,minimum width=2.2in] [fit = (remark5) (top1)] (remark5label) {};
\node[rectangle,draw,inner sep=0.2em,fill=blue!10,minimum width=2.25in] [fit = (remark5) (top1)] (remark5label) {};
}
\end{pgfonlayer}
}
......@@ -152,7 +152,7 @@
\begin{pgfonlayer}{background}
{
\node[rectangle,draw,inner sep=0.2em,fill=blue!10,minimum width=2.2in] [fit = (remark6) (s5)] (remark6label) {};
\node[rectangle,draw,inner sep=0.2em,fill=blue!10,minimum width=2.25in] [fit = (remark6) (s5)] (remark6label) {};
}
\end{pgfonlayer}
}
......
......@@ -10,7 +10,7 @@
\node [anchor=west] (s3) at ([xshift=2em]s2.east) {{}};
\node [anchor=west] (s4) at ([xshift=2em]s3.east) {{感到}};
\node [anchor=west] (s5) at ([xshift=2em]s4.east) {{满意}};
\node [anchor=south west] (sentlabel) at ([yshift=-0.5em]s1.north west) {\scriptsize{\sffamily\bfseries{\color{red}{待翻译句子(已经分词):}}}};
\node [anchor=south west] (sentlabel) at ([yshift=-0.5em]s1.north west) {\scriptsize{\sffamily\bfseries{待翻译句子(已经分词):}}};
{
\draw [->,very thick,ublue] (s1.south) -- ([yshift=-0.7em]s1.south);
......
......@@ -8,7 +8,7 @@
\node [anchor=west] (s4) at ([xshift=2em]s3.east) {{感到}};
\node [anchor=west] (s5) at ([xshift=2em]s4.east) {{满意}};
\node [anchor=south west] (sentlabel) at ([yshift=-0.5em]s1.north west) {\scriptsize{{\color{red}{待翻译句子(已经分词):}}}};
\node [anchor=south west] (sentlabel) at ([yshift=-0.5em]s1.north west) {\scriptsize{\sffamily\bfseries{待翻译句子(已经分词):}}};
\draw [->,very thick,ublue] (s1.south) -- ([yshift=-0.7em]s1.south);
\draw [->,very thick,ublue] (s2.south) -- ([yshift=-0.7em]s2.south);
......@@ -202,8 +202,8 @@
\node [anchor=west] (score1) at ([xshift=1.5em]ft14.east) {\footnotesize{P=0.042}};
\node [anchor=west] (score2) at ([xshift=1.5em]ft24.east) {\footnotesize{P=0.006}};
\node [anchor=west] (score3) at ([xshift=1.5em]ft34.east) {\footnotesize{P=0.003}};
\node [anchor=south] (scorelabel) at ([xshift=-2.0em]score1.north) {\scriptsize{{\color{red}{率给每个译文赋予一个模型得分}}}};
\node [anchor=south] (scorelabel2) at ([yshift=-0.5em]scorelabel.north) {\scriptsize{{\color{red}{系统综合单词概率和语言模型概}}}};
\node [anchor=south] (scorelabel) at ([xshift=-2.0em]score1.north) {\scriptsize{{\color{black}{率给每个译文赋予一个模型得分}}}};
\node [anchor=south] (scorelabel2) at ([yshift=-0.5em]scorelabel.north) {\scriptsize{{\color{black}{系统综合单词概率和语言模型概}}}};
}
{
\node [anchor=north] (scorelabel2) at (score3.south) {\scriptsize{{选择得分}}};
......
......@@ -22,10 +22,10 @@
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow,minimum height=1.6cm] [fit = (P) (modellabel)] (model) {};
\end{pgfonlayer}
\draw [->,very thick,ublue] ([xshift=0.2em]corpus.east) -- ([xshift=4.2em]corpus.east) node [pos=0.5, above] {\color{red}{\scriptsize{模型学习}}};
\draw [->,very thick,ublue] ([xshift=0.2em]corpus.east) -- ([xshift=4.2em]corpus.east) node [pos=0.5, above] {\color{black}{\scriptsize{训练}}};
{
\draw [->,very thick,ublue] ([xshift=0.4em]model.east) -- ([xshift=4.4em]model.east) node [inner sep=0pt,pos=0.5, above,yshift=0.3em] (decodingarrow) {\color{red}{\scriptsize{搜索\&计算}}};
\draw [->,very thick,ublue] ([xshift=0.4em]model.east) -- ([xshift=4.4em]model.east) node [inner sep=0pt,pos=0.5, above,yshift=0.3em] (decodingarrow) {\color{black}{\scriptsize{解码}}};
{\scriptsize
\node [anchor=north west,inner sep=2pt] (sentlabel) at ([xshift=6.5em,yshift=-0.9em]model.north east) {{\color{ublue} \sffamily\bfseries{机器翻译引擎}}};
......
......@@ -22,9 +22,9 @@
\node[rectangle,draw=ublue,thick,inner sep=0.2em,fill=white,drop shadow,minimum height=1.6cm] [fit = (P) (modellabel)] (model) {};
\end{pgfonlayer}
\draw [->,very thick,ublue] ([xshift=0.2em]corpus.east) -- ([xshift=3.0em]corpus.east) node [inner sep=0pt,pos=0.5,above,yshift=0.3em] (trainingarrow) {\color{red}{\scriptsize{模型学习}}};
\draw [->,very thick,ublue] ([xshift=0.2em]corpus.east) -- ([xshift=3.0em]corpus.east) node [inner sep=0pt,pos=0.5,above,yshift=0.3em] (trainingarrow) {\color{black}{\scriptsize{训练}}};
\draw [->,very thick,ublue] ([xshift=0.4em]model.east) -- ([xshift=3.4em]model.east) node [inner sep=0pt,pos=0.5,above,yshift=0.3em] (decodingarrow) {\color{red}{\scriptsize{穷举\&计算}}};
\draw [->,very thick,ublue] ([xshift=0.4em]model.east) -- ([xshift=3.4em]model.east) node [inner sep=0pt,pos=0.5,above,yshift=0.3em] (decodingarrow) {\color{black}{\scriptsize{解码}}};
{\scriptsize
\node [anchor=north west,inner sep=2pt] (sentlabel) at ([xshift=5.5em,yshift=-0.9em]model.north east) {{\color{ublue} \sffamily\bfseries{机器翻译引擎}}};
......
......@@ -39,7 +39,7 @@
\end{tikzpicture}
& {\tikz{\node[minimum height=3.2em]{\small{0.0023}{\color{red}\small{$\times$0.0107}}};}} \\
& {\tikz{\node[minimum height=3.2em]{\small{\ 0.0023}{\color{red}\small{$\times$0.0107}}};}} \\
\begin{tikzpicture}
......@@ -76,7 +76,7 @@
\end{tikzpicture}
&{ \tikz{\node[minimum height=3em]{\small{0.0023}{\color{red}\small{$\times$0.0009}}};}}\\
&{ \tikz{\node[minimum height=3.2em]{\small{0.0023}{\color{red}\small{$\times$0.0009}}};}}\\
\hline
\end{tabular}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
%%% outline
%-------------------------------------------------------------------------
\newlength{\bc}
\setlength{\bc}{0.5cm}
\begin{tikzpicture}
\begin{scope}
\filldraw [fill=white,drop shadow] (0,0) rectangle (\bc*5,\bc*5);
\filldraw [fill=black] (\bc*2,0) rectangle (\bc*3,\bc*1);
\filldraw [fill=black] (\bc*1,\bc*1) rectangle (\bc*2,\bc*2);
\filldraw [fill=black] (\bc*4,\bc*2) rectangle (\bc*5,\bc*3);
\filldraw [fill=black] (\bc*3,\bc*3) rectangle (\bc*4,\bc*4);
\filldraw [fill=black] (0,\bc*4) rectangle (\bc*1,\bc*5);
\draw [step=\bc, very thin, color=gray] (0,0) grid (\bc*5,\bc*5);
\draw [line width=1pt] (0,0) -- (0,\bc*5)--(\bc*5,\bc*5) -- (\bc*5,0) -- (0,0);
\coordinate (o) at (0,\bc*5);
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm]o.west){};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc]o.west){};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc*2]o.west){};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc*3]o.west){感到};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc*4]o.west){满意};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.2cm,yshift=0.4em]o.east){I};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc,yshift=0.4em]o.east){am};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*2,yshift=0.4em]o.east){satisfied};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*3,yshift=0.4em]o.east){with};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*4,yshift=0.4em]o.east){you};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=\bc*4.5,yshift=-1.0cm-\bc*4]o.west){(a)对齐实例1};
\end{scope}
\begin{scope}[xshift=15.0em]
\filldraw [fill=white,drop shadow] (0,0) rectangle (\bc*8,\bc*6);
\filldraw [fill=black] (0,\bc*5) rectangle (\bc*1,\bc*6);
\filldraw [fill=black] (\bc*1,\bc*3) rectangle (\bc*2,\bc*4);
\filldraw [fill=black] (\bc*2,\bc*2) rectangle (\bc*3,\bc*3);
\filldraw [fill=black] (\bc*3,\bc*2) rectangle (\bc*4,\bc*3);
\filldraw [fill=black] (\bc*4,\bc*1) rectangle (\bc*5,\bc*2);
\filldraw [fill=black] (\bc*5,0) rectangle (\bc*6,\bc*1);
\filldraw [fill=black] (\bc*6,\bc*4) rectangle (\bc*7,\bc*5);
\filldraw [fill=black] (\bc*7,\bc*4) rectangle (\bc*8,\bc*5);
\draw [step=\bc, very thin, color=gray] (0,0) grid (\bc*8,\bc*6);
\draw [line width=1pt] (0,0) -- (0,\bc*6)--(\bc*8,\bc*6) -- (\bc*8,0) -- (0,0);
\coordinate (o) at (0,\bc*6);
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm]o.west){};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc]o.west){每天};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc*2]o.west){乘坐};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc*3]o.west){地铁};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc*4]o.west){};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=-0.4em,yshift=-0.25cm-\bc*5]o.west){上班};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm,yshift=0.4em]o.east){He};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc,yshift=0.4em]o.east){takes};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*2,yshift=0.4em]o.east){the};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*3,yshift=0.4em]o.east){subway};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*4,yshift=0.4em]o.east){to};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*5,yshift=0.4em]o.east){work};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*6,yshift=0.4em]o.east){every};
\node[anchor=west,inner sep=0pt,font=\footnotesize,rotate=45] at([xshift=0.1cm+\bc*7,yshift=0.4em]o.east){day};
\node[anchor=east,inner sep=0pt,font=\footnotesize] at([xshift=\bc*6.0,yshift=-1.0cm-\bc*5]o.west){(b)对齐实例2};
\end{scope}
\end{tikzpicture}
%---------------------------------------------------------------------
\ No newline at end of file
......@@ -10,39 +10,39 @@
}
{\scriptsize
\node [anchor=west,minimum height=2.5em,minimum width=5.0em] (sf1) at ([xshift=1em]st.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s1) at ([xshift=2.48em]sf1.east) {科学家};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s2) at ([xshift=2.19em]s1.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s3) at ([xshift=2.185em]s2.east) {并不};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s4) at ([xshift=2.183em]s3.east) {知道};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s1) at ([xshift=2.5em]sf1.east) {科学家};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s2) at ([xshift=2.5em]s1.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s3) at ([xshift=2.5em]s2.east) {并不};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s4) at ([xshift=2.5em]s3.east) {知道};
}
{\scriptsize
\node [anchor=west] (tau11) at ([xshift=1.5em]taut.east) {$\tau_0$\tiny{1.NULL}};
\node [anchor=west] (tau11) at ([xshift=1.24em]taut.east) {$\tau_0$\; \tiny{1.NULL}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau1) [fit = (tau11)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau1) [fit = (tau11)] {};
\end{pgfonlayer}
\node [anchor=west] (tau21) at ([xshift=1.80em]tau1.east) {$\tau_1$};
\node [anchor=west] (tau21) at ([xshift=1.575em]tau1.east) {$\tau_1$\;};
\node [anchor=west] (tau22) at ([yshift=-0.2em,xshift=-0.5em]tau21.north east) {\tiny{1.科学家}};
\node [anchor=west] (tau23) at ([yshift=0.2em,xshift=-0.5em]tau21.south east) {\tiny{2.们}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=blue!30,drop shadow] (tau2)[fit = (tau21) (tau22) (tau23)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau2)[fit = (tau21) (tau22) (tau23)] {};
\end{pgfonlayer}
\node [anchor=west] (tau31) at ([xshift=2.05em]tau2.east) {$\tau_2$\tiny{1.NULL}};
\node [anchor=west] (tau31) at ([xshift=1.997em]tau2.east) {$\tau_2$\; \tiny{1.NULL}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau3) [fit = (tau31)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau3) [fit = (tau31)] {};
\end{pgfonlayer}
\node [anchor=west] (tau41) at ([xshift=2.2em]tau3.east) {$\tau_3$\tiny{1.并不}};
\node [anchor=west] (tau41) at ([xshift=2.153em]tau3.east) {$\tau_3$\; \tiny{1.并不}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau4) [fit = (tau41)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau4) [fit = (tau41)] {};
\end{pgfonlayer}
\node [anchor=west] (tau51) at ([xshift=2.2em]tau4.east) {$\tau_4$\tiny{1.知道}};
\node [anchor=west] (tau51) at ([xshift=2.1525em]tau4.east) {$\tau_4$\; \tiny{1.知道}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau5) [fit = (tau51)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau5) [fit = (tau51)] {};
\end{pgfonlayer}
}
......@@ -73,37 +73,37 @@
{\scriptsize
\node [anchor=west,minimum height=2.5em,minimum width=5.0em] (sf12) at ([yshift=-15.0em,xshift=1em]st.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s12) at ([xshift=2.48em]sf12.east) {科学家};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s22) at ([xshift=2.19em]s12.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s32) at ([xshift=2.185em]s22.east) {并不};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s42) at ([xshift=2.183em]s32.east) {知道};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s12) at ([xshift=2.5em]sf12.east) {科学家};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s22) at ([xshift=2.5em]s12.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s32) at ([xshift=2.5em]s22.east) {并不};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s42) at ([xshift=2.5em]s32.east) {知道};
}
{\scriptsize
\node [anchor=west] (tau112) at ([yshift=-15.0em,xshift=1.5em]taut.east) {$\tau_0$\tiny{1.NULL}};
\node [anchor=west] (tau112) at ([yshift=-15.0em,xshift=1.24em]taut.east) {$\tau_0$\; \tiny{1.NULL}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau12) [fit = (tau112)] {};
\end{pgfonlayer}
\node [anchor=west] (tau212) at ([xshift=1.80em]tau12.east) {$\tau_1$};
\node [anchor=west] (tau212) at ([xshift=1.6762em]tau12.east) {$\tau_1$\;};
\node [anchor=west] (tau222) at ([yshift=-0.2em,xshift=-0.5em]tau212.north east) {\tiny{1.们}};
\node [anchor=west] (tau232) at ([yshift=0.2em,xshift=-0.5em]tau212.south east) {\tiny{2.科学家}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=yellow!30,drop shadow] (tau22)[fit = (tau212) (tau222) (tau232)] {};
\end{pgfonlayer}
\node [anchor=west] (tau312) at ([xshift=2.05em]tau22.east) {$\tau_2$\tiny{1.NULL}};
\node [anchor=west] (tau312) at ([xshift=1.997em]tau22.east) {$\tau_2$\; \tiny{1.NULL}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau32) [fit = (tau312)] {};
\end{pgfonlayer}
\node [anchor=west] (tau412) at ([xshift=2.2em]tau32.east) {$\tau_3$\tiny{1.并不}};
\node [anchor=west] (tau412) at ([xshift=1.9555em]tau32.east) {$\tau_3$\; \tiny{1.并不}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau42) [fit = (tau412)] {};
\end{pgfonlayer}
\node [anchor=west] (tau512) at ([xshift=2.2em]tau42.east) {$\tau_4$\tiny{1.知道}};
\node [anchor=west] (tau512) at ([xshift=2.2525em]tau42.east) {$\tau_4$\; \tiny{1.知道}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau52) [fit = (tau512)] {};
\end{pgfonlayer}
......@@ -131,6 +131,7 @@
\draw [->,thick] (d42.north) -- ([yshift=-4.45em]s32.south);
\draw [->,thick] (d52.north) -- ([yshift=-4.45em]s42.south);
%\end{scope}
\end{tikzpicture}
......
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
\begin{scope}
\tikzstyle{cand} = [draw,inner sep=4pt,line width=1pt,align=center,drop shadow,minimum height =1.6em,minimum width=4.2em,fill=green!30]
\tikzstyle{ref} = [draw,inner sep=4pt,line width=1pt,align=center,drop shadow,minimum height =1.6em,minimum width=4.2em,fill=red!30]
\node[align=center,minimum width=2.4em,minimum height=1.6em,minimum width=6em] (n11) at (0,0){源语};
\node[cand,anchor=west] (n12) at ([xshift=0.0em]n11.east){};
\node[cand,anchor=west] (n13) at ([xshift=1em]n12.east){};
\node[cand,anchor=west] (n14) at ([xshift=1em]n13.east){};
\node[cand,anchor=west] (n15) at ([xshift=1em]n14.east){感到};
\node[cand,anchor=west] (n16) at ([xshift=1em]n15.east){满意};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n21) at ([yshift=-4em]n11.south){顺序翻译};
\node[ref,anchor=west] (n22) at ([xshift=0.0em]n21.east){I};
\node[ref,anchor=west] (n23) at ([xshift=1em]n22.east){with};
\node[ref,anchor=west] (n24) at ([xshift=1em]n23.east){you};
\node[ref,anchor=west] (n25) at ([xshift=1em]n24.east){am};
\node[ref,anchor=west] (n26) at ([xshift=1em]n25.east){satisfied};
\draw[line width=1.2pt,dashed] ([yshift=-0.3em]n12.south) -- ([yshift=0.2em]n22.north);
\draw[line width=1.2pt,dashed] ([yshift=-0.3em]n13.south) -- ([yshift=0.2em]n23.north);
\draw[line width=1.2pt,dashed] ([yshift=-0.3em]n14.south) -- ([yshift=0.2em]n24.north);
\draw[line width=1.2pt,dashed] ([yshift=-0.3em]n15.south) -- ([yshift=0.2em]n25.north);
\draw[line width=1.2pt,dashed] ([yshift=-0.3em]n16.south) -- ([yshift=0.2em]n26.north);
\node[anchor=west] at([xshift=5.5em,yshift=-3em]n21.east){(a)顺序翻译对齐结果};
\end{scope}
\begin{scope}[yshift=-11.5em]
\tikzstyle{cand} = [draw,inner sep=4pt,line width=1pt,align=center,drop shadow,minimum height =1.6em,minimum width=4.2em,fill=green!30]
\tikzstyle{ref} = [draw,inner sep=4pt,line width=1pt,align=center,drop shadow,minimum height =1.6em,minimum width=4.2em,fill=red!30]
\node[align=center,minimum width=2.4em,minimum height=1.6em,minimum width=6em] (n11) at (0,0){源语};
\node[cand,anchor=west] (n12) at ([xshift=0.0em]n11.east){};
\node[cand,anchor=west] (n13) at ([xshift=1em]n12.east){};
\node[cand,anchor=west] (n14) at ([xshift=1em]n13.east){};
\node[cand,anchor=west] (n15) at ([xshift=1em]n14.east){感到};
\node[cand,anchor=west] (n16) at ([xshift=1em]n15.east){满意};
\node[align=center,minimum width=2.4em,minimum height=1.6em,anchor=north,minimum width=6em] (n21) at ([yshift=-4em]n11.south){调序翻译};
\node[ref,anchor=west] (n22) at ([xshift=0.0em]n21.east){I};
\node[ref,anchor=west] (n23) at ([xshift=1em]n22.east){am};
\node[ref,anchor=west] (n24) at ([xshift=1em]n23.east){satisfied};
\node[ref,anchor=west] (n25) at ([xshift=1em]n24.east){with};
\node[ref,anchor=west] (n26) at ([xshift=1em]n25.east){you};
\draw[line width=1.2pt,dashed] ([yshift=-0.3em]n12.south) -- ([yshift=0.2em]n22.north);
\draw[line width=1.2pt,dashed,out=-40,in=140] ([yshift=-0.3em]n13.south) to ([yshift=0.2em]n25.north);
\draw[line width=1.2pt,dashed,out=-40,in=140] ([yshift=-0.3em]n14.south) to ([yshift=0.2em]n26.north);
\draw[line width=1.2pt,dashed,out=-140,in=40] ([yshift=-0.3em]n15.south) to ([yshift=0.2em]n23.north);
\draw[line width=1.2pt,dashed,out=-140,in=40] ([yshift=-0.3em]n16.south) to ([yshift=0.2em]n24.north);
\node[anchor=west] at([xshift=5.5em,yshift=-3em]n21.east){(b)调序翻译对齐结果};
\end{scope}
\end{tikzpicture}
%---------------------------------------------------------------------
\ No newline at end of file
......@@ -11,39 +11,39 @@
}
{\scriptsize
\node [anchor=west,minimum height=2.5em,minimum width=5.0em] (sf1) at ([xshift=1em]st.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s1) at ([xshift=2.48em]sf1.east) {科学家};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s2) at ([xshift=2.19em]s1.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s3) at ([xshift=2.185em]s2.east) {并不};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s4) at ([xshift=2.183em]s3.east) {知道};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s1) at ([xshift=2.5em]sf1.east) {科学家};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s2) at ([xshift=2.5em]s1.east) {};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s3) at ([xshift=2.5em]s2.east) {并不};
\node [rectangle,draw,anchor=west,line width=1pt,minimum height=2.5em,minimum width=5.0em,fill=green!30,drop shadow] (s4) at ([xshift=2.5em]s3.east) {知道};
}
{\scriptsize
\node [anchor=west] (tau11) at ([xshift=1.5em]taut.east) {$\tau_0$\tiny{1.NULL}};
\node [anchor=west] (tau11) at ([xshift=1.24em]taut.east) {$\tau_0$\; \tiny{1.NULL}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau1) [fit = (tau11)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau1) [fit = (tau11)] {};
\end{pgfonlayer}
\node [anchor=west] (tau21) at ([xshift=1.80em]tau1.east) {$\tau_1$};
\node [anchor=west] (tau21) at ([xshift=1.575em]tau1.east) {$\tau_1$\;};
\node [anchor=west] (tau22) at ([yshift=-0.2em,xshift=-0.5em]tau21.north east) {\tiny{1.科学家}};
\node [anchor=west] (tau23) at ([yshift=0.2em,xshift=-0.5em]tau21.south east) {\tiny{2.们}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau2)[fit = (tau21) (tau22) (tau23)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau2)[fit = (tau21) (tau22) (tau23)] {};
\end{pgfonlayer}
\node [anchor=west] (tau31) at ([xshift=2.05em]tau2.east) {$\tau_2$\tiny{1.NULL}};
\node [anchor=west] (tau31) at ([xshift=1.997em]tau2.east) {$\tau_2$\; \tiny{1.NULL}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau3) [fit = (tau31)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau3) [fit = (tau31)] {};
\end{pgfonlayer}
\node [anchor=west] (tau41) at ([xshift=2.2em]tau3.east) {$\tau_3$\tiny{1.并不}};
\node [anchor=west] (tau41) at ([xshift=2.153em]tau3.east) {$\tau_3$\; \tiny{1.并不}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau4) [fit = (tau41)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau4) [fit = (tau41)] {};
\end{pgfonlayer}
\node [anchor=west] (tau51) at ([xshift=2.2em]tau4.east) {$\tau_4$\tiny{1.知道}};
\node [anchor=west] (tau51) at ([xshift=2.1525em]tau4.east) {$\tau_4$\; \tiny{1.知道}};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=red!30,drop shadow] (tau5) [fit = (tau51)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=red!30,drop shadow] (tau5) [fit = (tau51)] {};
\end{pgfonlayer}
}
......@@ -51,27 +51,27 @@
{\scriptsize
\node [anchor=west] (phi11) at ([xshift=2.3em]phit.east) {$\phi_0$\ 0};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=blue!30,drop shadow] (phi1) [fit = (phi11)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=blue!30,drop shadow] (phi1) [fit = (phi11)] {};
\end{pgfonlayer}
\node [anchor=west] (phi21) at ([xshift=2.947em]phi1.east) {$\phi_1$\ 2};
\node [anchor=west] (phi21) at ([xshift=2.867em]phi1.east) {$\phi_1$\ 2};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=blue!30,drop shadow] (phi2) [fit = (phi21)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=blue!30,drop shadow] (phi2) [fit = (phi21)] {};
\end{pgfonlayer}
\node [anchor=west] (phi31) at ([xshift=2.876em]phi2.east) {$\phi_2$\ 0};
\node [anchor=west] (phi31) at ([xshift=3.087em]phi2.east) {$\phi_2$\ 0};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=blue!30,drop shadow] (phi3) [fit = (phi31)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=blue!30,drop shadow] (phi3) [fit = (phi31)] {};
\end{pgfonlayer}
\node [anchor=west] (phi41) at ([xshift=2.8715em]phi3.east) {$\phi_3$\ 1};
\node [anchor=west] (phi41) at ([xshift=3.086em]phi3.east) {$\phi_3$\ 1};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=blue!30,drop shadow] (phi4) [fit = (phi41)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=blue!30,drop shadow] (phi4) [fit = (phi41)] {};
\end{pgfonlayer}
\node [anchor=west] (phi51) at ([xshift=2.86925em]phi4.east) {$\phi_4$\ 1};
\node [anchor=west] (phi51) at ([xshift=3.086em]phi4.east) {$\phi_4$\ 1};
\begin{pgfonlayer}{background}
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=6.8em,fill=blue!30,drop shadow] (phi5) [fit = (phi51)] {};
\node [rounded rectangle,draw,line width=1pt,minimum height=3.0em,minimum width=7.0em,fill=blue!30,drop shadow] (phi5) [fit = (phi51)] {};
\end{pgfonlayer}
}
......@@ -105,7 +105,6 @@
\draw [->,thick] (t4.north) -- (phi4.south);
\draw [->,thick] (t5.north) -- (phi5.south);
{\scriptsize
\node [anchor=west] (sent11) at ([xshift=1em,yshift=-0.3em]s4.south east) {把这些元语};
\node [anchor=west] (sent12) at ([yshift=-1em]sent11.west) {言单词放在};
......
%%% outline
%-------------------------------------------------------------------------
\begin{tikzpicture}
{
\node [anchor=west,inner sep=2pt] (s1) at (0,0) {$s_1$:在};
\node [anchor=west,inner sep=2pt] (s2) at ([xshift=2em]s1.east) {$s_2$:桌子};
\node [anchor=west,inner sep=2pt] (s3) at ([xshift=2em]s2.east) {$s_3$:上};
\node [anchor=north,inner sep=2pt] (t1) at ([yshift=-2.4em]s1.center) {$t_1$:on};
\node [anchor=north,inner sep=2pt] (t2) at ([yshift=-2.4em]s2.center) {$t_2$:the};
\node [anchor=north,inner sep=2pt] (t3) at ([yshift=-2.4em]s3.center) {$t_3$:table};
\node [anchor=east,inner sep=2pt] (t0) at ([xshift=-2.2em]t1.west) {$t_0$};
\draw [-,dashed,thick] (s1.south) -- (t0.north);
\draw [-,dashed,thick] (s2.south) -- (t3.north);
\draw [-,dashed,thick] (s3.south) -- (t1.north);
}
\begin{pgfonlayer}{background}
{
\path [fill=red!20] (s2.north west) -- (s2.south west) -- (t3.north west) -- (t3.south west) -- (t3.south east) -- (t3.north east) -- (s2.south east) -- (s2.north east) -- (s2.north west);
}
\end{pgfonlayer}
\end{tikzpicture}
%---------------------------------------------------------------------
......@@ -22,11 +22,11 @@
\end{scope}
\draw [-,thick,ublue,dashed] (s1.south) -- (t1.north);
\draw [-,thick,ublue,dashed] (s4.south) -- ([yshift=0.3em]t2.north);
\draw [-,thick,ublue,dashed] (s2.south) ..controls +(south:1em) and +(north:1em).. (t4.north);
\draw [-,thick,ublue,dashed] (s3.south) ..controls +(south:0.5em) and +(north:1.5em).. (t5.north);
\draw [-,thick,ublue,dashed] (s5.south) -- (t3.north);
\draw [-,thick,dashed] (s1.south) -- (t1.north);
\draw [-,thick,dashed] (s4.south) -- ([yshift=0.3em]t2.north);
\draw [-,thick,dashed] (s2.south) ..controls +(south:1em) and +(north:1em).. (t4.north);
\draw [-,thick,dashed] (s3.south) ..controls +(south:0.5em) and +(north:1.5em).. (t5.north);
\draw [-,thick,dashed] (s5.south) -- (t3.north);
\end{tikzpicture}
......
......@@ -23,7 +23,7 @@
\chapter{基于扭曲度和繁衍率的模型}
第五章展示了一种简单的基于单词的翻译模型。这种模型的形式非常简单,而且其隐含的词对齐信息具有较好的可解释性。不过,语言翻译的复杂性远远超出人们想象。这里仍然面临两方面挑战\ \dash\ 如何对`` 调序''问题进行建模以及如何对``一对多翻译''问题进行建模。调序是翻译问题中所特有的现象,比如,汉语到日语的翻译中,需要对谓词进行调序。另一方面,一个单词在另一种语言中可能会被翻译为多个连续的词,比如,汉语`` 联合国''翻译到英语会对应三个单词``The United Nations''。这种现象也被称作一对多翻译
{\chapterfive}展示了一种基于单词的翻译模型。这种模型的形式非常简单,而且其隐含的词对齐信息具有较好的可解释性。不过,语言翻译的复杂性远远超出人们的想象。有两方面挑战\ \dash\ 如何对`` 调序''问题进行建模以及如何对``一对多翻译''问题进行建模。调序是翻译问题中所特有的现象,比如,汉语到日语的翻译中,需要对谓词进行调序。另一方面,一个单词在另一种语言中可能会被翻译为多个连续的词,比如,汉语`` 联合国''翻译到英语会对应三个单词``The United Nations''。这种现象也被称作一对多翻译,它与句子长度预测有着密切的联系
无论是调序还是一对多翻译,简单的翻译模型(如IBM模型1)都无法对其进行很好的处理。因此,需要考虑对这两个问题单独进行建模。本章将会对机器翻译中两个常用的概念进行介绍\ \dash\ 扭曲度(Distortion)和繁衍率(Fertility)。它们可以被看做是对调序和一对多翻译现象的一种统计描述。基于此,本章会进一步介绍基于扭曲度和繁衍率的翻译模型,建立相对完整的基于单词的统计建模体系。相关的技术和概念在后续章节也会被进一步应用。
......@@ -34,52 +34,82 @@
\sectionnewpage
\section{基于扭曲度的翻译模型}
下面将介绍扭曲度在机器翻译中的定义及使用方法。这也带来了两个新的翻译模型\ \dash\ IBM模型2和HMM翻译模型
下面将介绍扭曲度在机器翻译中的定义及使用方法。这也带来了两个新的翻译模型\ \dash\ IBM模型2\upcite{Peter1993The}和HMM翻译模型\upcite{vogel1996hmm}
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{什么是扭曲度}
可以考虑先用例子描述一下翻译中的调序,之后说单词调序对应着``调序距离'',这种距离实际上可以被看做是一种扭曲度。。。
\parinterval {\small\sffamily\bfseries{调序}}(Reordering)是自然语言翻译中特有的语言现象。造成这个现象的主要原因在于不同语言之间语序的差异,比如,汉语是“主谓宾”结构,而日语是“主宾谓”结构。即使在句子整体结构相似的语言上进行翻译,调序也是频繁出现的现象。如图\ref{fig:6-1}所示,当一个主动语态的汉语句子翻译为一个被动语态的英语句子时,如果直接顺序翻译,那么翻译结果“I with you am satisfied”很明显不符合英语语法。这里就需要采取一些方法和手段在翻译过程中对词或短语进行调序,从而得到正确的翻译结果。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter6/Figures/figure-examples-of-sequential-translation-and-reorder-translation}
\caption{顺序翻译和调序翻译的实例对比}
\label{fig:6-1}
\end{figure}
%----------------------------------------------
\parinterval 在对调序问题进行建模的方法中,最基本的是使用调序距离方法。这里,可以假设完全进行顺序翻译时,调序的“代价”是最低的。当调序出现时,可以用调序相对于顺序翻译产生的位置偏移来度量调序的程度,也被称为调序距离。图\ref{fig:6-2}展示了翻译时两种语言中词的对齐矩阵。比如,在图\ref{fig:6-2}(a)中,系统需要跳过“对”和“你”来翻译“感到”和“满意”,之后再回过头翻译“对”和“你”,这样就完成了对单词的调序。这时可以简单的把需要跳过的单词数看作一种距离。
\parinterval 可以看到,调序距离实际上是在度量目标语言词序相对于源语言词序的一种扭曲程度。因此,也常常把这种调序距离称作{\small\sffamily\bfseries{扭曲度}}(Distortion)。调序距离越大对应的扭曲度也越大。比如,可以明显看出图\ref{fig:6-2}(b)中调序的扭曲度要比图\ref{fig:6-2}(a)中调序的扭曲度大,因此\ref{fig:6-2}(b)实例的调序代价也更大。
\parinterval 在机器翻译中使用扭曲度进行翻译建模是一种十分自然的想法。接下来,会介绍两个基于扭曲度的翻译模型,分别是IBM模型2和隐马尔可夫模型。不同于IBM模型1,它们利用了单词的位置信息定义了扭曲度,并将扭曲度融入翻译模型中,使得对翻译问题的建模更加合理。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter6/Figures/figure-alignment-matrix-for-zh-to-en-translation}
\caption{汉语到英语翻译的对齐矩阵}
\label{fig:6-2}
\end{figure}
%----------------------------------------------
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{IBM模型2}
\parinterval IBM模型1很好地化简了问题,但是由于使用了很强的假设,导致模型和实际情况有较大差异。其中一个比较严重的问题是假设词对齐的生成概率服从均匀分布。图\ref{fig:5-20}展示了一个简单的实例。尽管译文$\mathbf{t}$$\mathbf{t}'$的质量更好,但对于IBM模型1来说它们对应的翻译概率相同。这是因为当词对齐服从均匀分布时,模型会忽略目标语言单词的位置信息。因此当单词翻译相同但顺序不同时,翻译概率一样。同时,由于源语言单词是由错误位置的目标语单词生成的,不合理的对齐也会导致不合理的词汇翻译概率。
\parinterval 对于建模来说,IBM模型1很好地化简了翻译问题,但是由于使用了很强的假设,导致模型和实际情况有较大差异。其中一个比较严重的问题是假设词对齐的生成概率服从均匀分布。IBM模型2抛弃了这个假设\upcite{Peter1993The}。它认为词对齐是有倾向性的,它与源语言单词的位置和目标语言单词的位置有关。具体来说,对齐位置$a_j$的生成概率与位置$j$、源语言句子长度$m$和目标语言句子长度$l$有关,形式化表述为:
\begin{eqnarray}
\funp{P}(a_j|a_1^{j-1},s_1^{j-1},m,\vectorn{t}) \equiv a(a_j|j,m,l)
\label{eq:6-1}
\end{eqnarray}
\parinterval 这里还用{\chapterthree}中的例子(图\ref{fig:6-3})来进行说明。在IBM模型1中,``桌子''对齐到目标语言四个位置的概率是一样的。但在IBM模型2中,``桌子''对齐到``table''被形式化为$a(a_j |j,m,l)=a(3|2,3,3)$,意思是对于源语言位置2($j=2$)的词,如果它的源语言和目标语言都是3个词($l=3,m=3$),对齐到目标语言位置3($a_j=3$)的概率是多少?因为$a(a_j|j,m,l)$也是模型需要学习的参数,因此``桌子''对齐到不同目标语言单词的概率也是不一样的。理想的情况下,通过$a(a_j|j,m,l)$,``桌子''对齐到``table''应该得到更高的概率。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter5/Figures/figure-different-translation-result-in-different-score-ibm1}
\caption{不同的译文导致不同IBM模型1得分的情况}
\label{fig:5-20}
\input{./Chapter6/Figures/figure-zh-en-bilingual-sentence-pairs}
\caption{汉译英句对及词对齐}
\label{fig:6-3}
\end{figure}
%----------------------------------------------
\parinterval 因此,IBM模型2抛弃了对$\textrm{P}(a_j|a_1^{j-1},s_1^{j-1},m,\mathbf{t})$服从均匀分布的假设。IBM模型2认为词对齐是有倾向性的,它要与源语单词的位置和目标语单词的位置有关。具体来说,对齐位置$a_j$的生成概率与位置$j$、源语句子长度$m$和译文长度$l$有关,形式化表述为:
\parinterval IBM模型2的其他假设均与模型1相同,即源语言长度预测概率及源语言单词生成概率被定义为:
\begin{eqnarray}
\textrm{P}(a_j|a_1^{j-1},s_1^{j-1},m,\mathbf{t}) \equiv a(a_j|j,m,l)
\label{eq:5-25}
\funp{P}(m|\vectorn{t}) & \equiv & \varepsilon \label{eq:s-len-gen-prob} \\
\funp{P}(s_j|a_1^{j},s_1^{j-1},m,\vectorn{t}) & \equiv & f(s_j|t_{a_j})
\label{eq:s-word-gen-prob}
\end{eqnarray}
\parinterval 这里还用图\ref{fig:5-18}中的例子来进行说明。在模型1中,``桌子''对齐到译文四个位置上的单词的概率是一样的。但在模型2中,``桌子''对齐到``table''被形式化为$a(a_j |j,m,l)=a(3|2,3,3)$,意思是对于源文位置2($j=2$)的词,如果它的源语言和译文都是3个词($l=3,m=3$),对齐到目标语译文位置3($a_j=3$)的概率是多少?因为$a(a_j|j,m,l)$也是模型需要学习的参数,因此``桌子''对齐到不同目标语单词的概率也是不一样的。理想的情况下,通过$a(a_j|j,m,l)$,``桌子''对齐到``table''应该得到更高的概率。
\parinterval IBM模型2的其他假设均与模型1相同。把公式\ref{eq:5-20}\ref{eq:5-22}\ref{eq:5-25}重新带入公式\ref{eq:5-18}\ref{eq:5-17},可以得到IBM模型2的数学描述:
把公式\ref{eq:s-len-gen-prob}\ref{eq:s-word-gen-prob}\ref{eq:6-1} 重新带入公式$\funp{P}(\vectorn{s},\vectorn{a}|\vectorn{t})=\funp{P}(m|\vectorn{t})\prod_{j=1}^{m}{\funp{P}(a_j|a_1^{j-1},s_1^{j-1},m,\vectorn{t})}$\\${\funp{P}(s_j|a_1^{j},s_1^{j-1},m,\vectorn{t})}$$\funp{P}(\vectorn{s}|\vectorn{t})= \sum_{\vectorn{a}}\funp{P}(\vectorn{s},\vectorn{a}|\vectorn{t})$,可以得到IBM模型2的数学描述:
\begin{eqnarray}
\textrm{P}(\mathbf{s}| \mathbf{t}) & = & \sum_{\mathbf{a}}{\textrm{P}(\mathbf{s},\mathbf{a}| \mathbf{t})} \nonumber \\
\funp{P}(\vectorn{s}| \vectorn{t}) & = & \sum_{\vectorn{a}}{\funp{P}(\vectorn{s},\vectorn{a}| \vectorn{t})} \nonumber \\
& = & \sum_{a_1=0}^{l}{\cdots}\sum _{a_m=0}^{l}{\varepsilon}\prod_{j=1}^{m}{a(a_j|j,m,l)f(s_j|t_{a_j})}
\label{eq:5-26}
\label{eq:6-4}
\end{eqnarray}
\parinterval 类似于模型1,模型2的表达式\ref{eq:5-26}也能被拆分为两部分进行理解。第一部分:遍历所有的$\mathbf{a}$;第二部分:对于每个$\mathbf{a}$累加对齐概率$\textrm{P}(\mathbf{s},\mathbf{a}| \mathbf{t})$,即计算对齐概率$a(a_j|j,m,l)$和词汇翻译概率$f(s_j|t_{a_j})$对于所有源语言位置的乘积。
\parinterval 类似于模型1,模型2的表达式\ref{eq:6-4}也能被拆分为两部分进行理解。第一部分:遍历所有的$\vectorn{a}$;第二部分:对于每个$\vectorn{a}$累加对齐概率$\funp{P}(\vectorn{s},\vectorn{a}| \vectorn{t})$,即计算对齐概率$a(a_j|j,m,l)$和词汇翻译概率$f(s_j|t_{a_j})$对于所有源语言位置的乘积。
\parinterval 同样的,模型2的解码及训练优化和模型1的十分相似,在此不再赘述,详细推导过程可以参看\ref{decoding&computational-optimization}这一小节,这里给出IBM模型2的最终表达式:
\parinterval 同样的,模型2的解码及训练优化和模型1的十分相似,在此不再赘述,详细推导过程可以参看{\chapterfive}解码及计算优化部分。这里直接给出IBM模型2的最终表达式:
\begin{eqnarray}
\textrm{IBM模型2:\ \ \ \ }\textrm{P}(\mathbf{s}| \mathbf{t}) & = & \varepsilon \prod\limits_{j=1}^{m} \sum\limits_{i=0}^{l} a(i|j,m,l) f(s_j|t_i)
\label{eq:5-65}
\funp{P}(\vectorn{s}| \vectorn{t}) & = & \varepsilon \prod\limits_{j=1}^{m} \sum\limits_{i=0}^{l} a(i|j,m,l) f(s_j|t_i)
\label{eq:6-5}
\end{eqnarray}
......@@ -89,76 +119,41 @@
\subsection{隐马尔可夫模型}
\parinterval {\color{red}IBM模型可以得到双语句子间的词对齐,因此也有很多工作在这个模型的基础上对词对齐方法进行改进。其中一个比较有代表性的工作是基于隐马尔可夫模型的方法\cite{vogel1996hmm},它可以被看作是IBM 模型2的升级版本。
这部分重点说HMM在机器翻译和对齐中的应用}
\parinterval {\small\sffamily\bfseries{隐马尔可夫模型}}(Hidden Markov Model,HMM)是经典的机器学习模型,它在语音识别、自然语言处理等领域得到了非常广泛的应用。其本质是一个概率模型,用来描述一个含有隐含参数的马尔可夫过程,简单来说,是用来描述一个系统,它隐含状态的转移和可见状态的概率\footnote{https://zh.wikipedia.org/zh-hans/隐马尔可夫模型}
\parinterval 我们用一个简单的例子来对这些概念进行说明。假设有三枚质地不同的硬币A、B、C,这三个硬币抛出正面的概率分别为0.3、0.5、0.7。之后开始抛硬币,随机从三个硬币里挑一个,挑到每一个硬币的概率都是$1/3$。不停的重复上述过程,会得到一串硬币的正反序列,如:抛硬币6次,得到:正 正 反 反 正 反。
\parinterval 这个正反序列叫做可见状态链,由每个回合的可见状态构成。此外,HMM模型还有一串隐含状态链,在这里,隐含状态链就是所用硬币的序列,比如可能是:C B A B C A。同样的,HMM模型还会描述系统隐藏状态的转移概率,在本例子中,A的下一个状态是A、B、C的概率都是$1/3$。B、C的下一个状态是A、B、C的转移概率也同样是$1/3$。同样的,尽管可见状态链之间没有转移概率,但是隐含状态和可见状态之间存在着输出概率,即A、B、C抛出正面的输出概率为0.3、0.5、0.7。图\ref{fig:5-29}描述了这个例子所对应的的隐马尔可夫模型示意图。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter5/Figures/figure-example-hmm}
\caption{抛硬币的隐马尔可夫模型实例}
\label{fig:5-29}
\end{figure}
%----------------------------------------------
\parinterval 一般来说,HMM包含下面三个问题\cite{manning1999foundations}
\begin{itemize}
\vspace{0.5em}
\item 估计:即给定模型(硬币种类和转移概率),根据可见状态链(抛硬币的结果),计算在该模型下得到这个结果的概率,这个问题的解决需要用到前后向算法。
\vspace{0.5em}
\item 参数学习:即给定硬币种类(隐含状态数量),根据多个可见状态链(抛硬币的结果),估计模型的参数(转移概率),同IBM模型的参数训练一样,这个问题的求解需要用到EM算法。
\vspace{0.5em}
\item 解码问题:即给定模型(硬币种类和转移概率)和可见状态链(抛硬币的结果),计算在可见状态链的情况下,最可能出现的对应的状态序列,这个问题的求解需要用到基于动态规划方法,在HMM中被称作维特比算法(Viterbi Algorithm)。
\vspace{0.5em}
\end{itemize}
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{词对齐模型}
\parinterval IBM模型把翻译问题定义为对译文和词对齐同时进行生成的问题,模型翻译质量的好坏与词对齐有着非常紧密的联系。IBM模型1假设对齐概率仅依赖于译文长度,即对齐概率服从均匀分布;IBM模型2假设对齐概率与源语言、目标语言的句子长度以及源语言位置和目标语言位置相关。IBM模型2已经覆盖到了大部分的词对齐问题,但是该模型只考虑到了词语的绝对位置,并未考虑到相邻词语间的关系。图\ref{fig:5-30}展示了一个简单的实例,可以看到的是,汉语的每个词都被分配给了英语句子中的每一个单词,但是词语并不是任意分布在各个位置上的,而是倾向于生成簇。也就是说,如果源语言的两个词位置越近,它们的目标词在目标语言句子的位置也越近。
\parinterval IBM模型把翻译问题定义为生成词对齐的问题,模型翻译质量的好坏与词对齐有着非常紧密的联系。IBM模型1假设对齐概率仅依赖于目标语言句子长度,即对齐概率服从均匀分布;IBM模型2假设对齐概率与源语言、目标语言的句子长度以及源语言位置和目标语言位置相关。虽然IBM模型2已经覆盖了一部分词对齐问题,但是该模型只考虑到了单词的绝对位置,并未考虑到相邻单词间的关系。图\ref{fig:6-4} 展示了一个简单的实例,可以看到的是,汉语的每个单词都被分配给了英语句子中的每一个单词,但是单词并不是任意分布在各个位置上的,而是倾向于生成簇。也就是说,如果源语言的两个单词位置越近,它们的译文在目标语言句子中的位置也越近。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter5/Figures/figure-zh-en-sentence-alignment}
\input{./Chapter6/Figures/figure-zh-en-sentence-alignment}
\caption{汉译英句对及对齐}
\label{fig:5-30}
\label{fig:6-4}
\end{figure}
%----------------------------------------------
\parinterval 因此,基于HMM的词对齐模型抛弃了IBM模型1-2的绝对位置假设,将一阶隐马尔可夫模型用于单词对齐问题。HMM词对齐模型认为,词语与词语之间并不是毫无联系的,对齐概率应该取决于对齐位置的差异而不是本身词语所在的位置。具体来说,位置$j$的对齐概率$a_j$与前一个位置$j-1$的对齐位置$a_{j-1}$和译文长度$l$有关,形式化的表述为:
\parinterval 针对此问题,基于HMM的词对齐模型抛弃了IBM模型1-2的绝对位置假设,将一阶隐马尔可夫模型用于词对齐问题\upcite{vogel1996hmm}。HMM词对齐模型认为,单词与单词之间并不是毫无联系的,对齐概率应该取决于对齐位置的差异而不是本身单词所在的位置。具体来说,位置$j$的对齐概率$a_j$与前一个位置$j-1$的对齐位置$a_{j-1}$和译文长度$l$有关,形式化的表述为:
\begin{eqnarray}
\textrm{P}(a_{j}|a_{1}^{j-1},s_{1}^{j-1},m,\mathbf{t})=\textrm{P}(a_{j}|a_{j-1},l)
\label{eq:5-49}
\funp{P}(a_{j}|a_{1}^{j-1},s_{1}^{j-1},m,\vectorn{t})\equiv\funp{P}(a_{j}|a_{j-1},l)
\label{eq:6-6}
\end{eqnarray}
\parinterval 这里用图\ref{fig:5-30}的例子对公式进行说明。在IBM模型1-2中,词语的对齐都是与单词所在的绝对位置有关。但在HMM词对齐模型中,``你''对齐到``you''被形式化为$\textrm{P}(a_{j}|a_{j-1},l)= P(5|4,5)$,意思是对于源文位置$3(j=3)$的词,如果它的目标译文是5个词,上一个对齐位置是$4(a_{2}=4)$,对齐到目标语译文位置$5(a_{j}=5)$的概率是多少?理想的情况下,通过$\textrm{P}(a_{j}|a_{j-1},l)$,``你''对齐到``you''应该得到更高的概率,并且由于源语词``对''和``你''距离很近,因此其对应的对齐位置``with''和``you''的距离也应该很近。
\parinterval 这里用图\ref{fig:6-4}的例子对公式进行说明。在IBM模型1-2中,单词的对齐都是与单词所在的绝对位置有关。但在HMM词对齐模型中,``你''对齐到``you''被形式化为$\funp{P}(a_{j}|a_{j-1},l)= P(5|4,5)$,意思是对于源语言位置$3(j=3)$上的单词,如果它的译文是第5个目标语言单词,上一个对齐位置是$4(a_{2}=4)$,对齐到目标语言位置$5(a_{j}=5)$的概率是多少?理想的情况下,通过$\funp{P}(a_{j}|a_{j-1},l)$,``你''对齐到``you''应该得到更高的概率,并且由于源语言单词``对''和``你''距离很近,因此其对应的对齐位置``with''和``you''的距离也应该很近。
\parinterval 因此,把公式\ref{eq:5-22}\ref{eq:5-49}重新带入公式\ref{eq:5-18}\ref{eq:5-17},可得HMM词对齐模型的数学描述:
\parinterval 把公式$\funp{P}(s_j|a_1^{j},s_1^{j-1},m,\vectorn{t}) \equiv f(s_j|t_{a_j})$\ref{eq:6-6}重新带入公式$\funp{P}(\vectorn{s},\vectorn{a}|\vectorn{t})=\funp{P}(m|\vectorn{t})$\\$\prod_{j=1}^{m}{\funp{P}(a_j|a_1^{j-1},s_1^{j-1},m,\vectorn{t})\funp{P}(s_j|a_1^{j},s_1^{j-1},m,\vectorn{t})}$$\funp{P}(\vectorn{s}|\vectorn{t})= \sum_{\vectorn{a}}\funp{P}(\vectorn{s},\vectorn{a}|\vectorn{t})$,可得HMM词对齐模型的数学描述:
\begin{eqnarray}
\textrm{P}(\mathbf{s}| \mathbf{t})=\sum_{\mathbf{a}}{\textrm{P}(m|\mathbf{t})}\prod_{j=1}^{m}{\textrm{P}(a_{j}|a_{j-1},l)f(s_{j}|t_{a_j})}
\label{eq:5-50}
\funp{P}(\vectorn{s}| \vectorn{t})=\sum_{\vectorn{a}}{\funp{P}(m|\vectorn{t})}\prod_{j=1}^{m}{\funp{P}(a_{j}|a_{j-1},l)f(s_{j}|t_{a_j})}
\label{eq:6-7}
\end{eqnarray}
\parinterval 此外,为了使得HMM的对齐概率$\textrm{P}(a_{j}|a_{j-1},l)$满足归一化的条件,这里还假设其对齐概率只取决于$a_{j}-a_{j-1}$,即:
\parinterval 此外,为了使得HMM的对齐概率$\funp{P}(a_{j}|a_{j-1},l)$满足归一化的条件,这里还假设其对齐概率只取决于$a_{j}-a_{j-1}$,即:
\begin{eqnarray}
\textrm{P}(a_{j}|a_{j-1},l)=\frac{\mu(a_{j}-a_{j-1})}{\sum_{i=1}^{l}{\mu(i-a_{j-1})}}
\label{eq:5-51}
\funp{P}(a_{j}|a_{j-1},l)=\frac{\mu(a_{j}-a_{j-1})}{\sum_{i=1}^{l}{\mu(i-a_{j-1})}}
\label{eq:6-8}
\end{eqnarray}
\noindent 其中,$\mu( \cdot )$是隐马尔可夫模型的参数,可以通过训练得到。
\parinterval 需要注意的是,公式\ref{eq:6-7}之所以被看作是一种隐马尔可夫模型,是由于其形式与标准的一阶隐马尔可夫模型无异。$\funp{P}(a_{j}|a_{j-1},l)$可以被看作是一种状态转移概率,$f(s_{j}|t_{a_j})$可以被看作是一种发射概率。关于隐马尔可夫模型具体的数学描述也可参考{\chapterthree}中的相关内容。
%----------------------------------------------------------------------------------------
......@@ -168,62 +163,85 @@
\sectionnewpage
\section{基于繁衍率的翻译模型}
下面介绍翻译中的一对多问题,以及这个问题所带来的句子长度预测问题。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
%----------------------------------------------------------------------------------------
\subsection{什么是繁衍率}
{\color{red}{扣后面非自回归解码的问题,SMT和NMT中都有应用。从另一个角度说,繁衍率也是对翻译长度的一种建模,它本质在描述:一个词(或序列)翻译到另一种语言有多长?因此,在需要对翻译长度建模的问题中,繁衍率都可以被使用}}
\parinterval 从前面的介绍可知,IBM模型1和模型2把不同的源语言单词看作相互独立的单元来进行词对齐和翻译。换句话说,即使某个源语言短语中的两个单词都对齐到同一个目标语单词,它们之间也是相互独立的。这样模型1和模型2对于多个源语言单词对齐到同一个目标语单词的情况并不能很好地进行描述。
\parinterval 从前面的介绍可知,IBM模型1和模型2把不同的源语言单词看作相互独立的单元来进行词对齐和翻译。换句话说,即使某个源语言短语中的两个单词都对齐到同一个目标语单词,它们之间也是相互独立的。这样IBM模型1和模型2对于多个源语言单词对齐到同一个目标语单词的情况并不能很好地进行描述。
\parinterval 这里将会给出另一个翻译模型,能在一定程度上解决上面提到的问题\upcite{Peter1993The,och2003systematic}。该模型把目标语言生成源语言的过程分解为如下几个步骤:首先,确定每个目标语言单词生成源语言单词的个数,这里把它称为{\small\sffamily\bfseries{繁衍率}}\index{繁衍率}{\small\sffamily\bfseries{产出率}}\index{产出率}(Fertility)\index{Fertility};其次,决定目标语言句子中每个单词生成的源语言单词都是什么,即决定生成的第一个源语言单词是什么,生成的第二个源语言单词是什么,以此类推。这样每个目标语言单词就对应了一个源语言单词列表;最后把各组源语言单词列表中的每个单词都放置到合适的位置上,完成目标语言译文到源语言句子的生成。
\parinterval 这里将会给出另一个翻译模型,能在一定程度上解决上面提到的问题。该模型把译文生成源文的过程分解为如下几个步骤:首先,确定每个目标语言单词生成源语言单词的个数,这里把它称为{\small\sffamily\bfseries{产出率}}\index{繁衍率}{\small\sffamily\bfseries{产出率}}\index{产出率}(Fertility)\index{Fertility};其次,决定译文中每个单词生成的源语言单词都是什么,即决定生成的第一个源语言单词是什么,生成的第二个源语言单词是什么,以此类推。这样每个目标语单词就对应了一个源语言单词列表;最后把各组源语言单词列表中的每个单词都放置到合适的位置上,完成目标语言译文到源语言句子的生成
\parinterval 对于句对$(\vectorn{s},\vectorn{t})$,令$\varphi$表示产出率,同时令${\tau}$表示每个目标语言单词对应的源语言单词列表。图{\ref{fig:6-5}}描述了一个英语句子生成汉语句子的过程
\parinterval 对于句对$(\mathbf{s},\mathbf{t})$,令$\varphi$表示产出率,同时令${\tau}$表示每个目标语单词对应的源语言单词列表。图{\ref{fig:6-1}}描述了一个英文句子生成中文句子的过程。首先,对于每个英语单词$t_i$决定它的产出率$\varphi_{i}$。比如``Scientists''的产出率是2,可表示为${\varphi}_{1}=2$。这表明它会生成2个中文单词;其次,确定英文句子中每个单词生成的中文单词列表。比如``Scientists''生成``科学家''和``们''两个中文单词,可表示为${\tau}_1=\{{\tau}_{11}=\textrm{``科学家''},{\tau}_{12}=\textrm{``们''}$。这里用特殊的空标记NULL表示翻译对空的情况;最后,把生成的所有中文单词放在合适的位置。比如``科学家''和``们''分别放在$\mathbf{s}$的位置1和位置2。可以用符号$\pi$记录生成的单词在源语言句子$\mathbf{s}$中的位置。比如``Scientists''生成的中文单词在$\mathbf{s}$ 中的位置表示为${\pi}_{1}=\{{\pi}_{11}=1,{\pi}_{12}=2\}$
\begin{itemize}
\vspace{0.3em}
\item 首先,对于每个英语单词$t_i$决定它的产出率$\varphi_{i}$。比如``Scientists''的产出率是2,可表示为${\varphi}_{1}=2$。这表明它会生成2个汉语单词;
\vspace{0.3em}
\item 其次,确定英语句子中每个单词生成的汉语单词列表。比如``Scientists''生成``科学家''和``们''两个汉语单词,可表示为${\tau}_1=\{{\tau}_{11}=\textrm{``科学家''},{\tau}_{12}=\textrm{``们''}\}$。 这里用特殊的空标记NULL表示翻译对空的情况;
\vspace{0.3em}
\item 最后,把生成的所有汉语单词放在合适的位置。比如``科学家''和``们''分别放在$\vectorn{s}$的位置1和位置2。可以用符号$\pi$记录生成的单词在源语言句子$\vectorn{s}$中的位置。比如``Scientists'' 生成的汉语单词在$\vectorn{s}$ 中的位置表示为${\pi}_{1}=\{{\pi}_{11}=1,{\pi}_{12}=2\}$
\vspace{0.3em}
\end{itemize}
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter6/Figures/figure-probability-translation-process}
\caption{基于产出率的翻译模型执行过程}
\label{fig:6-1}
\label{fig:6-5}
\end{figure}
%----------------------------------------------
\parinterval 为了表述清晰,这里重新说明每个符号的含义。$\mathbf{s}$$\mathbf{t}$$m$$l$分别表示源语言句子、目标语译文、源语言单词数量以及译文单词数量。$\mathbf{\varphi}$$\mathbf{\tau}$$\mathbf{\pi}$分别记录产出率、生成的源语言单词以及它们在源文中的位置。${\varphi}_{i}$表示第$i$个译文单词$t_i$的产出率。${\tau}_{i}$${\pi}_i$分别表示$t_i$生成的源语言单词列表及其在源语言句子$\mathbf{s}$中的位置列表。
\parinterval 为了表述清晰,这里重新说明每个符号的含义。$\vectorn{s}$$\vectorn{t}$$m$$l$分别表示源语言句子、目标语言译文、源语言单词数量以及译文单词数量。$\vectorn{\varphi}$$\vectorn{\tau}$$\vectorn{\pi}$分别表示产出率、生成的源语言单词以及它们在源语言句子中的位置。${\varphi}_{i}$表示第$i$个目标语言单词$t_i$的产出率。${\tau}_{i}$${\pi}_i$ 分别表示$t_i$生成的源语言单词列表及其在源语言句子$\vectorn{s}$中的位置列表。
\parinterval 可以看出,一组$\tau$$\pi$(记为$<\tau,\pi>$)可以决定一个对齐$\mathbf{a}$和一个源语句子$\mathbf{s}$
\parinterval 可以看出,一组$\tau$$\pi$(记为$<\tau,\pi>$)可以决定一个对齐$\vectorn{a}$和一个源语句子$\vectorn{s}$
\noindent 相反的,一个对齐$\mathbf{a}$和一个源语句子$\mathbf{s}$可以对应多组$<\tau,\pi>$。如图\ref{fig:6-2}所示,不同的$<\tau,\pi>$对应同一个源语言句子和词对齐。它们的区别在于目标语单词``Scientists''生成的源语言单词``科学家''和``们''的顺序不同。这里把不同的$<\tau,\pi>$对应到的相同的源语句子$\mathbf{s}$和对齐$\mathbf{a}$记为$<\mathbf{s},\mathbf{a}>$。因此计算$\textrm{P}(\mathbf{s},\mathbf{a}| \mathbf{t})$时需要把每个可能结果的概率加起来,如下:
\noindent 相反的,一个对齐$\vectorn{a}$和一个源语句子$\vectorn{s}$可以对应多组$<\tau,\pi>$。如图\ref{fig:6-6}所示,不同的$<\tau,\pi>$对应同一个源语言句子和词对齐。它们的区别在于目标语单词``Scientists''生成的源语言单词``科学家''和`` 们''的顺序不同。这里把不同的$<\tau,\pi>$对应到的相同的源语句子$\vectorn{s}$和对齐$\vectorn{a}$记为$<\vectorn{s},\vectorn{a}>$。因此计算$\funp{P}(\vectorn{s},\vectorn{a}| \vectorn{t})$时需要把每个可能结果的概率加起来,如下:
\begin{equation}
\textrm{P}(\mathbf{s},\mathbf{a}| \mathbf{t})=\sum_{{<\tau,\pi>}\in{<\mathbf{s},\mathbf{a}>}}{\textrm{P}(\tau,\pi|\mathbf{t}) }
\label{eq:6-1}
\funp{P}(\vectorn{s},\vectorn{a}| \vectorn{t})=\sum_{{<\tau,\pi>}\in{<\vectorn{s},\vectorn{a}>}}{\funp{P}(\tau,\pi|\vectorn{t}) }
\label{eq:6-9}
\end{equation}
\parinterval 不过$<\mathbf{s},\mathbf{a}>$中有多少个元素呢?通过图\ref{fig:6-1}中的例子,可以推出$<\mathbf{s},\mathbf{a}>$应该包含$\prod_{i=0}^{l}{\varphi_i !}$个不同的二元组$<\tau,\pi>$。 这是因为在给定源语言句子和词对齐时,对于每一个$\tau_i$都有$\varphi_{i}!$种排列。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter6/Figures/figure-example-of-t-s-generate}
\caption{不同$\tau$$\pi$对应相同的源语言句子和词对齐的情况}
\label{fig:6-2}
\label{fig:6-6}
\end{figure}
%----------------------------------------------
\parinterval 进一步,$\textrm{P}(\tau,\pi|\mathbf{t})$可以被表示如图\ref{fig:6-3}的形式。其中$\tau_{i1}^{k-1}$表示$\tau_{i1}\tau_{i2}\cdots \tau_{i(k-1)}$$\pi_{i1}^{ k-1}$表示$\pi_{i1}\pi_{i2}\cdots \pi_{i(k-1)}$。可以把图\ref{fig:6-3}中的公式分为5个部分,并用不同的序号和颜色进行标注。每部分的具体含义是:
\parinterval 不过$<\vectorn{s},\vectorn{a}>$中有多少组$<\tau,\pi>$呢?通过图\ref{fig:6-5}中的例子,可以推出$<\vectorn{s},\vectorn{a}>$应该包含$\prod_{i=0}^{l}{\varphi_i !}$个不同的二元组$<\tau,\pi>$。 这是因为在给定源语言句子和词对齐时,对于每一个$\tau_i$都有$\varphi_{i}!$种排列。
\parinterval 进一步,$\funp{P}(\tau,\pi|\vectorn{t})$可以被表示如图\ref{fig:6-7}的形式。其中$\tau_{i1}^{k-1}$表示$\tau_{i1}\tau_{i2}\cdots \tau_{i(k-1)}$$\pi_{i1}^{ k-1}$表示$\pi_{i1}\pi_{i2}\cdots \pi_{i(k-1)}$。可以把图\ref{fig:6-7}中的公式分为5个部分,并用不同的序号和颜色进行标注。每部分的具体含义是:
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter6/Figures/figure-expression}
\caption{{$\funp{P}(\tau,\pi|t)$}的详细表达式}
\setlength{\belowcaptionskip}{-0.5em}
\label{fig:6-7}
\end{figure}
%----------------------------------------------
\begin{itemize}
\vspace{0.5em}
\item 对每个$i\in[1,l]$的目标语单词的产出率建模({\color{red!70} 红色}),即$\varphi_i$的概率。它依赖于$\mathbf{t}$和区间$[1,i-1]$的目标语单词的产出率$\varphi_1^{i-1}$\footnote{这里约定,当$i=1$ 时,$\varphi_1^0$ 表示空。}
\item 第一部分:每个$i\in[1,l]$的目标语单词的产出率建模({\color{red!70} 红色}),即$\varphi_i$的生成概率。它依赖于$\vectorn{t}$和区间$[1,i-1]$的目标语单词的产出率$\varphi_1^{i-1}$\footnote{这里约定,当$i=1$ 时,$\varphi_1^0$ 表示空。}
\vspace{0.5em}
\item $i=0$时的产出率建模({\color{blue!70} 蓝色}),即空标记$t_0$的产出率的概率。它依赖于$\mathbf{t}$和区间$[1,i-1]$的目标语单词的产出率$\varphi_1^l$
\item 第二部分:$i=0$时的产出率建模({\color{blue!70} 蓝色}),即空标记$t_0$的产出率生成概率。它依赖于$\vectorn{t}$和区间$[1,i-1]$的目标语单词的产出率$\varphi_1^l$
\vspace{0.5em}
\item 词汇翻译建模({\color{green!70} 绿色}),目标语言单词$t_i$生成第$k$个源语言单词$\tau_{ik}$时的概率,依赖于$\mathbf{t}$、所有目标语言单词的产出率$\varphi_0^l$、区间$i\in[1,l]$的目标语言单词生成的源语言单词$\tau_1^{i-1}$和目标语单词$t_i$生成的前$k$个源语言单词$\tau_{i1}^{k-1}$
\item 第三部分:词汇翻译建模({\color{green!70} 绿色}),目标语言单词$t_i$生成第$k$个源语言单词$\tau_{ik}$时的概率,依赖于$\vectorn{t}$、所有目标语言单词的产出率$\varphi_0^l$、区间$i\in[1,l]$的目标语言单词生成的源语言单词$\tau_1^{i-1}$和目标语单词$t_i$生成的前$k$个源语言单词$\tau_{i1}^{k-1}$
\vspace{0.5em}
\item 对于每个$i\in[1,l]$的目标语言单词生成的源语言单词的{\small\bfnew{扭曲度}}\index{扭曲度}(Distortion)\index{Distortion}建模({\color{yellow!70!black} 黄色}),即第$i$个译文单词生成的第$k$个源语言单词在源文中的位置$\pi_{ik}$ 的概率。其中$\pi_1^{i-1}$$\pi_{i1}^{k-1}$分别表示区间$[1,i-1]$的目标语言单词生成的源语言单词的扭曲度和第$i$译文单词生成的前$k$个源语言单词的扭曲度。
\item 第四部分:对于每个$i\in[1,l]$的目标语言单词生成的源语言单词的扭曲度建模({\color{yellow!70!black} 黄色}),即第$i$个目标语言单词生成的第$k$个源语言单词在源文中的位置$\pi_{ik}$ 的概率。其中$\pi_1^{i-1}$ 表示区间$[1,i-1]$的目标语言单词生成的源语言单词的扭曲度,$\pi_{i1}^{k-1}$表示第$i$目标语言单词生成的前$k-1$个源语言单词的扭曲度。
\vspace{0.5em}
\item $i=0$时的扭曲度建模({\color{gray!70} 灰色}),即空标记$t_0$生成的源语言单词在源语言句子中位置的概率。
\item 第五部分:$i=0$时的扭曲度建模({\color{gray!70} 灰色}),即空标记$t_0$生成源语言位置的概率。
\end{itemize}
%----------------------------------------------------------------------------------------
......@@ -232,62 +250,65 @@
\subsection{IBM 模型3}
\parinterval IBM模型3通过一些假设对图\ref{fig:6-3}所表示的基本模型进行了化简。具体来说,对于每个$i\in[1,l]$,假设$\textrm{P}(\varphi_i |\varphi_1^{i-1},\mathbf{t})$仅依赖于$\varphi_i$$t_i$$\textrm{P}(\pi_{ik}|\pi_{i1}^{k-1},\pi_1^{i-1},\tau_0^l,\varphi_0^l,\mathbf{t})$仅依赖于$\pi_{ik}$$i$$m$$l$。而对于所有的$i\in[0,l]$,假设$\textrm{P}(\tau_{ik}|\tau_{i1}^{k-1},\tau_1^{i-1},\phi_0^l,\mathbf{t})$仅依赖于$\tau_{ik}$$t_i$。形式化这些假设,可以得到:
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter6/Figures/figure-expression}
\caption{{$\textrm{P}(\tau,\pi|t)$}的详细表达式}
\setlength{\belowcaptionskip}{-0.5em}
\label{fig:6-3}
\end{figure}
%----------------------------------------------
\parinterval IBM模型3通过一些假设对图\ref{fig:6-7}所表示的基本模型进行了化简。具体来说,对于每个$i\in[1,l]$,假设$\funp{P}(\varphi_i |\varphi_1^{i-1},\vectorn{t})$仅依赖于$\varphi_i$$t_i$$\funp{P}(\pi_{ik}|\pi_{i1}^{k-1},\pi_1^{i-1},\tau_0^l,\varphi_0^l,\vectorn{t})$仅依赖于$\pi_{ik}$$i$$m$$l$。而对于所有的$i\in[0,l]$,假设$\funp{P}(\tau_{ik}|\tau_{i1}^{k-1},\tau_1^{i-1},\varphi_0^l,\vectorn{t})$仅依赖于$\tau_{ik}$$t_i$。这些假设的形式化描述为:
\begin{eqnarray}
\textrm{P}(\varphi_i|\varphi_1^{i-1},\mathbf{t}) & = &{\textrm{P}(\varphi_i|t_i)} \label{eq:6-2} \\
\textrm{P}(\tau_{ik} = s_j |\tau_{i1}^{k-1},\tau_{1}^{i-1},\varphi_0^t,\mathbf{t}) & = & t(s_j|t_i) \label{eq:6-3} \\
\textrm{P}(\pi_{ik} = j |\pi_{i1}^{k-1},\pi_{1}^{i-1},\tau_{0}^{l},\varphi_{0}^{l},\mathbf{t}) & = & d(j|i,m,l) \label{eq:6-4}
%\label{eq:3-49}
\funp{P}(\varphi_i|\varphi_1^{i-1},\vectorn{t}) & = &{\funp{P}(\varphi_i|t_i)} \label{eq:6-10} \\
\funp{P}(\tau_{ik} = s_j |\tau_{i1}^{k-1},\tau_{1}^{i-1},\varphi_0^t,\vectorn{t}) & = & t(s_j|t_i) \label{eq:6-11} \\
\funp{P}(\pi_{ik} = j |\pi_{i1}^{k-1},\pi_{1}^{i-1},\tau_{0}^{l},\varphi_{0}^{l},\vectorn{t}) & = & d(j|i,m,l) \label{eq:6-12}
\end{eqnarray}
\parinterval 通常把$d(j|i,m,l)$称为扭曲度函数。这里$\textrm{P}(\varphi_i|\varphi_1^{i-1},\mathbf{t})={\textrm{P}(\varphi_i|t_i)}$${\textrm{P}(\pi_{ik}=j|\pi_{i1}^{k-1},}$ $\pi_{1}^{i-1},\tau_0^l,\varphi_0^l,\mathbf{t})=d(j|i,m,l)$仅对$1 \le i \le l$成立。这样就完成了图\ref{fig:6-3}中第1、 3和4部分的建模。
\parinterval 通常把$d(j|i,m,l)$称为扭曲度函数。这里$\funp{P}(\varphi_i|\varphi_1^{i-1},\vectorn{t})={\funp{P}(\varphi_i|t_i)}$${\funp{P}(\pi_{ik}=j|\pi_{i1}^{k-1},}$ $\pi_{1}^{i-1},\tau_0^l,\varphi_0^l,\vectorn{t})=d(j|i,m,l)$仅对$1 \le i \le l$成立。这样就完成了图\ref{fig:6-7}中第1、 3和4部分的建模。
\parinterval 对于$i=0$的情况需要单独进行考虑。实际上,$t_0$只是一个虚拟的单词。它要对应$\vectorn{s}$中原本为空对齐的单词。这里假设:要等其他非空对应单词都被生成(放置)后,才考虑这些空对齐单词的生成(放置)。即非空对单词都被生成后,在那些还有空的位置上放置这些空对的源语言单词。此外,在任何的空位置上放置空对的源语言单词都是等概率的,即放置空对齐源语言单词服从均匀分布。这样在已经放置了$k$个空对齐源语言单词的时候,应该还有$\varphi_0-k$个空位置。如果第$j$个源语言位置为空,那么
\begin{equation}
\funp{P}(\pi_{0k}=j|\pi_{01}^{k-1},\pi_1^l,\tau_0^l,\varphi_0^l,\vectorn{t})=\frac{1}{\varphi_0-k}
\label{eq:6-13}
\end{equation}
否则
\begin{equation}
\funp{P}(\pi_{0k}=j|\pi_{01}^{k-1},\pi_1^l,\tau_0^l,\varphi_0^l,\vectorn{t})=0
\label{eq:6-14}
\end{equation}
\parinterval 对于$i=0$的情况需要单独进行考虑。实际上,$t_0$只是一个虚拟的单词。它要对应$\mathbf{s}$中原本为空对齐的单词。这里假设要等其他非空对应单词都被生成(放置)后,才考虑这些空对齐单词的生成(放置)。即非空对单词都被生成后,在那些还有空的位置上放置这些空对的源语单词。此外,在任何的空位置上放置空对的源语单词都是等概率的,即放置空对齐源语言单词服从均匀分布。这样在已经放置了$k$个空对齐源语言单词的时候,应该还有$\varphi_0-k$个空位置。如果第$i$个位置为空,那么$\textrm{P}(\pi_{0k}=i|\pi_{01}^{k-1},\pi_1^l,\tau_0^l,\varphi_0^l,\mathbf{t})=\frac{1}{\varphi_0-k}$,否则$\textrm{P}(\pi_{0k}=i|\pi_{01}^{k-1},\pi_1^l,\tau_0^l,\varphi_0^l,\mathbf{t})=0$这样对于$t_0$所对应的$\tau_0$,就有
这样对于$t_0$所对应的$\tau_0$,就有
{
\begin{eqnarray}
\prod_{k=1}^{\varphi_0}{\textrm{P}(\pi_{0k}|\pi_{01}^{k-1},\pi_{1}^{l},\tau_{0}^{l},\varphi_{0}^{l},\mathbf{t}) }=\frac{1}{\varphi_{0}!}
\label{eq:6-5}
\prod_{k=1}^{\varphi_0}{\funp{P}(\pi_{0k}|\pi_{01}^{k-1},\pi_{1}^{l},\tau_{0}^{l},\varphi_{0}^{l},\vectorn{t}) }=\frac{1}{\varphi_{0}!}
\label{eq:6-15}
\end{eqnarray}
}
\parinterval 而上面提到的$t_0$所对应的这些空位置是如何生成的呢?即如何确定哪些位置是要放置空对齐的源语言单词。在IBM模型3中,假设在所有的非空对齐源语言单词都被生成出来后(共$\varphi_1+\varphi_2+\cdots {\varphi}_l$个非空对源语单词),这些单词后面都以$p_1$概率随机地产生一个``槽''用来放置空对齐单词。这样,${\varphi}_0$就服从了一个二项分布。于是得到
{
\begin{eqnarray}
\textrm{P}(\varphi_0|\mathbf{t})=\big(\begin{array}{c}
\funp{P}(\varphi_0|\vectorn{t})=\big(\begin{array}{c}
\varphi_1+\varphi_2+\cdots \varphi_l\\
\varphi_0\\
\end{array}\big)p_0^{\varphi_1+\varphi_2+\cdots \varphi_l-\varphi_0}p_1^{\varphi_0}
\label{eq:6-6}
\label{eq:6-16}
\end{eqnarray}
}
\noindent 其中,$p_0+p_1=1$。到此为止,我们完成了图\ref{fig:6-3}中第2和5部分的建模。最终根据这些假设可以得到$\textrm{P}(\mathbf{s}| \mathbf{t})$的形式
\noindent 其中,$p_0+p_1=1$。到此为止,已经完成了图\ref{fig:6-7}中第2和5部分的建模。最终根据这些假设可以得到$\funp{P}(\vectorn{s}| \vectorn{t})$的形式为
{
\begin{eqnarray}
{\textrm{P}(\mathbf{s}| \mathbf{t})}&= &{\sum_{a_1=0}^{l}{\cdots}\sum_{a_m=0}^{l}{\Big[\big(\begin{array}{c}
{\funp{P}(\vectorn{s}| \vectorn{t})}&= &{\sum_{a_1=0}^{l}{\cdots}\sum_{a_m=0}^{l}{\Big[\big(\begin{array}{c}
m-\varphi_0\\
\varphi_0\\
\end{array}\big)}p_0^{m-2\varphi_0}p_1^{\varphi_0}\prod_{i=1}^{l}{{\varphi_i}!n(\varphi_i|t_i) }} \nonumber \\
& & \times{\prod_{j=1}^{m}{t(s_j|t_{a_j})} \times \prod_{j=1,a_j\neq 0}^{m}{d(j|a_j,m,l)}} \Big]
\label{eq:6-7}
\label{eq:6-17}
\end{eqnarray}
}
\noindent 其中,$n(\varphi_i |t_i)={\textrm{P}(\varphi_i|t_i)}$表示产出率的分布。这里的约束条件为,
\noindent 其中,$n(\varphi_i |t_i)={\funp{P}(\varphi_i|t_i)}$表示产出率的分布。这里的约束条件为,
{
\begin{eqnarray}
\sum_{s}t(s|t) & = &1 \label{eq:6-8} \\
\sum_{j}d(j|i,m,l) & = & 1 \label{eq:6-9} \\
\sum_{\varphi} n(\varphi|t) & = &1 \label{eq:6-10} \\
p_0+p_1 & = & 1 \label{eq:6-11}
\sum_{s_x}t(s_x|t_y) & = &1 \label{eq:6-18} \\
\sum_{j}d(j|i,m,l) & = & 1 \label{eq:6-19} \\
\sum_{\varphi} n(\varphi|t_y) & = &1 \label{eq:6-20} \\
p_0+p_1 & = & 1 \label{eq:6-21}
\end{eqnarray}
}
......@@ -299,34 +320,35 @@ p_0+p_1 & = & 1 \label{eq:6-11}
\parinterval IBM模型3仍然存在问题,比如,它不能很好地处理一个目标语言单词生成多个源语言单词的情况。这个问题在模型1和模型2中也存在。如果一个目标语言单词对应多个源语言单词,往往这些源语言单词构成短语或搭配。但是模型1-3把这些源语言单词看成独立的单元,而实际上它们是一个整体。这就造成了在模型1-3中这些源语言单词可能会``分散''开。为了解决这个问题,模型4对模型3进行了进一步修正。
\parinterval 为了更清楚的阐述,这里引入新的术语\ \dash \ {\small\bfnew{概念单元}}\index{概念单元}{\small\bfnew{概念}}\index{概念}(Concept)\index{Concept}。词对齐可以被看作概念之间的对应。这里的概念是指具有独立语法或语义功能的一组单词。依照Brown等人的表示方法\upcite{Peter1993The},可以把概念记为cept.。每个句子都可以被表示成一系列的cept.。这里要注意的是,源语言句子中的cept.数量不一定等于目标句子中的cept.数量。因为有些cept. 可以为空,因此可以把那些空对的单词看作空cept.。比如,在图\ref{fig:6-8}的实例中,``了''就对应一个空cept.。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter6/Figures/figure-word-alignment}
\caption{词对齐的汉译英句对及独立单词cept.的位置}
\label{fig:6-4}
\caption{词对齐的汉译英句对及独立单词cept.的位置(记为$[i]$}
\label{fig:6-8}
\end{figure}
%----------------------------------------------
\parinterval 为了更清楚的阐述,这里引入新的术语\ \dash \ {\small\bfnew{概念单元}}\index{概念单元}{\small\bfnew{概念}}\index{概念}(Concept)\index{Concept}。词对齐可以被看作概念之间的对应。这里的概念是指具有独立语法或语义功能的一组单词。依照Brown等人的表示方法\cite{Peter1993The},可以把概念记为cept.。每个句子都可以被表示成一系列的cept.。这里要注意的是,源语言句子中的cept.数量不一定等于目标句子中的cept.数量。因为有些cept. 可以为空,因此可以把那些空对的单词看作空cept.。比如,在图\ref{fig:6-4}的实例中,``了''就对应一个空cept.。
\parinterval 在IBM模型的词对齐框架下,目标语的cept.只能是那些非空对齐的目标语单词,而且每个cept.只能由一个目标语单词组成(通常把这类由一个单词组成的cept.称为独立单词cept.)。这里用$[i]$表示第$i$ 个独立单词cept.在目标语言句子中的位置。换句话说,$[i]$表示第$i$个非空对的目标语单词的位置。比如在本例中``mind''在$\mathbf{t}$中的位置表示为$[3]$
\parinterval 在IBM模型的词对齐框架下,目标语的cept.只能是那些非空对齐的目标语单词,而且每个cept.只能由一个目标语言单词组成(通常把这类由一个单词组成的cept.称为独立单词cept.)。这里用$[i]$表示第$i$ 个独立单词cept.在目标语言句子中的位置。换句话说,$[i]$表示第$i$个非空对的目标语单词的位置。比如在本例中``mind''在$\vectorn{t}$中的位置表示为$[3]$
\parinterval 另外,可以用$\odot_{i}$表示位置为$[i]$的目标语言单词对应的那些源语言单词位置的平均值,如果这个平均值不是整数则对它向上取整。比如在本例中,目标语句中第4个cept. (``.'')对应在源语言句子中的第5个输出值。可表示为${\odot}_{4}=5$
\parinterval 另外,可以用$\odot_{i}$表示位置为$[i]$的目标语言单词对应的那些源语言单词位置的平均值,如果这个平均值不是整数则对它向上取整。比如在本例中,目标语句中第4个cept. (``.'')对应在源语言句子中的第5个单词。可表示为${\odot}_{4}=5$
\parinterval 利用这些新引进的概念,模型4对模型3的扭曲度进行了修改。主要是把扭曲度分解为两类参数。对于$[i]$对应的源语言单词列表($\tau_{[i]}$)中的第一个单词($\tau_{[i]1}$),它的扭曲度用如下公式计算:
\begin{equation}
\textrm{P}(\pi_{[i]1}=j|{\pi}_1^{[i]-1},{\tau}_0^l,{\varphi}_0^l,\mathbf{t})=d_{1}(j-{\odot}_{i-1}|A(t_{[i-1]}),B(s_j))
\label{eq:6-12}
\funp{P}(\pi_{[i]1}=j|{\pi}_1^{[i]-1},{\tau}_0^l,{\varphi}_0^l,\vectorn{t})=d_{1}(j-{\odot}_{i-1}|A(t_{[i-1]}),B(s_j))
\label{eq:6-22}
\end{equation}
\noindent 其中,译文的第$i$个单词生成的第$k$个源语单词在源语言句子中的位置用变量$\pi_{ik}$表示。而对于列表($\tau_{[i]}$)中的其他的单词($\tau_{[i]k},1 < k \le \varphi[i]$)的扭曲度计算,进行如下计算
\noindent 其中,第$i$个目标语言单词生成的第$k$个源语言单词的位置用变量$\pi_{ik}$表示。而对于列表($\tau_{[i]}$)中的其他的单词($\tau_{[i]k},1 < k \le \varphi_{[i]}$)的扭曲度,用如下公式计算:
\begin{equation}
\textrm{P}(\pi_{[i]k}=j|{\pi}_{[i]1}^{k-1},\pi_1^{[i]-1},\tau_0^l,\varphi_0^l,\mathbf{t})=d_{>1}(j-\pi_{[i]k-1}|B(s_j))
\label{eq:6-13}
\funp{P}(\pi_{[i]k}=j|{\pi}_{[i]1}^{k-1},\pi_1^{[i]-1},\tau_0^l,\varphi_0^l,\vectorn{t})=d_{>1}(j-\pi_{[i]k-1}|B(s_j))
\label{eq:6-23}
\end{equation}
\parinterval 这里的函数$A(\cdot)$和函数$B(\cdot)$分别把目标语言和源语言的单词影射到单词的词类。这么做的目的一方面要减小参数空间的大小,另一方面是要减小数据的稀疏程度。词类信息通常可以通过外部工具得到,比如Brown聚类等。另一种简单的方法是把单词直接映射为它的词性。这样可以直接用现在已经非常成熟的词性标注工具解决问题。
\parinterval 这里的函数$A(\cdot)$和函数$B(\cdot)$分别把目标语言和源语言的单词影射到单词的词类。这么做的目的是要减小参数空间的大小。词类信息通常可以通过外部工具得到,比如Brown聚类等。另一种简单的方法是把单词直接映射为它的词性。这样可以直接用现在已经非常成熟的词性标注工具解决问题。
\parinterval 从上面改进的扭曲度模型可以看出,对于$t_{[i]}$生成的第一个源语言单词,要考虑中心$\odot_{[i]}$和这个源语言单词之间的绝对距离。实际上也就要把$t_{[i]}$生成的所有源语言单词看成一个整体并把它放置在合适的位置。这个过程要依据第一个源语言单词的词类和对应源语中心位置,和前一个非空对目标语言单词$t_{[i-1]}$的词类。而对于$t[i]$生成的其他源语言单词,只需要考虑它与前一个刚放置完的源语言单词的相对位置和这个源语言单词的词类。
......@@ -338,32 +360,32 @@ p_0+p_1 & = & 1 \label{eq:6-11}
\subsection{ IBM 模型5}
\parinterval 模型3和模型4并不是``准确''的模型。这两个模型会把一部分概率分配给一些根本就不存在的句子。这个问题被称作IBM模型3和模型4的{\small\bfnew{缺陷}}\index{缺陷}(Deficiency)\index{Deficiency}。说的具体一些,模型3和模型4 中并没有这样的约束:如果已经放置了某个源语言单词的位置不能再放置其他单词,也就是说句子的任何位置只能放置一个词,不能多也不能少。由于缺乏这个约束,模型3和模型4中在所有合法的词对齐上概率和不等于1。 这部分缺失的概率被分配到其他不合法的词对齐上。举例来说,如图\ref{fig:6-5}所示,``吃 早饭''和``have breakfast''之间的合法词对齐用直线表示 。但是在模型3和模型4中, 在它们上的概率和为$0.9<1$。 损失掉的概率被分配到像5和6这样的对齐上了(红色)。虽然IBM模型并不支持一对多的对齐,但是模型3和模型4把概率分配给这些``不合法''的词对齐上,因此也就产生所谓的Deficiency问题
\parinterval 模型3和模型4并不是``准确''的模型。这两个模型会把一部分概率分配给一些根本就不存在的句子。这个问题被称作IBM模型3和模型4的{\small\bfnew{缺陷}}\index{缺陷}(Deficiency)\index{Deficiency}。说的具体一些,模型3和模型4 中并没有这样的约束:如果已经放置了某个源语言单词的位置不能再放置其他单词,也就是说句子的任何位置只能放置一个词,不能多也不能少。由于缺乏这个约束,模型3和模型4中在所有合法的词对齐上概率和不等于1。 这部分缺失的概率被分配到其他不合法的词对齐上。举例来说,如图\ref{fig:6-9}所示,``吃/早饭''和``have breakfast''之间的合法词对齐用直线表示 。但是在模型3和模型4中, 它们的概率和为$0.9<1$。 损失掉的概率被分配到像5和6这样的对齐上了(红色)。虽然IBM模型并不支持一对多的对齐,但是模型3和模型4把概率分配给这些`` 不合法''的词对齐上,因此也就产生所谓的缺陷
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter6/Figures/figure-word-alignment&probability-distribution-in-ibm-model-3}
\caption{IBM模型3的词对齐及概率分配}
\label{fig:6-5}
\label{fig:6-9}
\end{figure}
%----------------------------------------------
\parinterval 为了解决这个问题,模型5在模型中增加了额外的约束。基本想法是,在放置一个源语言单词的时候检查这个位置是否已经放置了单词,如果可以则把这个放置过程赋予一定的概率,否则把它作为不可能事件。依据这个想法,就需要在逐个放置源语言单词的时候判断源语言句子的哪些位置为空。这里引入一个变量$v(j, {\tau_1}^{[i]-1}, \tau_{[i]1}^{k-1})$,它表示在放置$\tau_{[i]k}$之前($\tau_1^{[i]-1}$$\tau_{[i]1}^{k-1}$已经被放置完了),从源语言句子的第一个位置到位置$j$(包含$j$)为止还有多少个空位置。这里,把这个变量简写为$v_j$。于是,对于$[i]$所对应的源语言单词列表($\tau_{[i]}$)中的第一个单词($\tau_{[i]1}$),有:
\parinterval 为了解决这个问题,模型5在模型中增加了额外的约束。基本想法是,在放置一个源语言单词的时候检查这个位置是否已经放置了单词,如果可以则把这个放置过程赋予一定的概率,否则把它作为不可能事件。基于这个想法,就需要在逐个放置源语言单词的时候判断源语言句子的哪些位置为空。这里引入一个变量$v(j, {\tau_1}^{[i]-1}, \tau_{[i]1}^{k-1})$,它表示在放置$\tau_{[i]k}$之前($\tau_1^{[i]-1}$ $\tau_{[i]1}^{k-1}$已经被放置完了),从源语言句子的第一个位置到位置$j$(包含$j$)为止还有多少个空位置。这里,把这个变量简写为$v_j$。于是,对于$[i]$所对应的源语言单词列表($\tau_{[i]}$)中的第一个单词($\tau_{[i]1}$),有:
\begin{eqnarray}
\textrm{P}(\pi_{[i]1} = j | \pi_1^{[i]-1}, \tau_0^l, \varphi_0^l, \mathbf{t}) & = & d_1(v_j|B(s_j), v_{\odot_{i-1}}, v_m-(\varphi_{[i]}-1)) \cdot \nonumber \\
\funp{P}(\pi_{[i]1} = j | \pi_1^{[i]-1}, \tau_0^l, \varphi_0^l, \vectorn{t}) & = & d_1(v_j|B(s_j), v_{\odot_{i-1}}, v_m-(\varphi_{[i]}-1)) \cdot \nonumber \\
& & (1-\delta(v_j,v_{j-1}))
\label{eq:6-14}
\label{eq:6-24}
\end{eqnarray}
\parinterval 对于其他单词($\tau_{[i]k}$, $1 < k\le\varphi_{[i]}$),有:
\begin{eqnarray}
& & \textrm{P}(\pi_{[i]k}=j|\pi_{[i]1}^{k-1}, \pi_1^{[i]-1}, \tau_0^l, \varphi_0^l,\mathbf{t}) \nonumber \\
& & \funp{P}(\pi_{[i]k}=j|\pi_{[i]1}^{k-1}, \pi_1^{[i]-1}, \tau_0^l, \varphi_0^l,\vectorn{t}) \nonumber \\
&= & d_{>1}(v_j-v_{\pi_{[i]k-1}}|B(s_j), v_m-v_{\pi_{[i]k-1}}-\varphi_{[i]}+k) \cdot (1-\delta(v_j,v_{j-1}))
\label{eq:6-15}
\label{eq:6-25}
\end{eqnarray}
\noindent 这里,因子$1-\delta(v_i, v_{i-1})$是用来判断第$i$个位置是不是为空。如果第$i$个位置为空则$v_i = v_{i-1}$,这样$\textrm{P}(\pi_{[i]1}=i|\pi_1^{[i]-1}, \tau_0^l, \varphi_0^l, \mathbf{t}) = 0$。这样就从模型上避免了模型3和模型4中生成不存在的字符串的问题。这里还要注意的是,对于放置第一个单词的情况,影响放置的因素有$v_i$$B(s_i)$$v_{i-1}$。此外还要考虑在$i$位置放置了第一个单词以后它的右边是不是还有足够的位置留给剩下的$k-1$个单词。参数$v_m-(\varphi_{[i]}-1)$正是为了考虑这个因素,这里$v_m$表示整个源语言句子中还有多少空位置,$\varphi_{[i]}-1$表示$i$位置右边至少还要留出的空格数。对于放置非第一个单词的情况,主要是要考虑它和前一个放置位置的相对位置。这主要体现在参数$v_i-v_{\varphi_{[i]}k-1}$上。式\ref{eq:6-15}的其他部分都可以用上面的理论解释,这里不再赘述。
\noindent 这里,因子$1-\delta(v_j, v_{j-1})$是用来判断第$j$个位置是不是为空。如果第$j$个位置为空则$v_j = v_{j-1}$,这样$\funp{P}(\pi_{[i]1}=j|\pi_1^{[i]-1}, \tau_0^l, \varphi_0^l, \vectorn{t}) = 0$。这样就从模型上避免了模型3和模型4中生成不存在的字符串的问题。这里还要注意的是,对于放置第一个单词的情况,影响放置的因素有$v_j$$B(s_i)$$v_{j-1}$。此外还要考虑位置$j$放置了第一个源语言单词以后它的右边是不是还有足够的位置留给剩下的$k-1$个源语言单词。参数$v_m-(\varphi_{[i]}-1)$正是为了考虑这个因素,这里$v_m$表示整个源语言句子中还有多少空位置,$\varphi_{[i]}-1$ 表示源语言位置$j$右边至少还要留出的空格数。对于放置非第一个单词的情况,主要是要考虑它和前一个放置位置的相对位置。这主要体现在参数$v_j-v_{\varphi_{[i]}k-1}$上。式\ref{eq:6-25} 的其他部分都可以用上面的理论解释,这里不再赘述。
\parinterval 实际上,模型5和模型4的思想基本一致,即,先确定$\tau_{[i]1}$的绝对位置,然后再确定$\tau_{[i]}$中剩余单词的相对位置。模型5消除了产生不存在的句子的可能性,不过模型5的复杂性也大大增加了。
%----------------------------------------------------------------------------------------
......@@ -373,9 +395,9 @@ p_0+p_1 & = & 1 \label{eq:6-11}
\sectionnewpage
\section{解码和训练}
\parinterval 和IBM模型1-2一样,IBM模型3-5和隐马尔可夫模型的解码可以直接使用\ref{sec:sentence-level-translation}\\节所描述的方法。基本思路是对译文自左向右生成,每次扩展一个源语言单词的翻译,即把源语言单词的译文放到已经生成的译文的右侧。每次扩展可以选择不同的源语言单词或者同一个源语言单词的不同翻译候选,这样就可以得到多个不同的扩展译文。在这个过程中,同时计算翻译模型和语言模型的得分,对每个得到译文候选打分。最终,保留一个或者多个译文。这个过程重复执行直至所有源语言单词被翻译完。
\parinterval 与IBM模型1一样,IBM模型2-5和隐马尔可夫模型的解码可以直接使用{\chapterfive}所描述的方法。基本思路与{\chaptertwo}所描述的自左向右搜索方法一致,即:对译文自左向右生成,每次扩展一个源语言单词的翻译,即把源语言单词的译文放到已经生成的译文的右侧。每次扩展可以选择不同的源语言单词或者同一个源语言单词的不同翻译候选,这样就可以得到多个不同的扩展译文。在这个过程中,同时计算翻译模型和语言模型的得分,对每个得到译文候选打分。最终,保留一个或者多个译文。这个过程重复执行直至所有源语言单词被翻译完。
\parinterval 类似的,IBM模型3-5和隐马尔可夫模型也都可以使用期望最大化(EM)方法进行模型训练。相关数学推导可参考附录\ref{appendix-B}的内容。通常,可以使用这些模型获得双语句子间的词对齐结果,比如著名的GIZA++工具。这时,往往会使用多个模型,把简单的模型训练后的参数作为初始值送给后面更加复杂的模型。比如,先用IBM模型1训练,之后把参数送给IBM模型2,再训练,之后把参数送给隐马尔可夫模型等。值得注意的是,并不是所有的模型使用EM算法都能找到全局最优解。特别是IBM模型3-5的训练中使用一些剪枝和近似的方法,优化的真实目标函数会更加复杂。不过,IBM模型1是一个{\small\bfnew{凸函数}}\index{凸函数}(Convex Function)\index{Convex function},因此理论上使用EM方法是能找到全局最优解的。更实际的好处是,IBM模型1训练的最终结果与参数的初始化过程无关。这也是为什么在使用IBM系列模型时,往往会使用IBM模型1作为起始模型的原因。
\parinterval 类似的,IBM模型2-5和隐马尔可夫模型也都可以使用期望最大化(EM)方法进行模型训练。相关数学推导可参考附录\ref{appendix-B}的内容。通常,可以使用这些模型获得双语句子间的词对齐结果,比如使用GIZA++工具。这时,往往会使用多个模型,把简单的模型训练后的参数作为初始值送给后面更加复杂的模型。比如,先用IBM模型1训练,之后把参数送给IBM模型2,再训练,之后把参数送给隐马尔可夫模型等。值得注意的是,并不是所有的模型使用EM算法都能找到全局最优解。特别是IBM模型3-5的训练中使用一些剪枝和近似的方法,优化的真实目标函数会更加复杂。不过,IBM模型1是一个{\small\bfnew{凸函数}}\index{凸函数}(Convex Function)\index{Convex function},因此理论上使用EM方法能够找到全局最优解。更实际的好处是,IBM 模型1训练的最终结果与参数的初始化过程无关。这也是为什么在使用IBM 系列模型时,往往会使用IBM模型1作为起始模型的原因。
%----------------------------------------------------------------------------------------
% NEW SECTION
......@@ -392,11 +414,11 @@ p_0+p_1 & = & 1 \label{eq:6-11}
\subsection{词对齐及对称化}
\parinterval IBM的五个模型都是基于一个词对齐的假设\ \dash \ 一个源语言单词最多只能对齐到一个目标语言单词。这个约束大大化简了IBM模型的建模。最初,Brown等人提出这个假设可能是因为在法英翻译中一对多的对齐情况并不多见,这个假设带来的问题也不是那么严重。但是,在像汉英翻译这样的任务中,一个汉语单词对应多个英语单词的翻译很常见,这时IBM模型的词对齐假设就表现出了明显的问题。比如在翻译``我\ \ \ \ 试一试 。''\ $\to$ \ ``I will have a try .''时,IBM模型根本不能把单词``试一试''对齐到三个单词``have a try'',因而可能无法得到正确的翻译结果。
\parinterval IBM五个模型都是基于一个词对齐的假设\ \dash \ 一个源语言单词最多只能对齐到一个目标语言单词。这个约束大大降低了建模的难度。在法英翻译中一对多的对齐情况并不多见,这个假设带来的问题也不是那么严重。但是,在像汉英翻译这样的任务中,一个汉语单词对应多个英语单词的翻译很常见,这时IBM模型的词对齐假设就表现出了明显的问题。比如在翻译`` 我/会/试一试/。''\ $\to$ \ ``I will have a try .''时,IBM模型根本不能把单词``试一试''对齐到三个单词``have a try'',因而可能无法得到正确的翻译结果。
\parinterval 本质上说,IBM模型词对齐的``不完整''问题是IBM模型本身的缺陷。解决这个问题有很多思路,第一种方法就是,反向训练后,合并源语言单词,然后再正向训练。这里用汉英翻译为例来解释这个方法。首先反向训练,就是把英语当作待翻译语言,而把汉语当作目标语言进行训练(参数估计)。这样可以得到一个词对齐结果(参数估计的中间结果)。在这个词对齐结果里面,一个汉语单词可对应多个英语单词。之后,扫描每个英语句子,如果有多个英语单词对应同一个汉语单词,就把这些英语单词合并成一个英语单词。处理完之后,再把汉语当作源语言而把英语当作目标语言进行训练。这样就可以把一个汉语单词对应到合并的英语单词上。虽然从模型上看,还是一个汉语单词对应一个英语``单词'',但实质上已经把这个汉语单词对应到多个英语单词上了。训练完之后,再利用这些参数进行翻译(解码)时,就能把一个中文单词翻译成多个英文单词了。但是反向训练后再训练也存在一些问题。首先,合并英语单词会使数据变得更稀疏,训练不充分。其次,由于IBM模型的词对齐结果并不是高精度的,利用它的词对齐结果来合并一些英文单词可能造成严重的错误,比如:把本来很独立的几个单词合在了一起。因此,此方法也并不完美。具体使用时还要考虑实际需要和问题的严重程度来决定是否使用这个方法。
\parinterval 本质上,IBM模型词对齐的``不完整''问题是IBM模型本身的缺陷。解决这个问题有很多思路。一种思路是,反向训练后,合并源语言单词,然后再正向训练。这里用汉英翻译为例来解释这个方法。首先反向训练,就是把英语当作待翻译语言,而把汉语当作目标语言进行训练(参数估计)。这样可以得到一个词对齐结果(参数估计的中间结果)。在这个词对齐结果里面,一个汉语单词可对应多个英语单词。之后,扫描每个英语句子,如果有多个英语单词对应同一个汉语单词,就把这些英语单词合并成一个英语单词。处理完之后,再把汉语当作源语言而把英语当作目标语言进行训练。这样就可以把一个汉语单词对应到合并的英语单词上。虽然从模型上看,还是一个汉语单词对应一个英语``单词'',但实质上已经把这个汉语单词对应到多个英语单词上了。训练完之后,再利用这些参数进行翻译(解码)时,就能把一个中文单词翻译成多个英文单词了。但是反向训练后再训练也存在一些问题。首先,合并英语单词会使数据变得更稀疏,训练不充分。其次,由于IBM模型的词对齐结果并不是高精度的,利用它的词对齐结果来合并一些英文单词可能造成严重的错误,比如:把本来很独立的几个单词合在了一起。因此,还要考虑实际需要和问题的严重程度来决定是否使用该方法。
\parinterval 另一种方法是双向对齐之后进行词对齐{\small\sffamily\bfseries{对称化}}\index{对称化}(Symmetrization)\index{Symmetrization}。这个方法可以在IBM词对齐的基础上获得对称的词对齐结果。思路很简单,用正向(汉语为源语言,英语为目标语言)和反向(汉语为目标语言,英语为源语言)同时训练。这样可以得到两个词对齐结果。然后利用一些启发性方法用这两个词对齐生成对称的结果(比如,取``并集''、``交集''等),这样就可以得到包含一对多和多对多的词对齐结果。比如,在基于短语的统计机器翻译中已经很成功地使用了这种词对齐信息进行短语的获取。直到今天,对称化仍然是很多自然语言处理系统中的一个关键步骤。
\parinterval 另一种思路是双向对齐之后进行词对齐{\small\sffamily\bfseries{对称化}}\index{对称化}(Symmetrization)\index{Symmetrization}。这个方法可以在IBM词对齐的基础上获得对称的词对齐结果。思路很简单,用正向(汉语为源语言,英语为目标语言)和反向(汉语为目标语言,英语为源语言)同时训练。这样可以得到两个词对齐结果。然后利用一些启发性方法用这两个词对齐生成对称的结果(比如,取`` 并集''、``交集''等),这样就可以得到包含一对多和多对多的词对齐结果\upcite{och2003systematic}。比如,在基于短语的统计机器翻译中已经很成功地使用了这种词对齐信息进行短语的获取。直到今天,对称化仍然是很多自然语言处理系统中的一个关键步骤。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
......@@ -404,23 +426,23 @@ p_0+p_1 & = & 1 \label{eq:6-11}
\subsection{``缺陷''问题}
\parinterval ``缺陷''问题是指翻译模型会把一部分概率分配给一些根本不存在的源语言字符串。如果用$\textrm{P}(\textrm{well}|\mathbf{t})$表示$\textrm{P}(\mathbf{s}| \mathbf{t})$在所有的正确的(可以理解为语法上正确的)$\mathbf{s}$上的和,即
\parinterval IBM模型的缺陷是指翻译模型会把一部分概率分配给一些根本不存在的源语言字符串。如果用$\funp{P}(\textrm{well}|\vectorn{t})$表示$\funp{P}(\vectorn{s}| \vectorn{t})$在所有的正确的(可以理解为语法上正确的)$\vectorn{s}$上的和,即
\begin{eqnarray}
\textrm{P}(\textrm{well}|\mathbf{t})=\sum_{\mathbf{s}\textrm{\;is\;well\;formed}}{\textrm{P}(\mathbf{s}| \mathbf{t})}
\label{eq:6-15}
\funp{P}(\textrm{well}|\vectorn{t})=\sum_{\vectorn{s}\textrm{\;is\;well\;formed}}{\funp{P}(\vectorn{s}| \vectorn{t})}
\label{eq:6-26}
\end{eqnarray}
\parinterval 类似地,用$\textrm{P}(\textrm{ill}|\mathbf{t})$表示$\textrm{P}(\mathbf{s}| \mathbf{t})$在所有的错误的(可以理解为语法上错误的)$\mathbf{s}$上的和。如果$\textrm{P}(\textrm{well}|\mathbf{t})+ \textrm{P}(\textrm{ill}|\mathbf{t})<1$,就把剩余的部分定义为$\textrm{P}(\textrm{failure}|\mathbf{t})$。它的形式化定义为,
\parinterval 类似地,用$\funp{P}(\textrm{ill}|\vectorn{t})$表示$\funp{P}(\vectorn{s}| \vectorn{t})$在所有的错误的(可以理解为语法上错误的)$\vectorn{s}$上的和。如果$\funp{P}(\textrm{well}|\vectorn{t})+ \funp{P}(\textrm{ill}|\vectorn{t})<1$,就把剩余的部分定义为$\funp{P}(\textrm{failure}|\vectorn{t})$。它的形式化定义为,
\begin{eqnarray}
\textrm{P}({\textrm{failure}|\mathbf{t}}) = 1 - \textrm{P}({\textrm{well}|\mathbf{t}}) - \textrm{P}({\textrm{ill}|\mathbf{t}})
\label{eq:6-16}
\funp{P}({\textrm{failure}|\vectorn{t}}) = 1 - \funp{P}({\textrm{well}|\vectorn{t}}) - \funp{P}({\textrm{ill}|\vectorn{t}})
\label{eq:6-27}
\end{eqnarray}
\parinterval 本质上,模型3和模型4就是对应$\textrm{P}({\textrm{failure}|\mathbf{t}})>0$的情况。这部分概率是模型损失掉的。有时候也把这类``缺陷''问题称为Technical Deficiency。还有一种``缺陷''问题被称作Spiritually Deficiency,它是指$\textrm{P}({\textrm{well}|\mathbf{t}}) + \textrm{P}({\textrm{ill}|\mathbf{t}}) = 1$$\textrm{P}({\textrm{ill}|\mathbf{t}}) > 0$的情况。模型1和模型2就有Spiritually Deficiency的问题。可以注意到,Technical Deficiency只存在于模型3和模型4中,模型1和模型2并没有Technical Deficiency问题。根本原因是模型1和模型2的词对齐是从源语言出发对应到目标语言,$\mathbf{t}$$\mathbf{s}$的翻译过程实际上是从单词$s_1$开始到单词$s_m$结束,依次把每个源语言单词$s_j$对应到唯一一个目标语言位置。显然,这个过程能够保证每个源语言单词仅对应一个目标语言单词。但是,模型3和模型4中对齐是从目标语言出发对应到源语言,$\mathbf{t}$$\mathbf{s}$的翻译过程从$t_1$开始$t_l$结束,依次把目标语言单词$t_i$生成的单词对应到某个源语言位置上。但是这个过程不能保证$t_i$中生成的单词所对应的位置没有被其他已经完成对齐的目标语单词所生成的某个源语言单词对应过,因此也就产生了``缺陷''问题
\parinterval 本质上,模型3和模型4就是对应$\funp{P}({\textrm{failure}|\vectorn{t}})>0$的情况。这部分概率是模型损失掉的。有时候也把这类缺陷称为{\small\bfnew{物理缺陷}}\index{物理缺陷}(Physical Deficiency\index{Physical Deficiency})或{\small\bfnew{技术缺陷}}\index{技术缺陷}(Technical Deficiency\index{Technical Deficiency})。还有一种缺陷被称作{\small\bfnew{精神缺陷}}(Spiritual Deficiency\index{Spiritual Deficiency})或{\small\bfnew{逻辑缺陷}}\index{逻辑缺陷}(Logical Deficiency\index{Logical Deficiency}),它是指$\funp{P}({\textrm{well}|\vectorn{t}}) + \funp{P}({\textrm{ill}|\vectorn{t}}) = 1$$\funp{P}({\textrm{ill}|\vectorn{t}}) > 0$的情况。模型1 和模型2 就有逻辑缺陷。可以注意到,技术缺陷只存在于模型3 和模型4 中,模型1和模型2并没有技术缺陷问题。根本原因在于模型1和模型2的词对齐是从源语言出发对应到目标语言,$\vectorn{t}$$\vectorn{s}$ 的翻译过程实际上是从单词$s_1$开始到单词$s_m$ 结束,依次把每个源语言单词$s_j$对应到唯一一个目标语言位置。显然,这个过程能够保证每个源语言单词仅对应一个目标语言单词。但是,模型3 和模型4中对齐是从目标语言出发对应到源语言,$\vectorn{t}$$\vectorn{s}$的翻译过程从$t_1$开始$t_l$ 结束,依次把目标语言单词$t_i$生成的单词对应到某个源语言位置上。但是这个过程不能保证$t_i$中生成的单词所对应的位置没有被其他单词占用,因此也就产生了缺陷
\parinterval 这里还要强调的是,Technical Deficiency是模型3和模型4是模型本身的缺陷造成的,如果有一个``更好''的模型就可以完全避免这个问题。而Spiritually Deficiency几乎是不能从模型上根本解决的,因为对于任意一种语言都不能枚举所有的句子($\textrm{P}({\textrm{ill}|\mathbf{t}})$实际上是得不到的)。
\parinterval 这里还要强调的是,技术缺陷是模型3和模型4是模型本身的缺陷造成的,如果有一个``更好''的模型就可以完全避免这个问题。而逻辑缺陷几乎是不能从模型上根本解决的,因为对于任意一种语言都不能枚举所有的句子($\funp{P}({\textrm{ill}|\vectorn{t}})$实际上是得不到的)。
\parinterval IBM的模型5已经解决了Technical Deficiency问题。不过模型5过于复杂。实际上Technical Deficiency问题是不是需要解决,这一点在本节随后的内容中还要进行讨论。Spiritually Deficiency的解决很困难,因为即使对于人来说也很难判断一个句子是不是``良好''的句子。当然可以考虑用语言模型来缓解这个问题,不过由于在翻译的时候源语言句子都是定义``良好''的句子,$\textrm{P}({\textrm{ill}|\mathbf{t}})$$\textrm{P}(\mathbf{s}| \mathbf{t})$的影响并不大。但用输入的源语言句子$\mathbf{s}$的``良好性''并不能解决Technical Deficiency,因为Technical Deficiency是模型的问题或者模型参数估计方法的问题。无论输入什么样的$\mathbf{s}$,模型3和模型4的Technical Deficiency问题都存在。
\parinterval IBM的模型5已经解决了技术缺陷问题。但逻辑缺陷的解决很困难,因为即使对于人来说也很难判断一个句子是不是``良好''的句子。当然可以考虑用语言模型来缓解这个问题,不过由于在翻译的时候源语言句子都是定义``良好''的句子,$\funp{P}({\textrm{ill}|\vectorn{t}})$$\funp{P}(\vectorn{s}| \vectorn{t})$的影响并不大。但用输入的源语言句子$\vectorn{s}$的``良好性''并不能解决技术缺陷,因为技术缺陷是模型的问题或者模型参数估计方法的问题。无论输入什么样的$\vectorn{s}$,模型3和模型4的技术缺陷问题都存在。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
......@@ -428,9 +450,9 @@ p_0+p_1 & = & 1 \label{eq:6-11}
\subsection{句子长度}
\parinterval 在IBM模型中,$\textrm{P}(\mathbf{t})\textrm{P}(\mathbf{s}| \mathbf{t})$会随着目标语言句子长度的增加而减少,因为这种生成模型有多个概率化的因素组成,一般乘积项越多结果的值越小。这也就是说,IBM模型会更倾向选择长度短一些的目标语言句子。显然这种对短句子的偏向性并不是我们所期望的。
\parinterval 在IBM模型中,$\funp{P}(\vectorn{t})\funp{P}(\vectorn{s}| \vectorn{t})$会随着目标语言句子长度的增加而减少,因为这种模型有多个概率化的因素组成,乘积项越多结果的值越小。这也就是说,IBM模型会更倾向选择长度短一些的目标语言句子。显然这种对短句子的偏向性并不是机器翻译所期望的。
\parinterval 这个问题在很多统计机器翻译系统中都存在,实际上也是一种{\small\bfnew{系统偏置}}\index{系统偏置}(System Bias)\index{System Bias}的体现。为了消除这种偏置,可以通过在模型中增加一个短句子惩罚引子来抵消掉模型对短句子的倾向性。比如,可以定义一个惩罚引子,它的值随着长度的减少而增加。不过,简单引入这样的惩罚因子会导致模型并不符合一个严格的噪声信道模型。它对应一个判别式框架的翻译模型,这部分内容会在下一章进行介绍。
\parinterval 这个问题在很多机器翻译系统中都存在。它实际上也反应了一种{\small\bfnew{系统偏置}}\index{系统偏置}(System Bias)\index{System Bias}的体现。为了消除这种偏置,可以通过在模型中增加一个短句子惩罚引子来抵消掉模型对短句子的倾向性。比如,可以定义一个惩罚引子,它的值随着长度的减少而增加。不过,简单引入这样的惩罚因子会导致模型并不符合一个严格的噪声信道模型。它对应一个基于判别式框架的翻译模型,这部分内容会在{\chapterseven}进行介绍。
%----------------------------------------------------------------------------------------
% NEW SUB-SECTION
......@@ -438,7 +460,7 @@ p_0+p_1 & = & 1 \label{eq:6-11}
\subsection{其他问题}
\parinterval 模型5的意义是什么?模型5的提出是为了消除模型3和模型4的Deficiency问题。Deficiency问题的本质是,$\textrm{P}(\mathbf{s},\mathbf{a}| \mathbf{t})$在所有合理的对齐上概率和不为1。 但是,在统计机器翻译中更关心是哪个对齐$\mathbf{a}$使$\textrm{P}(\mathbf{s},\mathbf{a}| \mathbf{t})$达到最大,即使$\textrm{P}(\mathbf{s},\mathbf{a}|\mathbf{t})$不符合概率分布的定义,也并不影响我们寻找理想的对齐$\mathbf{a}$。从工程的角度说,$\textrm{P}(\mathbf{s},\mathbf{a}| \mathbf{t})$不归一并不是一个十分严重的问题。遗憾的是,实际上到现在为止有太多对IBM模型3和模型4中的Deficiency 问题进行过系统的实验和分析,但对于这个问题到底有多严重并没有定论。当然用模型5是可以解决这个问题。但是如果用一个非常复杂的模型去解决了一个并不产生严重后果的问题,那这个模型也就没有太大意义了(从实践的角度)。
\parinterval 模型5的意义是什么?模型5的提出是为了消除模型3和模型4的缺陷。缺陷的本质是,$\funp{P}(\vectorn{s},\vectorn{a}| \vectorn{t})$在所有合理的对齐上概率和不为1。 但是,在这里更关心是哪个对齐$\vectorn{a}$使$\funp{P}(\vectorn{s},\vectorn{a}| \vectorn{t})$达到最大,即使$\funp{P}(\vectorn{s},\vectorn{a}|\vectorn{t})$不符合概率分布的定义,也并不影响我们寻找理想的对齐$\vectorn{a}$。从工程的角度说,$\funp{P}(\vectorn{s},\vectorn{a}| \vectorn{t})$不归一并不是一个十分严重的问题。遗憾的是,实际上到现在为止有太多对IBM模型3和模型4中的缺陷进行过系统的实验和分析,但对于这个问题到底有多严重并没有定论。当然用模型5是可以解决这个问题。但是如果用一个非常复杂的模型去解决了一个并不产生严重后果的问题,那这个模型也就没有太大意义了(从实践的角度)。
\parinterval 概念(cept.)的意义是什么?经过前面的分析可知,IBM模型的词对齐模型使用了cept.这个概念。但是,在IBM模型中使用的cept.最多只能对应一个目标语言单词(模型并没有用到源语言cept. 的概念)。因此可以直接用单词代替cept.。这样,即使不引入cept.的概念,也并不影响IBM模型的建模。实际上,cept.的引入确实可以帮助我们从语法和语义的角度解释词对齐过程。不过,这个方法在IBM 模型中的效果究竟如何还没有定论。
......@@ -451,15 +473,15 @@ p_0+p_1 & = & 1 \label{eq:6-11}
{\color{red}产出率需要增加}
\parinterval 本章对IBM系列模型进行了全面的介绍和讨论,从一个简单的基于单词的翻译模型开始,本章以建模、解码、训练多个维度对统计机器翻译进行了描述,期间也涉及了词对齐、优化等多个重要概念。IBM 模型共分为5个模型,对翻译问题的建模依次由浅入深,同时模型复杂度也依次增加。IBM模型作为入门统计机器翻译的``必经之路'',其思想对今天的机器翻译仍然产生着影响。虽然单独使用IBM模型进行机器翻译现在已经不多见,甚至很多从事神经机器翻译等前沿研究的人对IBM模型已经逐渐淡忘,但是不能否认IBM模型标志着一个时代的开始。从某种意义上,当使用公式$\hat{\mathbf{t}} = \argmax_{\mathbf{t}} \textrm{P}(\mathbf{t}|\mathbf{s})$描述机器翻译问题的时候,或多或少都在与IBM模型使用相似的思想。
\parinterval 本章对IBM系列模型进行了全面的介绍和讨论,从一个简单的基于单词的翻译模型开始,本章以建模、解码、训练多个维度对统计机器翻译进行了描述,期间也涉及了词对齐、优化等多个重要概念。IBM 模型共分为5个模型,对翻译问题的建模依次由浅入深,同时模型复杂度也依次增加。IBM模型作为入门统计机器翻译的``必经之路'',其思想对今天的机器翻译仍然产生着影响。虽然单独使用IBM模型进行机器翻译现在已经不多见,甚至很多从事神经机器翻译等前沿研究的人对IBM模型已经逐渐淡忘,但是不能否认IBM模型标志着一个时代的开始。从某种意义上,当使用公式$\hat{\vectorn{t}} = \argmax_{\vectorn{t}} \funp{P}(\vectorn{t}|\vectorn{s})$描述机器翻译问题的时候,或多或少都在与IBM模型使用相似的思想。
\parinterval 当然,本书也无法涵盖IBM模型的所有内涵,很多内容需要感兴趣的读者继续研究和挖掘,有两个方向可以考虑:
\begin{itemize}
\vspace{0.5em}
\item IBM模型在提出后的十余年中,一直受到了学术界的关注。一个比较有代表性的成果是GIZA++(\url{https://github.com/moses-smt/giza-pp}),它集成了IBM模型和隐马尔可夫模型,并实现了这些模型的训练。在随后相当长的一段时间里,GIZA++也是机器翻译研究的标配,用于获得双语平行数据上单词一级的对齐结果。此外,研究者也对IBM模型进行了大量的分析,为后人研究统计机器翻译提供了大量依据\cite{och2004alignment}。虽然IBM模型很少被独立使用,甚至直接用基于IBM模型的解码器也不多见,但是它通常会作为其他模型的一部分参与到对翻译的建模中。这部分工作会在下一章基于短语和句法的模型中进行讨论\cite{koehn2003statistical}。此外,IBM模型也给机器翻译提供了一种非常简便的计算双语词串对应好坏的方式,因此也被广泛用于度量双语词串对应的强度,是自然语言处理中的一种常用特征。
\item IBM模型在提出后的十余年中,一直受到了学术界的关注。一个比较有代表性的成果是GIZA++(\url{https://github.com/moses-smt/giza-pp}),它集成了IBM模型和隐马尔可夫模型,并实现了这些模型的训练。在随后相当长的一段时间里,GIZA++也是机器翻译研究的标配,用于获得双语平行数据上单词一级的对齐结果。此外,研究者也对IBM模型进行了大量的分析,为后人研究统计机器翻译提供了大量依据\upcite{och2004alignment}。虽然IBM模型很少被独立使用,甚至直接用基于IBM模型的解码器也不多见,但是它通常会作为其他模型的一部分参与到对翻译的建模中。这部分工作会在下一章基于短语和句法的模型中进行讨论\upcite{koehn2003statistical}。此外,IBM模型也给机器翻译提供了一种非常简便的计算双语词串对应好坏的方式,因此也被广泛用于度量双语词串对应的强度,是自然语言处理中的一种常用特征。
\vspace{0.5em}
\item 除了在机器翻译建模上的开创性工作,IBM模型的另一项重要贡献是建立了统计词对齐的基础模型。在训练IBM模型的过程中,除了学习到模型参数,还可以得到双语数据上的词对齐结果。也就是说词对齐标注是IBM模型训练的间接产物。这也使得IBM模型成为了自动词对齐的重要方法。包括GIZA++在内的很多工作,实际上更多的是被用于自动词对齐任务,而非简单的训练IBM模型参数。随着词对齐概念的不断深入,这个任务逐渐成为了自然语言处理中的重要分支,比如,对IBM模型的结果进行对称化\cite{och2003systematic},也可以直接使用判别式模型利用分类模型解决词对齐问题\cite{ittycheriah2005maximum},甚至可以把对齐的思想用于短语和句法结构的双语对应\cite{xiao2013unsupervised}。除了GIZA++,研究人员也开发了很多优秀的自动词对齐工具,比如,FastAlign (\url{https://github.com/clab/fast_align})、Berkeley Aligner(\url{https://github.com/mhajiloo/berkeleyaligner})等,这些工具现在也有很广泛的应用。
\item 除了在机器翻译建模上的开创性工作,IBM模型的另一项重要贡献是建立了统计词对齐的基础模型。在训练IBM模型的过程中,除了学习到模型参数,还可以得到双语数据上的词对齐结果。也就是说词对齐标注是IBM模型训练的间接产物。这也使得IBM模型成为了自动词对齐的重要方法。包括GIZA++在内的很多工作,实际上更多的是被用于自动词对齐任务,而非简单的训练IBM模型参数。随着词对齐概念的不断深入,这个任务逐渐成为了自然语言处理中的重要分支,比如,对IBM模型的结果进行对称化\upcite{och2003systematic},也可以直接使用判别式模型利用分类模型解决词对齐问题\upcite{ittycheriah2005maximum},甚至可以把对齐的思想用于短语和句法结构的双语对应\upcite{xiao2013unsupervised}。除了GIZA++,研究人员也开发了很多优秀的自动词对齐工具,比如,FastAlign (\url{https://github.com/clab/fast_align})、Berkeley Aligner(\url{https://github.com/mhajiloo/berkeleyaligner})等,这些工具现在也有很广泛的应用。
\vspace{0.5em}
\end{itemize}
......
......@@ -4,12 +4,12 @@
\begin{scope}[minimum height = 18pt]
\node[anchor=east] (s0) at (-0.5em, 0) {$\textbf{s}$:};
\node[anchor=east] (s0) at (-0.5em, 0) {$\seq{s}$};
\node[anchor=west,fill=gray!20] (s1) at (0, 0) {\footnotesize{桌子 上}};
\node[anchor=west,fill=gray!20] (s2) at ([xshift=1em]s1.east) {\footnotesize{}};
\node[anchor=west,fill=gray!20] (s3) at ([xshift=1em]s2.east) {\footnotesize{一个 苹果}};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\textbf{t}$:};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\seq{t}$};
\node[anchor=north] (l) at ([xshift=7em,yshift=-0.5em]t0.south) {\footnotesize{(a)\ }};
\end{scope}
......@@ -18,12 +18,12 @@
\begin{scope}[xshift=15em,minimum height = 18pt]
\node[anchor=east] (s0) at (-0.5em, 0) {$\textbf{s}$:};
\node[anchor=east] (s0) at (-0.5em, 0) {$\seq{s}$};
\node[anchor=west,fill=gray!20] (s1) at (0, 0) {\footnotesize{桌子 上}};
\node[anchor=west,fill=red!20] (s2) at ([xshift=1em]s1.east) {\footnotesize{}};
\node[anchor=west,fill=gray!20] (s3) at ([xshift=1em]s2.east) {\footnotesize{一个 苹果}};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\textbf{t}$:};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\seq{t}$};
{
\node[anchor=west,fill=red!20] (t1) at (0, -1.5) {\footnotesize{There is}};
\path[<->, thick] (s2.south) edge (t1.north);
......@@ -36,12 +36,12 @@
\begin{scope}[yshift=-9.5em,minimum height = 18pt]
\node[anchor=east] (s0) at (-0.5em, 0) {$\textbf{s}$:};
\node[anchor=east] (s0) at (-0.5em, 0) {$\seq{s}$};
\node[anchor=west,fill=gray!20] (s1) at (0, 0) {\footnotesize{桌子 上}};
\node[anchor=west,fill=gray!20] (s2) at ([xshift=1em]s1.east) {\footnotesize{}};
\node[anchor=west,fill=red!20] (s3) at ([xshift=1em]s2.east) {\footnotesize{一个 苹果}};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\textbf{t}$:};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\seq{t}$};
{
\node[anchor=west,fill=gray!20] (t1) at (0, -1.5) {\footnotesize{There is}};
\path[<->, thick] (s2.south) edge (t1.north);
......@@ -58,12 +58,12 @@
\begin{scope}[xshift=15em,yshift=-9.5em,minimum height = 18pt]%[scale=0.5]
\node[anchor=east] (s0) at (-0.5em, 0) {$\textbf{s}$:};
\node[anchor=east] (s0) at (-0.5em, 0) {$\seq{s}$};
\node[anchor=west,fill=red!20] (s1) at (0, 0) {\footnotesize{桌子 上}};
\node[anchor=west,fill=gray!20] (s2) at ([xshift=1em]s1.east) {\footnotesize{}};
\node[anchor=west,fill=gray!20] (s3) at ([xshift=1em]s2.east) {\footnotesize{一个 苹果}};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\textbf{t}$:};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\seq{t}$};
{
\node[anchor=west,fill=gray!20] (t1) at (0, -1.5) {\footnotesize{There is}};
\path[<->, thick] (s2.south) edge (t1.north);
......
......@@ -19,8 +19,8 @@
\path[<->, thick] (s3.south) edge (t3.north);
}
\node[anchor=south] (s0) at ([xshift=-2em,yshift=0em]s1.south) {\textbf{s:}};
\node[anchor=east] (t0) at ([xshift=0em,yshift=-3.5em]s0.east) {\textbf{t:}};
\node[anchor=south] (s0) at ([xshift=-2em,yshift=0em]s1.south) {$\seq{s}$};
\node[anchor=east] (t0) at ([xshift=0em,yshift=-3.5em]s0.east) {$\seq{t}$};
\node[anchor=south,inner sep=0pt,yshift=-0.3em] (sp1) at (s1.north) {\footnotesize{$\bar{s}_{a_1 = 1}$}};
\node[anchor=south,inner sep=0pt,yshift=-0.3em] (sp2) at (s2.north) {\footnotesize{$\bar{s}_{a_2 = 2}$}};
......
......@@ -5,7 +5,7 @@
{
\node [anchor=north,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h0) at (0,0) {\small{null}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl0) at (h0.north west) {\scriptsize{{\color{white} \textbf{0}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt0) at (h0.east) {\footnotesize{{\color{white} \textbf{P=1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt0) at (h0.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=1}}}};
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h2) at ([xshift=2.2em,yshift=3.5em]h0.east) {\small{an}};
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h3) at ([xshift=2.2em]h2.east) {\small{apple}};
......@@ -13,8 +13,8 @@
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl2) at (h2.north west) {\scriptsize{{\color{white} \textbf{1}}}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl3) at (h3.north west) {\scriptsize{{\color{white} \textbf{2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt2) at (h2.east) {\footnotesize{{\color{white} \textbf{P=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h3.east) {\footnotesize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt2) at (h2.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h3.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.5}}}};
\draw [->,very thick,ublue] ([xshift=0.1em]pt0.south) -- ([xshift=-0.1em]h2.west);
\draw [->,very thick,ublue] ([xshift=0.1em]pt2.south) -- ([xshift=-0.1em]h3.west);
......@@ -22,7 +22,7 @@
{
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h1) at ([xshift=7em]h0.east) {\small{an apple}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl1) at (h1.north west) {\scriptsize{{\color{white} \textbf{1-2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt1) at (h1.east) {\footnotesize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt1) at (h1.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.5}}}};
\draw [->,very thick,ublue] ([xshift=0.1em]pt0.south) -- ([xshift=-0.1em]h1.west);
}
}
......@@ -37,10 +37,10 @@
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl5) at (h6.north west) {\scriptsize{{\color{white} \textbf{1}}}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl5) at (h8.north west) {\scriptsize{{\color{white} \textbf{2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt4) at (h4.east) {\footnotesize{{\color{white} \textbf{P=1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt5) at (h5.east) {\footnotesize{{\color{white} \textbf{P=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt6) at (h6.east) {\footnotesize{{\color{white} \textbf{P=.4}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt8) at (h8.east) {\footnotesize{{\color{white} \textbf{P=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt4) at (h4.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt5) at (h5.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt6) at (h6.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.4}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt8) at (h8.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.2}}}};
\draw [->,very thick,ublue] ([xshift=0.1em]pt4.south) -- ([xshift=-0.1em]h5.west);
\draw [->,very thick,ublue] ([xshift=0.1em]pt4.south) -- ([xshift=-0.1em]h6.west);
......@@ -48,7 +48,7 @@
{
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h7) at ([xshift=2.2em]h5.east) {\small{is not}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt7) at (h7.east) {\footnotesize{{\color{white} \textbf{P=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt7) at (h7.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.2}}}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl5) at (h7.north west) {\scriptsize{{\color{white} \textbf{2}}}};
\draw [->,very thick,ublue] ([xshift=0.1em]pt5.south) -- ([xshift=-0.1em]h7.west);
}
......@@ -68,7 +68,7 @@
{
\node [anchor=north,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h0) at (0,0) {\small{null}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl0) at (h0.north west) {\scriptsize{{\color{white} \textbf{0}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt0) at (h0.east) {\footnotesize{{\color{white} \textbf{P=1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt0) at (h0.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=1}}}};
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h2) at ([xshift=2.2em,yshift=3.5em]h0.east) {\small{an}};
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h3) at ([xshift=2.2em]h2.east) {\small{apple}};
......@@ -76,8 +76,8 @@
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl2) at (h2.north west) {\scriptsize{{\color{white} \textbf{1}}}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl3) at (h3.north west) {\scriptsize{{\color{white} \textbf{2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt2) at (h2.east) {\footnotesize{{\color{white} \textbf{P=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h3.east) {\footnotesize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt2) at (h2.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h3.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.5}}}};
\draw [->,very thick,ublue] ([xshift=0.1em]pt0.south) -- ([xshift=-0.1em]h2.west);
\draw [->,very thick,ublue] ([xshift=0.1em]pt2.south) -- ([xshift=-0.1em]h3.west);
......@@ -97,10 +97,10 @@
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl5) at (h6.north west) {\scriptsize{{\color{white} \textbf{1}}}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl5) at (h8.north west) {\scriptsize{{\color{white} \textbf{2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt4) at (h4.east) {\footnotesize{{\color{white} \textbf{P=1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt5) at (h5.east) {\footnotesize{{\color{white} \textbf{P=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt6) at (h6.east) {\footnotesize{{\color{white} \textbf{P=.4}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt8) at (h8.east) {\footnotesize{{\color{white} \textbf{P=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt4) at (h4.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt5) at (h5.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt6) at (h6.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.4}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt8) at (h8.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.2}}}};
\draw [->,very thick,ublue] ([xshift=0.1em]pt4.south) -- ([xshift=-0.1em]h5.west);
\draw [->,very thick,ublue] ([xshift=0.1em]pt4.south) -- ([xshift=-0.1em]h6.west);
......@@ -117,11 +117,11 @@
{
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em,opacity=0.3] (h1) at ([xshift=7em]h0.east) {\small{an apple}};
\node [anchor=north west,inner sep=1.0pt,fill=black,opacity=0.3] (hl1) at (h1.north west) {\scriptsize{{\color{white} \textbf{1-2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt1) at (h1.east) {\footnotesize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt1) at (h1.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.5}}}};
}
{
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em,opacity=0.3] (h7) at ([xshift=2.2em]h5.east) {\small{is not}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt7) at (h7.east) {\footnotesize{{\color{white} \textbf{P=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black,opacity=0.3] (pt7) at (h7.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.2}}}};
\node [anchor=north west,inner sep=1.0pt,fill=black,opacity=0.3] (hl5) at (h7.north west) {\scriptsize{{\color{white} \textbf{2}}}};
}
}
......
......@@ -2,7 +2,7 @@
%%% 引入短语翻译
{\small
\begin{tabular}{l | l}
{\red{词串}}翻译表 & P \\ \hline
{\red{词串}}翻译表 & $\funp{P}$ \\ \hline
$\to$ I & 0.6 \\
喜欢 $\to$ like & 0.3 \\
$\to$ red & 0.8 \\
......
......@@ -12,7 +12,7 @@
\node [anchor=west] (s2) at ([xshift=1.0em]s1.east) {喜欢};
\node [anchor=west] (s3) at ([xshift=1.0em]s2.east) {\red{}};
\node [anchor=west] (s4) at ([xshift=1.0em]s3.east) {};
\node [anchor=east] (s) at (s1.west) {$\textbf{s}=$};
\node [anchor=east] (s) at (s1.west) {$\seq{s}=$};
}
\end{scope}
......@@ -22,7 +22,7 @@
\node [anchor=west] (t2) at ([xshift=0.8em,yshift=-0.0em]t1.east) {like};
\node [anchor=west] (t3) at ([xshift=0.6em,yshift=-0.0em]t2.east) {red};
\node [anchor=west] (t4) at ([xshift=1.15em,yshift=-0.1em]t3.east) {tea};
\node [anchor=east] (t) at ([xshift=-0.2em]t1.west) {$\textbf{t}=$};
\node [anchor=east] (t) at ([xshift=-0.2em]t1.west) {$\seq{t}=$};
}
\end{scope}
......@@ -44,7 +44,7 @@
\node [anchor=west] (s2) at ([xshift=1.0em]s1.east) {喜欢};
\node [anchor=west] (s3) at ([xshift=1.0em]s2.east) {\red{}};
\node [anchor=west] (s4) at ([xshift=1.0em]s3.east) {};
\node [anchor=east] (s) at (s1.west) {$\textbf{s}=$};
\node [anchor=east] (s) at (s1.west) {$\seq{s}=$};
}
\end{scope}
......@@ -54,7 +54,7 @@
\node [anchor=west] (t2) at ([xshift=0.8em,yshift=-0.0em]t1.east) {like};
\node [anchor=west] (t3) at ([xshift=0.6em,yshift=-0.0em]t2.east) {black};
\node [anchor=west] (t4) at ([xshift=1.0em,yshift=-0.1em]t3.east) {tea};
\node [anchor=east] (t) at ([xshift=-0.2em]t1.west) {$\textbf{t}=$};
\node [anchor=east] (t) at ([xshift=-0.2em]t1.west) {$\seq{t}=$};
}
\end{scope}
......
......@@ -6,7 +6,7 @@
{
\node [anchor=north,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h0) at (0,0) {\scriptsize{null}};
\node [anchor=north west,inner sep=1.5pt,fill=black] (hl0) at (h0.north west) {\scriptsize{{\color{white} \textbf{0}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt0) at (h0.east) {\scriptsize{{\color{white} \textbf{P=1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt0) at (h0.east) {\scriptsize{{\color{white} \textbf{$\funp{P}$=1}}}};
}
{
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h13) at ([xshift=2.1em,yshift=6em]h0.east) {\scriptsize{there is}};
......@@ -17,8 +17,8 @@
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl3) at (h13.north west) {\scriptsize{{\color{white} \textbf{3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt1) at (h1.east) {\scriptsize{{\color{white} \textbf{P=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h13.east) {\scriptsize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt1) at (h1.east) {\scriptsize{{\color{white} \textbf{$\funp{P}$=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h13.east) {\scriptsize{{\color{white} \textbf{$\funp{P}$=.5}}}};
\node [anchor=west,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3em] (h2) at ([xshift=2.1em]h1.east) {\scriptsize{have}};
\node [anchor=west,inner sep=2pt,minimum height=2em,minimum width=3em] (h22) at ([xshift=2.1em]h12.east) {\small{\textbf{...}}};
......@@ -32,15 +32,15 @@
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl3) at (h3.north west) {\scriptsize{{\color{white} \textbf{2}}}};
\node [anchor=north west,inner sep=1.0pt,fill=black] (hl33) at (h33.north west) {\scriptsize{{\color{white} \textbf{4-5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt2) at (h2.east) {\scriptsize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt23) at (h23.east) {\scriptsize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h3.east) {\scriptsize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt33) at (h33.east) {\scriptsize{{\color{white} \textbf{P=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt2) at (h2.east) {\scriptsize{{\color{white} \textbf{$\funp{P}$=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt23) at (h23.east) {\scriptsize{{\color{white} \textbf{$\funp{P}$=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h3.east) {\scriptsize{{\color{white} \textbf{$\funp{P}$=.5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt33) at (h33.east) {\scriptsize{{\color{white} \textbf{$\funp{P}$=.5}}}};
}
\node [anchor=north] (l0) at ([xshift=0.2em,yshift=-0.7em]h0.south) {\small{\textbf{未译词}}};
\node [anchor=north] (l1) at ([xshift=0.3em,yshift=-0.7em]h1.south) {\small{\textbf{已译1}}};
\node [anchor=north] (l2) at ([xshift=0.3em,yshift=-0.7em]h2.south) {\small{\textbf{已译2}}};
\node [anchor=north] (l3) at ([xshift=0.3em,yshift=-0.7em]h3.south) {\small{\textbf{已译3}}};
\node [anchor=north] (l1) at ([xshift=0.3em,yshift=-0.7em]h1.south) {\small{\textbf{已译}1\textbf{}}};
\node [anchor=north] (l2) at ([xshift=0.3em,yshift=-0.7em]h2.south) {\small{\textbf{已译}2\textbf{}}};
\node [anchor=north] (l3) at ([xshift=0.3em,yshift=-0.7em]h3.south) {\small{\textbf{已译}3\textbf{}}};
\begin{pgfonlayer}{background}
\node [rectangle,inner sep=0.3em,fill=blue!10] [fit = (h0) (pt0)] (box0) {};
......
......@@ -4,7 +4,7 @@
{\small
\begin{tabular}{l | l}
单词翻译表 & P \\ \hline
单词翻译表 & $\funp{P}$ \\ \hline
$\to$ I & 0.6 \\
喜欢 $\to$ like & 0.3 \\
绿 $\to$ green & 0.9 \\
......
......@@ -7,7 +7,7 @@
\node [anchor=west] (s2) at ([xshift=1.0em]s1.east) {喜欢};
\node [anchor=west] (s3) at ([xshift=1.0em]s2.east) {{\color{ugreen} 绿}};
\node [anchor=west] (s4) at ([xshift=1.07em]s3.east) {};
\node [anchor=east] (s) at (s1.west) {$\textbf{s}=$};
\node [anchor=east] (s) at (s1.west) {$\seq{s}=$};
}
\end{scope}
......@@ -18,7 +18,7 @@
\node [anchor=west] (t2) at ([xshift=0.8em,yshift=-0.0em]t1.east) {like};
\node [anchor=west] (t3) at ([xshift=1.0em,yshift=-0.2em]t2.east) {green};
\node [anchor=west] (t4) at ([xshift=0.78em,yshift=0.1em]t3.east) {tea};
\node [anchor=east] (t) at ([xshift=-0.3em]t1.west) {$\textbf{t}=$};
\node [anchor=east] (t) at ([xshift=-0.3em]t1.west) {$\seq{t}=$};
}
\end{scope}
......
......@@ -2,7 +2,7 @@
%%% 基于单词的模型的问题
{\small
\begin{tabular}{l | l}
单词翻译表 & P \\ \hline
单词翻译表 & $\funp{P}$ \\ \hline
$\to$ I & 0.6 \\
喜欢 $\to$ like & 0.3 \\
$\to$ red & 0.8 \\
......
......@@ -10,7 +10,7 @@
\node [anchor=west] (s2) at ([xshift=1.0em]s1.east) {喜欢};
\node [anchor=west] (s3) at ([xshift=1.0em]s2.east) {\red{}};
\node [anchor=west] (s4) at ([xshift=1.0em]s3.east) {};
\node [anchor=east] (s) at (s1.west) {$\textbf{s}=$};
\node [anchor=east] (s) at (s1.west) {$\seq{s}=$};
}
\end{scope}
......@@ -21,7 +21,7 @@
\node [anchor=west] (t2) at ([xshift=0.8em,yshift=-0.0em]t1.east) {like};
\node [anchor=west] (t3) at ([xshift=1.0em,yshift=-0.0em]t2.east) {red};
\node [anchor=west] (t4) at ([xshift=1.0em,yshift=-0.1em]t3.east) {tea};
\node [anchor=east] (t) at ([xshift=-0.3em]t1.west) {$\textbf{t}=$};
\node [anchor=east] (t) at ([xshift=-0.3em]t1.west) {$\seq{t}=$};
}
\end{scope}
......@@ -34,7 +34,7 @@
\begin{pgfonlayer}{background}
{
\node [rectangle,draw,thick,inner sep=0.2em,fill=white,drop shadow] [fit = (t3) (t4)] (problemphrase) {};
\node [anchor=north,text width=8em,align=left] (problemlabel) at (problemphrase.south) {\begin{spacing}{0.8}\scriptsize{``红 茶''为一种搭配,应该翻译为``black tea''}\end{spacing}};
\node [anchor=north,text width=8em,align=left] (problemlabel) at (problemphrase.south) {\begin{spacing}{0.8}\scriptsize{“红 茶”为一种搭配,应该翻译为“black tea”}\end{spacing}};
}
\end{pgfonlayer}
......
......@@ -39,7 +39,7 @@
\node[align=center,elementnode,minimum size=0.3cm,inner sep=0.1pt,fill=blue!50] (la4) at (a41) {};
\node[align=center,elementnode,minimum size=0.3cm,inner sep=0.1pt,fill=blue!50] (la5) at (a30) {};
\node[anchor=west] (f1) at ([xshift=3em,yshift=0.8em]a43.east) {\small{$\textrm{P}_{\textrm{lex}}(\bar{t}|\bar{s})=w(t_1|s_1)\times$}};
\node[anchor=west] (f1) at ([xshift=3em,yshift=0.8em]a43.east) {\small{$\funp{P}_{\textrm{lex}}(\bar{t}|\bar{s})=w(t_1|s_1)\times$}};
\node[anchor=north] (f2) at ([xshift=5.2em]f1.south) {\small{$\frac{1}{2}(w(t_2|s_2)+w(t_4|s_2))\times$}};
\node[anchor=north west] (f3) at (f2.south west) {\small{$w(N|s_3)\times$}};
\node[anchor=north west] (f4) at (f3.south west) {\small{$w(t_4|s_4)\times$}};
......
......@@ -19,8 +19,8 @@
\path[<->, thick] (s3.south) edge (t3.north);
}
\node[anchor=south] (s0) at ([xshift=-3em,yshift=0em]s1.south) {源语言:};
\node[anchor=east] (t0) at ([xshift=0em,yshift=-3.5em]s0.east) {目标语言:};
\node[anchor=south] (s0) at ([xshift=-3em,yshift=0em]s1.south) {源语言};
\node[anchor=east] (t0) at ([xshift=0em,yshift=-3.5em]s0.east) {目标语言};
\end{scope}
\end{tikzpicture}
......
......@@ -12,12 +12,12 @@
\draw[thick] ([yshift=2em]x0.center) -- ([xshift=8em,yshift=4em]x0.center);
\node[anchor=north] (e1) at ([xshift=6em,yshift=6em]x0.south) {\small{$d_1$}};
\node[anchor=north] (e2) at ([xshift=7em,yshift=4em]x0.south) {\small{$d_2$}};
\node[anchor=north,rotate=90] (e2) at ([xshift=-1.3em,yshift=3.6em]x0.south) {\small{model score}};
\node[anchor=north,rotate=90] (e2) at ([xshift=-1.3em,yshift=3.6em]x0.south) {\small{Score}};
}
{
\node [anchor=center,draw=red,circle,inner sep=2pt,thick] (x1) at ([xshift=4em,yshift=3em]x0.center) {};
\draw[thick,dotted] ([xshift=4em]x0.center) -- ([xshift=4em,yshift=3em]x0.center);
\draw[thick,dotted] ([xshift=4em]x0.center) -- ([xshift=4em,yshift=3.6em]x0.center);
}
\node[anchor=north] (zero) at ([yshift=0.1em]x0.south) {\small{0}};
\node[anchor=north] (wx) at ([xshift=4em,yshift=0.1em]x0.south) {\small{$w_x$}};
......
......@@ -20,7 +20,7 @@
\node[anchor=north] (e1) at ([xshift=2em,yshift=3em]x0.north) {\small{$d^*=d_1$}};
\node[anchor=north] (e2) at ([xshift=6.2em,yshift=5em]x0.north) {\small{$d^*=d_2$}};
\node[anchor=north,rotate=90] (e2) at ([xshift=-1.3em,yshift=3.6em]x0.south) {\small{BLEU}};
\node[anchor=north,rotate=90] (e2) at ([xshift=-1.3em,yshift=3em]x0.south) {\small{BLEU}};
\draw[decorate,decoration={brace,amplitude=0.4em},red,thick] ([xshift=4em,yshift=0.5em]x0.south) -- ([xshift=8.2em,yshift=0.5em]x0.south);
\node[anchor=north] (wi) at ([xshift=6.1em,yshift=2.1em]x0.south) {\footnotesize{\red{挑选$w_i$}}};
}
......
\begin{tikzpicture}
\begin{scope}[scale=0.62]
{\tiny
\draw[step=1,help lines,color=black] (0,0) grid (4,4);
\node[anchor=north] (y2) at (-5.3em,1.5) {0.01};
\node[anchor=north] (y1) at ([xshift=0em,yshift=-3.3em]y2.south) {0.00};
\node[anchor=north] (y3) at ([xshift=0em,yshift=4.5em]y2.north) {0.02};
\node[anchor=north] (y4) at ([xshift=0em,yshift=6.6em]y3.north) {$\vdots$};
\node[anchor=north] (y5) at ([xshift=0em,yshift=2em]y4.north) {1.00};
\node[anchor=north] (x1) at (1em,-3em) {$\lambda_1$};
\node[anchor=north] (x2) at ([xshift=4.5em,yshift=0em]x1.north) {$\lambda_2$};
\node[anchor=north] (x3) at ([xshift=4em,yshift=-1em]x2.north) {$...$};
\node[anchor=north] (x4) at ([xshift=5em,yshift=1em]x3.north) {$\lambda_{M-1}$};
\node[anchor=north] (x5) at ([xshift=5em,yshift=0em]x4.north) {$\lambda_M$};
\draw [-](n1) (0,4) -- (0,4.4);
\draw [-](n2) (1,4) -- (1,4.4);
\draw [-](n3) (2,4) -- (2,4.4);
\draw [-](n4) (3,4) -- (3,4.4);
\draw [-](n5) (4,4) -- (4,4.4);
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r31) at (2,4) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r32) at (2,0) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r33) at (2,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r34) at (2,3) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r35) at (2,1) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (f11) at ([xshift=0em,yshift=23em]y2.north) {};
\node[anchor=south] (f12) at ([xshift=8.5em,yshift=-1em]f11.south) {\scriptsize{固定的权重}};
\node [anchor=center,draw,circle,inner sep=1.5pt,ugreen!50,fill=ugreen!50] (f21) at ([xshift=0em,yshift=-4em]f11.north) {};
\node[anchor=south] (f22) at ([xshift=8.5em,yshift=-1em]f21.south) {\scriptsize{有效取值点}};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (f31) at ([xshift=0em,yshift=-4em]f21.north) {};
\node[anchor=south] (f32) at ([xshift=8.5em,yshift=-1em]f31.south) {\scriptsize{无效取值点}};
\draw [-,very thick,red!50, dashed] (1,2) -- (2,4) -- (3,2) -- (2,3) -- (1,2) -- (3,2) -- (2,1) -- (1,2) -- (2,0) -- (3,2);
\draw [-,very thick,blue!50] (0,1) -- (1,2);
\draw [-,very thick,blue!50] (3,2) -- (4,4);
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r11) at (0,1) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r12) at (1,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r14) at (3,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r15) at (4,4) {};
}
\end{scope}
\begin{scope}[scale=0.62,xshift=3in]
{\tiny
\draw[step=1,help lines,color=black] (0,0) grid (4,4);
\node[anchor=north] (y2) at (-5.3em,1.5) {0.01};
\node[anchor=north] (y1) at ([xshift=0em,yshift=-3.3em]y2.south) {0.00};
\node[anchor=north] (y3) at ([xshift=0em,yshift=4.5em]y2.north) {0.02};
\node[anchor=north] (y4) at ([xshift=0em,yshift=6.6em]y3.north) {$\vdots$};
\node[anchor=north] (y5) at ([xshift=0em,yshift=2em]y4.north) {1.00};
\node[anchor=north] (x1) at (1em,-3em) {$\lambda_1$};
\node[anchor=north] (x2) at ([xshift=4.5em,yshift=0em]x1.north) {$\lambda_2$};
\node[anchor=north] (x3) at ([xshift=4em,yshift=-1em]x2.north) {$...$};
\node[anchor=north] (x4) at ([xshift=5em,yshift=1em]x3.north) {$\lambda_{M-1}$};
\node[anchor=north] (x5) at ([xshift=5em,yshift=0em]x4.north) {$\lambda_M$};
\draw [-](n1) (0,4) -- (0,4.4);
\draw [-](n2) (1,4) -- (1,4.4);
\draw [-](n3) (2,4) -- (2,4.4);
\draw [-](n4) (3,4) -- (3,4.4);
\draw [-](n5) (4,4) -- (4,4.4);
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r31) at (2,4) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r32) at (2,0) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r33) at (2,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r35) at (2,1) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,ugreen!50,fill=ugreen!50] (r34) at (2,3) {};
\draw [-,very thick,red!50, dashed] (1,2) -- (2,4) -- (3,2) -- (2,3) -- (1,2) -- (3,2) -- (2,1) -- (1,2) -- (2,0) -- (3,2);
\draw [-,very thick,blue!50] (0,1) -- (1,2);
\draw [-,very thick,blue!50] (3,2) -- (4,4);
\draw [-,very thick,ugreen!50, dashed] (1,2) -- (2,3) -- (3,2);
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r11) at (0,1) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r12) at (1,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r14) at (3,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r15) at (4,4) {};
}
\end{scope}
\end{tikzpicture}
\ No newline at end of file
......@@ -62,7 +62,7 @@
\begin{scope}[xshift = 1.5in, yshift = 1.3in]
{\scriptsize
\node (rules) {\textbf{抽取得到的短语:}};
\node (rules) {\textbf{抽取得到的短语}};
\draw[-] (rules.south west)--([xshift=2.0in]rules.south west);
{
......
......@@ -50,11 +50,11 @@
{
\node [anchor=west] (p1line1) at ([xshift=4em,yshift=1em]a75.east) {\footnotesize{$\bar{s}_i$: 天气\ \ \ \ \ \ }};
\node [anchor=north west] (p1line2) at ([xshift=0]p1line1.south west) {\footnotesize{$\bar{t}_i$: The\ \ \ weather\ \ \ \ \ }};
\node [anchor=west] (p1line1) at ([xshift=4em,yshift=1em]a75.east) {\footnotesize{$\bar{s}_i$ 天气\ \ \ \ \ \ }};
\node [anchor=north west] (p1line2) at ([xshift=0]p1line1.south west) {\footnotesize{$\bar{t}_i$ The\ \ \ weather\ \ \ \ \ }};
\node [anchor=west] (p2line1) at ([xshift=4em]a72.east) {\footnotesize{$\bar{s}_j$:\ \ \ \ \ }};
\node [anchor=north west] (p2line2) at ([xshift=0]p2line1.south west) {\footnotesize{$\bar{t}_j$: very\ \ \ good\ \ \ \ \ \ \ \ }};
\node [anchor=west] (p2line1) at ([xshift=4em]a72.east) {\footnotesize{$\bar{s}_j$\ \ \ \ \ }};
\node [anchor=north west] (p2line2) at ([xshift=0]p2line1.south west) {\footnotesize{$\bar{t}_j$ very\ \ \ good\ \ \ \ \ \ \ \ }};
\node [anchor=east] (p2line3) at ([xshift=0em,yshift=-4em]p1line2.east) {};
\begin{pgfonlayer}{background}
......
......@@ -5,7 +5,7 @@
\begin{scope}[minimum height = 20pt]
\node[anchor=east] (s0) at (-0.5em, 0) {$\textbf{s}$:};
\node[anchor=east] (s0) at (-0.5em, 0) {$\seq{s}$};
\node[anchor=west,fill=green!20] (s1) at (0, 0) {\small{\ \ 桌子\ \ \ \ \;}};
\node[anchor=south] (n1) at ([xshift=-2.5em,yshift=-0.5em]s1.north) {\small{1}};
\node[anchor=south] (n2) at ([xshift=-0.7em,yshift=-0.5em]s1.north) {\small{2}};
......@@ -14,7 +14,7 @@
\node[anchor=west,fill=red!20] (s2) at ([xshift=1em]s1.east) {\small{苹果}};
\node[anchor=south] (n5) at ([yshift=-0.5em]s2.north) {\small{5}};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\textbf{t}$:};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\seq{t}$};
\node[anchor=west,fill=red!20] (t1) at (0, -1.5) {\small{the apple}};
\node[anchor=west,fill=green!20] (t2) at ([xshift=1.3em]t1.east) {\small{on the table}};
......
......@@ -5,11 +5,11 @@
\begin{scope}[minimum height = 20pt]
\node[anchor=east] (s0) at (-0.5em, 0) {$\textbf{s}$:};
\node[anchor=east] (s0) at (-0.5em, 0) {$\seq{s}$};
\node[anchor=west,fill=green!20] (s1) at (0, 0) {\footnotesize{在 桌子 上 的}};
\node[anchor=west,fill=red!20] (s2) at ([xshift=1em]s1.east) {\footnotesize{苹果}};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\textbf{t}$:};
\node[anchor=east] (t0) at (-0.5em, -1.5) {$\seq{t}$};
\node[anchor=west,fill=red!20] (t1) at (0, -1.5) {\footnotesize{the apple}};
\node[anchor=west,fill=green!20] (t2) at ([xshift=1em]t1.east) {\footnotesize{on the table}};
......
\begin{tikzpicture}
\begin{scope}[scale=0.55]
{\tiny
\draw[step=1,help lines,color=black] grid (4,4);
\draw [-](n1) (0,4) -- (0,4.4);
\draw [-](n2) (1,4) -- (1,4.4);
\draw [-](n3) (2,4) -- (2,4.4);
\draw [-](n4) (3,4) -- (3,4.4);
\draw [-](n5) (4,4) -- (4,4.4);
\node[anchor=north] (y2) at (-5.3em,1.5) {0.01};
\node[anchor=north] (y1) at ([xshift=0em,yshift=-3.3em]y2.south) {0.00};
\node[anchor=north] (y3) at ([xshift=0em,yshift=4.5em]y2.north) {0.02};
\node[anchor=north] (y4) at ([xshift=0em,yshift=6.6em]y3.north) {$\vdots$};
\node[anchor=north] (y5) at ([xshift=0em,yshift=2em]y4.north) {1.00};
\node[anchor=north] (x1) at (1em,-3em) {$\lambda_1$};
\node[anchor=north] (x2) at ([xshift=4.5em,yshift=0em]x1.north) {$\lambda_2$};
\node[anchor=north] (x3) at ([xshift=4em,yshift=-1em]x2.north) {$...$};
\node[anchor=north] (x4) at ([xshift=5em,yshift=1em]x3.north) {$\lambda_{M-1}$};
\node[anchor=north] (x5) at ([xshift=5em,yshift=0em]x4.north) {$\lambda_M$};
\draw[decorate,decoration={brace}](0,4.7) --(4,4.7) node [xshift=-4em,yshift=1.5em,align=center](label1) {M个特征函数};
\draw[decorate,decoration={brace}](4.5,4.3) --(4.5,0) node [xshift=2.3em,yshift=6.8em,align=center](label2) {V种};
\node[anchor=north] (label3) at ([xshift=0em,yshift=-2.5em]label2.north) {取值};
}
\end{scope}
\begin{scope}[scale=0.55,xshift=3.2in]
{\tiny
\draw[step=1,help lines,color=black] grid (4,4);
\node[anchor=north] (y2) at (-5.3em,1.5) {0.01};
\node[anchor=north] (y1) at ([xshift=0em,yshift=-3.3em]y2.south) {0.00};
\node[anchor=north] (y3) at ([xshift=0em,yshift=4.5em]y2.north) {0.02};
\node[anchor=north] (y4) at ([xshift=0em,yshift=6.6em]y3.north) {$\vdots$};
\node[anchor=north] (y5) at ([xshift=0em,yshift=2em]y4.north) {1.00};
\node[anchor=north] (x1) at (1em,-3em) {$\lambda_1$};
\node[anchor=north] (x2) at ([xshift=4.5em,yshift=0em]x1.north) {$\lambda_2$};
\node[anchor=north] (x3) at ([xshift=4em,yshift=-1em]x2.north) {$...$};
\node[anchor=north] (x4) at ([xshift=5em,yshift=1em]x3.north) {$\lambda_{M-1}$};
\node[anchor=north] (x5) at ([xshift=5em,yshift=0em]x4.north) {$\lambda_M$};
\draw [-](n1) (0,4) -- (0,4.4);
\draw [-](n2) (1,4) -- (1,4.4);
\draw [-](n3) (2,4) -- (2,4.4);
\draw [-](n4) (3,4) -- (3,4.4);
\draw [-](n5) (4,4) -- (4,4.4);
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r11) at (0,1) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r12) at (1,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r13) at (2,1) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r14) at (3,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r15) at (4,4) {};
\draw [-,very thick,blue!50] (0,1) -- (1,2) -- (2,1) -- (3,2) -- (4,4);
\node[anchor=north] (p1) at (5.7,4.3) {\scriptsize{$\leftarrow$ \textbf{path}:}};
\node[anchor=north] (e1) at ([xshift=0,yshift=-0.4em]p1.south) {$w_1 = 0.01$};
\node[anchor=north] (e2) at ([xshift=0,yshift=-0.8em]e1.south) {$w_2 = 0.02$};
\node[anchor=north] (e3) at ([xshift=0,yshift=0.4em]e2.south) {$\vdots$};
\node[anchor=north] (e4) at ([xshift=0,yshift=-0.2em]e3.south) {$w_M = 1.00$};
}
\end{scope}
\begin{scope}[scale=0.55,xshift=6.8in]
{\tiny
\draw[step=1,help lines,color=black] grid (4,4);
\node[anchor=north] (y2) at (-5.3em,1.5) {0.01};
\node[anchor=north] (y1) at ([xshift=0em,yshift=-3.3em]y2.south) {0.00};
\node[anchor=north] (y3) at ([xshift=0em,yshift=4.5em]y2.north) {0.02};
\node[anchor=north] (y4) at ([xshift=0em,yshift=6.6em]y3.north) {$\vdots$};
\node[anchor=north] (y5) at ([xshift=0em,yshift=2em]y4.north) {1.00};
\node[anchor=north] (x1) at (1em,-3em) {$\lambda_1$};
\node[anchor=north] (x2) at ([xshift=4.5em,yshift=0em]x1.north) {$\lambda_2$};
\node[anchor=north] (x3) at ([xshift=4em,yshift=-1em]x2.north) {$...$};
\node[anchor=north] (x4) at ([xshift=5em,yshift=1em]x3.north) {$\lambda_{M-1}$};
\node[anchor=north] (x5) at ([xshift=5em,yshift=0em]x4.north) {$\lambda_M$};
\draw [-](n1) (0,4) -- (0,4.4);
\draw [-](n2) (1,4) -- (1,4.4);
\draw [-](n3) (2,4) -- (2,4.4);
\draw [-](n4) (3,4) -- (3,4.4);
\draw [-](n5) (4,4) -- (4,4.4);
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r11) at (0,1) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r12) at (1,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r13) at (2,1) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r14) at (3,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,blue!30,fill=blue!30] (r15) at (4,4) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,ugreen!30,fill=ugreen!30] (r21) at (0,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,ugreen!30,fill=ugreen!30] (r22) at (1,3) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,ugreen!30,fill=ugreen!30] (r23) at (2,4) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,ugreen!30,fill=ugreen!30] (r24) at (3,0) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,ugreen!30,fill=ugreen!30] (r25) at (4,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r31) at (0,4) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r32) at (1,3) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r33) at (2,2) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r34) at (3,3) {};
\node [anchor=center,draw,circle,inner sep=1.5pt,red!30,fill=red!30] (r35) at (4,1) {};
\draw [-,very thick,blue!50] (0,1) -- (1,2) -- (2,1) -- (3,2) -- (4,4);
\draw [-,very thick,ugreen!50] (0,2) -- (1,3) -- (2,4) -- (3,0) -- (4,2);
\draw [-,very thick,red!50] (0,4) -- (1,3) -- (2,2) -- (3,3) -- (4,1);
\draw[decorate,decoration={brace}](4.5,4.3) --(4.5,0) node [xshift=2.3em,yshift=6.5em,align=center](label1) {$M^V$};
\node[anchor=north] (label2) at ([xshift=0em,yshift=-2.5em]label1.north) {种组合};
}
\end{scope}
\end{tikzpicture}
\ No newline at end of file
......@@ -6,7 +6,7 @@
{
\node [anchor=north,inner sep=2pt,fill=red!20,minimum height=2em,minimum width=3.5em] (h0) at (0,0) {\small{null}};
\node [anchor=north west,inner sep=1.5pt,fill=black] (hl0) at (h0.north west) {\scriptsize{{\color{white} \textbf{0}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt0) at (h0.east) {\footnotesize{{\color{white} \textbf{P=1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt0) at (h0.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=1}}}};
}
{
......@@ -16,8 +16,8 @@
\node [anchor=north west,inner sep=1.5pt,fill=black] (hl1) at (h1.north west) {\scriptsize{{\color{white} \textbf{2}}}};
\node [anchor=north west,inner sep=1.5pt,fill=black] (hl2) at (h2.north west) {\scriptsize{{\color{white} \textbf{1}}}};
\node [anchor=north west,inner sep=1.5pt,fill=black] (hl3) at (h3.north west) {\scriptsize{{\color{white} \textbf{3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt1) at (h1.east) {\footnotesize{{\color{white} \textbf{P=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt2) at (h2.east) {\footnotesize{{\color{white} \textbf{P=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt1) at (h1.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt2) at (h2.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt3) at (h3.east) {\footnotesize{{\color{white} \textbf{P=.5}}}};
\draw [->,very thick,ublue] ([xshift=0.1em]pt0.south) -- ([xshift=-0.1em]h1.west);
......@@ -38,11 +38,11 @@
\node [anchor=north west,inner sep=1.5pt,fill=black] (hl7) at (h7.north west) {\scriptsize{{\color{white} \textbf{1-2}}}};
\node [anchor=north west,inner sep=1.5pt,fill=black] (hl8) at (h8.north west) {\scriptsize{{\color{white} \textbf{5}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt4) at (h4.east) {\footnotesize{{\color{white} \textbf{P=.1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt5) at (h5.east) {\footnotesize{{\color{white} \textbf{P=.4}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt6) at (h6.east) {\footnotesize{{\color{white} \textbf{P=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt7) at (h7.east) {\footnotesize{{\color{white} \textbf{P=.4}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt8) at (h8.east) {\footnotesize{{\color{white} \textbf{P=.2}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt4) at (h4.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.1}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt5) at (h5.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.4}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt6) at (h6.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.3}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt7) at (h7.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.4}}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2em,fill=black] (pt8) at (h8.east) {\footnotesize{{\color{white} \textbf{$\funp{P}$=.2}}}};
\draw [->,very thick,ublue] ([xshift=0.1em]pt1.south) -- ([xshift=1em,yshift=0.7em]pt1.south);
......@@ -65,7 +65,7 @@
{
\draw [->,ultra thick,red,line width=2pt,opacity=0.7] ([xshift=-0.5em]h0.west) -- ([xshift=0.7em]h0.east) -- ([xshift=-0.2em]h3.west) -- ([xshift=0.8em]h3.east) -- ([xshift=-0.2em]h5.west) -- ([xshift=0.8em]h5.east) -- ([xshift=-0.2em]h7.west) -- ([xshift=1.5em]h7.east);
\node [anchor=north west] (wtranslabel) at ([yshift=-3em]h0.south west) {\small{翻译路径:}};
\node [anchor=north west] (wtranslabel) at ([yshift=-3em]h0.south west) {\small{翻译路径}};
\draw [->,ultra thick,red,line width=1.5pt,opacity=0.7] (wtranslabel.east) -- ([xshift=1.5em]wtranslabel.east);
}
\end{scope}
......
......@@ -4,7 +4,7 @@
\begin{tikzpicture}
\begin{scope}[minimum height = 16pt]
\node[anchor=east] (s0) at (-0.8em, 0) {$\textbf{s}$:};
\node[anchor=east] (s0) at (-0.8em, 0) {$\textbf{s}$};
\node[anchor=west] (s1) at (0, 0) {桌子};
\node[anchor=west] (s2) at ([xshift=2em]s1.east) {};
\node[anchor=west] (s3) at ([xshift=2.3em]s2.east) {};
......
......@@ -41,11 +41,11 @@
\node[tgtnode] (tgt7) at ([yshift=-0.5*1.0cm]tgt6.north east) {\scriptsize{?}};
\node[tgtnode] (tgt8) at ([yshift=-0.5*1.0cm]tgt7.north east) {\scriptsize{EOS}};
\node [anchor=west] (p1line1) at ([xshift=4em,yshift=1em]a57.east) {\footnotesize{$\bar{s}_i$: 什么\ \ \ \ \ \ }};
\node [anchor=north west] (p1line2) at ([xshift=0]p1line1.south west) {\footnotesize{$\bar{t}_i$: learned\ \ \ nothing\ \ \ ? \ \ \ \ \ \ \ \ \ \ \ \ }};
\node [anchor=west] (p1line1) at ([xshift=4em,yshift=1em]a57.east) {\footnotesize{$\bar{s}_i$ 什么\ \ \ \ \ \ }};
\node [anchor=north west] (p1line2) at ([xshift=0]p1line1.south west) {\footnotesize{$\bar{t}_i$ learned\ \ \ nothing\ \ \ ? \ \ \ \ \ \ \ \ \ \ \ \ }};
\node [anchor=west] (p2line1) at ([xshift=4em]a53.east) {\footnotesize{$\bar{s}_j$:\ \ \ ?}};
\node [anchor=north west] (p2line2) at ([xshift=0]p2line1.south west) {\footnotesize{$\bar{t}_j$: Have\ \ \ you\ \ \ learned\ \ \ nothing}};
\node [anchor=west] (p2line1) at ([xshift=4em]a53.east) {\footnotesize{$\bar{s}_j$\ \ \ ?}};
\node [anchor=north west] (p2line2) at ([xshift=0]p2line1.south west) {\footnotesize{$\bar{t}_j$ Have\ \ \ you\ \ \ learned\ \ \ nothing}};
\node [anchor=east] (p1line3) at ([xshift=0em,yshift=2.9cm]p2line2.east) {};
\begin{pgfonlayer}{background}
......
......@@ -10,7 +10,7 @@
\node [anchor=west] (s4) at ([xshift=2em]s3.east) {\textbf{表示}};
\node [anchor=west] (s5) at ([xshift=2em]s4.east) {\textbf{满意}};
\node [anchor=south west] (sentlabel) at ([yshift=-0.5em]s1.north west) {\scriptsize{\textbf{待翻译句子(已经分词):}}};
\node [anchor=south west] (sentlabel) at ([yshift=-0.5em]s1.north west) {\scriptsize{\textbf{待翻译句子(已经分词):}}};
\draw [->,very thick,ublue] (s1.south) -- ([yshift=-0.7em]s1.south);
\draw [->,very thick,ublue] (s2.south) -- ([yshift=-0.7em]s2.south);
......@@ -80,38 +80,38 @@
{\tiny
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt11) at (t11.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt12) at (t12.east) {{\color{white} \textbf{P=.2}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt13) at (t13.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt11) at (t11.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt12) at (t12.east) {{\color{white} \textbf{$\funp{P}$=.2}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt13) at (t13.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
{
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt14) at (t14.east) {{\color{white} \textbf{P=.1}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt15) at (t15.east) {{\color{white} \textbf{P=.2}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt14) at (t14.east) {{\color{white} \textbf{$\funp{P}$=.1}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt15) at (t15.east) {{\color{white} \textbf{$\funp{P}$=.2}}};
}
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt21) at (t21.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt22) at (t22.east) {{\color{white} \textbf{P=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt23) at (t23.east) {{\color{white} \textbf{P=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt21) at (t21.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt22) at (t22.east) {{\color{white} \textbf{$\funp{P}$=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt23) at (t23.east) {{\color{white} \textbf{$\funp{P}$=.3}}};
{
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt24) at (t24.east) {{\color{white} \textbf{P=.2}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt25) at (t25.east) {{\color{white} \textbf{P=.1}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt24) at (t24.east) {{\color{white} \textbf{$\funp{P}$=.2}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt25) at (t25.east) {{\color{white} \textbf{$\funp{P}$=.1}}};
}
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt31) at (t31.east) {{\color{white} \textbf{P=1}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt31) at (t31.east) {{\color{white} \textbf{$\funp{P}$=1}}};
{
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt33) at (t32.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt33) at (t33.east) {{\color{white} \textbf{P=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt33) at (t32.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt33) at (t33.east) {{\color{white} \textbf{$\funp{P}$=.3}}};
}
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt41) at (t41.east) {{\color{white} \textbf{P=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt42) at (t42.east) {{\color{white} \textbf{P=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt41) at (t41.east) {{\color{white} \textbf{$\funp{P}$=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt42) at (t42.east) {{\color{white} \textbf{$\funp{P}$=.5}}};
{
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt43) at (t43.east) {{\color{white} \textbf{P=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt44) at (t44.east) {{\color{white} \textbf{P=.2}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt43) at (t43.east) {{\color{white} \textbf{$\funp{P}$=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt44) at (t44.east) {{\color{white} \textbf{$\funp{P}$=.2}}};
}
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt51) at (t51.east) {{\color{white} \textbf{P=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt52) at (t52.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt53) at (t53.east) {{\color{white} \textbf{P=.1}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt51) at (t51.east) {{\color{white} \textbf{$\funp{P}$=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt52) at (t52.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt53) at (t53.east) {{\color{white} \textbf{$\funp{P}$=.1}}};
}
......@@ -143,13 +143,13 @@
}
{
\node [anchor=north west] (wtranslabel) at ([yshift=-4em]t15.south west) {\scriptsize{翻译路径(仅含有单词):}};
\draw [->,ultra thick,red,line width=1.5pt,opacity=0.7] (wtranslabel.east) -- ([xshift=1em]wtranslabel.east);
\node [anchor=north west] (wtranslabel) at ([yshift=-4em]t15.south west) {\scriptsize{翻译路径(仅含有单词)}};
\draw [->,ultra thick,red,line width=1.5pt,opacity=0.7] ([xshift=0.2em]wtranslabel.east) -- ([xshift=1.2em]wtranslabel.east);
}
{
\node [anchor=north west] (ptranslabel) at ([yshift=-5.5em]t15.south west) {\scriptsize{翻译路径(含有短语):}};
\draw [->,ultra thick,ublue,line width=1.5pt,opacity=0.7] ([xshift=0.65em]ptranslabel.east) -- ([xshift=1.65em]ptranslabel.east);
\node [anchor=north west] (ptranslabel) at ([yshift=-5.5em]t15.south west) {\scriptsize{翻译路径(含有短语)}};
\draw [->,ultra thick,ublue,line width=1.5pt,opacity=0.7] ([xshift=0.95em]ptranslabel.east) -- ([xshift=1.95em]ptranslabel.east);
}
\end{scope}
......
......@@ -10,7 +10,7 @@
\node [anchor=west] (s4) at ([xshift=2em]s3.east) {\textbf{表示}};
\node [anchor=west] (s5) at ([xshift=2em]s4.east) {\textbf{满意}};
\node [anchor=south west] (sentlabel) at ([yshift=-0.5em]s1.north west) {\scriptsize{\textbf{待翻译句子(已经分词):}}};
\node [anchor=south west] (sentlabel) at ([yshift=-0.5em]s1.north west) {\scriptsize{\textbf{待翻译句子(已经分词):}}};
\draw [->,very thick,ublue] (s1.south) -- ([yshift=-0.7em]s1.south);
\draw [->,very thick,ublue] (s2.south) -- ([yshift=-0.7em]s2.south);
......@@ -52,22 +52,22 @@
{\tiny
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt11) at (t11.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt12) at (t12.east) {{\color{white} \textbf{P=.2}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt13) at (t13.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt11) at (t11.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt12) at (t12.east) {{\color{white} \textbf{$\funp{P}$=.2}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt13) at (t13.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt21) at (t21.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt22) at (t22.east) {{\color{white} \textbf{P=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt23) at (t23.east) {{\color{white} \textbf{P=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt21) at (t21.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt22) at (t22.east) {{\color{white} \textbf{$\funp{P}$=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt23) at (t23.east) {{\color{white} \textbf{$\funp{P}$=.3}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt31) at (t31.east) {{\color{white} \textbf{P=1}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt31) at (t31.east) {{\color{white} \textbf{$\funp{P}$=1}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt41) at (t41.east) {{\color{white} \textbf{P=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt42) at (t42.east) {{\color{white} \textbf{P=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt41) at (t41.east) {{\color{white} \textbf{$\funp{P}$=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt42) at (t42.east) {{\color{white} \textbf{$\funp{P}$=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt51) at (t51.east) {{\color{white} \textbf{P=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt52) at (t52.east) {{\color{white} \textbf{P=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt53) at (t53.east) {{\color{white} \textbf{P=.1}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt51) at (t51.east) {{\color{white} \textbf{$\funp{P}$=.5}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt52) at (t52.east) {{\color{white} \textbf{$\funp{P}$=.4}}};
\node [anchor=north,rotate=90,inner sep=1pt,minimum width=2.55em,fill=black] (pt53) at (t53.east) {{\color{white} \textbf{$\funp{P}$=.1}}};
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -23,12 +23,55 @@
\chapter{基于句法的模型}
人类的语言是具有结构的,这种结构往往体现在句子的句法信息上。比如,人们在翻译一个句子的时候会将待翻译的主干确定下来,之后得到译文的主干,最后形成完整的译文。一个人学习外语时,也会先学习外语句子的基本构成,比如,主语、谓语等。之后用这种句子结构知识生成外语句子。
使用句法分析也可以很好的处理翻译中的结构调序、远距离依赖等问题。而基于句法的机器翻译长期受到研究者关注。比如,早期基于规则的方法里就大量使用了句法信息来定义翻译规则。机器翻译的统计建模时代,句法信息的使用同样是领域主要研究方向之一。这也产生了很多基于句法的机器翻译模型及方法,而且在很多任务上取得非常出色的结果。本章将对这些模型和方法进行介绍,内容涉及机器翻译中句法信息的表示、句法翻译规则的学习、基于句法的翻译建模等。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\sectionnewpage
\section{翻译中句法信息的使用}
\parinterval 使用短语的优点在于可以捕捉具有完整意思的连续词串,因此能够对局部上下文信息进行建模。当单词之间的搭配和依赖关系出现在连续词串中时,短语可以很好地对其进行描述。但是,当单词之间距离很远时,使用短语的``效率''很低。同$n$-gram语言模型一样,当短语长度变长时,数据会变得非常稀疏。比如,很多实验已经证明,测试数据中超过5个的连续单词在训练数据中往往是很低频的现象,更长的短语甚至都很难在训练数据中找到。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter7/Figures/figure-long-distance-dependence-in-zh2en-translation}
\caption{汉英翻译中的长距离依赖}
\label{fig:7-6}
\end{figure}
%-------------------------------------------
\parinterval 当然,可以使用平滑算法对长短语的概率进行估计,但是使用过长的短语在实际系统研发中仍然不现实。图\ref{fig:7-6}展示了一个汉语到英语的翻译实例。源语言的两个短语(蓝色和红色高亮)在译文中产生了调序。但是,这两个短语在源语言句子中横跨11个单词。如果直接使用这个11个单词构成的短语进行翻译,显然会有非常严重的数据稀疏问题,因为很难期望在训练数据中见到一模一样的短语。
\parinterval 如果仅仅使用连续词串不能处理所有的翻译问题,根本的原因在于句子的表层串很难描述片段之间大范围的依赖。一个新的思路是使用句子的结构信息进行建模。第二章已经介绍了句子的句法表示形式。对于每个句子,都可以用句法树描述它的结构。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter7/Figures/figure-chinese-syntax-tree}
\caption{一个英文句法树(短语结构树)}
\label{fig:7-7}
\end{figure}
%-------------------------------------------
\parinterval\ref{fig:7-7}就展示了一棵英文句法树(短语结构树)。句法树描述了一种递归的结构,每个句法结构都可以用一个子树来描述,子树之间的组合可以构成更大的子树,最终完成整个句子的表示。相比线性的序列模型,树结构更容易处理大片段之间的关系。比如,两个在序列中距离``很远''的单词,在树结构中可能会``很近''。
%----------------------------------------------
\begin{figure}[htp]
\centering
\input{./Chapter7/Figures/figure-example-of-translation-use-syntactic-structure}
\caption{使用句法结构进行机器翻译的实例}
\label{fig:7-8}
\end{figure}
%-------------------------------------------
\parinterval 句法树结构可以赋予机器翻译一种对语言进一步抽象的能力,这样,并不需要使用连续词串,而是通过句法结构来对大范围的译文生成和调序进行建模。图\ref{fig:7-8}是一个在翻译中融入源语言(中文)句法信息的实例。这个例子中,介词短语包含15个单词,因此,使用短语很难涵盖``在 $...$ 后''这样的片段。这时,系统会把``在 $...$ 后''错误的翻译为``In $...$''。通过句法树,可以知道``在 $...$ 后''对应着一个完整的子树结构PP(介词短语)。因此也很容易知道介词短语中``在 $...$ 后''是一个模板(红色),而``在''和``后''之间的部分构成从句部分(蓝色)。最终得到正确的译文``After $...$''。
\parinterval 使用句法信息在机器翻译中不新鲜。在基于规则和模板的翻译模型中,就大量地使用了句法等结构信息。只是由于早期句法分析技术不成熟,系统的整体效果并不突出。在数据驱动的方法中,句法可以很好地融合在统计建模中。通过概率化的文法设计,可以对翻译过程进行很好的描述。
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
......
......@@ -172,26 +172,56 @@
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{IBM模型2训练方法}
IBM模型2与模型1的训练过程完全一样,本质上都是EM方法,因此可以直接复用{\chapterfive}中训练模型1的流程。对于句对$(\mathbf{s},\mathbf{t})$$m=|\mathbf{s}|$$l=|\mathbf{t}|$,E-Step的计算公式如下,其中参数$f(s_j|t_i)$与IBM模型1 一样:
\begin{eqnarray}
c(s_u|t_v;\mathbf{s},\mathbf{t}) &=&\sum\limits_{j=1}^{m} \sum\limits_{i=0}^{l} \frac{f(s_u|t_v)a(i|j,m,l) \delta(s_j,s_u)\delta (t_i,t_v) } {\sum_{k=0}^{l} f(s_u|t_k)a(k|j,m,l)} \\
c(i|j,m,l;\mathbf{s},\mathbf{t}) &=&\frac{f(s_j|t_i)a(i|j,m,l)} {\sum_{k=0}^{l} f(s_j|t_k)a(k,j,m,l)}
\label{eq:append-1}
\end{eqnarray}
\parinterval M-Step的计算公式如下,其中参数$a(i|j,m,l)$表示调序概率:
\begin{eqnarray}
f(s_u|t_v) &=\frac{c(s_u|t_v;\mathbf{s},\mathbf{t}) } {\sum_{s_u} c(s_u|t_v;\mathbf{s},\mathbf{t})} \\
a(i|j,m,l) &=\frac{c(i|j;\mathbf{s},\mathbf{t})} {\sum_{i}c(i|j;\mathbf{s},\mathbf{t})}
\label{eq:append-2}
\end{eqnarray}
对于由$K$个样本组成的训练集$\{(\mathbf{s}^{[1]},\mathbf{t}^{[1]}),...,(\mathbf{s}^{[K]},\mathbf{t}^{[K]})\}$,可以将M-Step的计算调整为:
\begin{eqnarray}
f(s_u|t_v) &=\frac{\sum_{k=0}^{K}c_{\mathbb{E}}(s_u|t_v;\mathbf{s}^{[k]},\mathbf{t}^{[k]}) } {\sum_{s_u} \sum_{k=1}^{K} c_{\mathbb{E}}(s_u|t_v;\mathbf{s}^{[k]},\mathbf{t}^{[k]})} \\
a(i|j,m,l) &=\frac{\sum_{k=0}^{K}c_{\mathbb{E}}(i|j;\mathbf{s}^{[k]},\mathbf{t}^{[k]})} {\sum_{i}\sum_{k=1}^{K}c_{\mathbb{E}}(i|j;\mathbf{s}^{[k]},\mathbf{t}^{[k]})}
\label{eq:append-3}
\end{eqnarray}
%----------------------------------------------------------------------------------------
% NEW SECTION
%----------------------------------------------------------------------------------------
\section{IBM模型3训练方法}
\parinterval 模型3的参数估计与模型1和模型2采用相同的方法。这里直接给出辅助函数。
\parinterval IBM模型3的参数估计与模型1和模型2采用相同的方法。这里直接给出辅助函数。
\begin{eqnarray}
h(t,d,n,p, \lambda,\mu, \nu, \zeta) & = & \textrm{P}_{\theta}(\mathbf{s}|\mathbf{t})-\sum_{t}\lambda_{t}\big(\sum_{s}t(s|t)-1\big) \nonumber \\
h(t,d,n,p, \lambda,\mu, \nu, \zeta) & = & \funp{P}_{\theta}(\mathbf{s}|\mathbf{t})-\sum_{t}\lambda_{t}\big(\sum_{s}t(s|t)-1\big) \nonumber \\
& & -\sum_{i}\mu_{iml}\big(\sum_{j}d(j|i,m,l)-1\big) \nonumber \\
& & -\sum_{t}\nu_{t}\big(\sum_{\varphi}n(\varphi|t)-1\big)-\zeta(p^0+p^1-1)
\label{eq:1.1}
\end{eqnarray}
\parinterval 由于篇幅所限这里略去了推导步骤直接给出一些用于参数估计的等式。
\parinterval 由于篇幅所限这里略去了推导步骤直接给出具体公式。
\begin{eqnarray}
c(s|t,\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\textrm{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \sum_{j=1}^{m} (\delta(s_j,s) \cdot \delta(t_{a_{j}},t))\big] \label{eq:1.2} \\
c(j|i,m,l;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\textrm{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \delta(i,a_j)\big] \label{eq:1.3} \\
c(\varphi|t;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\textrm{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \sum_{i=1}^{l}\delta(\varphi,\varphi_{i})\delta(t,t_i)\big]
c(s|t,\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\funp{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \sum_{j=1}^{m} (\delta(s_j,s) \cdot \delta(t_{a_{j}},t))\big] \label{eq:1.2} \\
c(j|i,m,l;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\funp{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \delta(i,a_j)\big] \label{eq:1.3} \\
c(\varphi|t;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\funp{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \sum_{i=1}^{l}\delta(\varphi,\varphi_{i})\delta(t,t_i)\big]
\label{eq:1.4}
\end{eqnarray}
\begin{eqnarray}
c(0|\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\textrm{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times (m-2\varphi_0) \big] \label{eq:1.5} \\
c(1|\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\textrm{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \varphi_0 \big] \label{eq:1.6}
c(0|\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\funp{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times (m-2\varphi_0) \big] \label{eq:1.5} \\
c(1|\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\funp{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \varphi_0 \big] \label{eq:1.6}
\end{eqnarray}
\parinterval 进一步,对于由$K$个样本组成的训练集,有:
......@@ -202,9 +232,9 @@ n(\varphi|t) & = & \nu_{t}^{-1} \times \sum_{s=1}^{K}c(\varphi |t;\mathbf{s}^{[k
p_x & = & \zeta^{-1} \sum_{k=1}^{K}c(x;\mathbf{s}^{[k]},\mathbf{t}^{[k]}) \label{eq:1.10}
\end{eqnarray}
\parinterval 在模型3中,因为产出率的引入,并不能像模型1和模型2那样,在保证正确性的情况下加速参数估计的过程。这就使得每次迭代过程中,都不得不面对大小为$(l+1)^m$的词对齐空间。遍历所有$(l+1)^m$个词对齐所带来的高时间复杂度显然是不能被接受的。因此就要考虑能否仅利用词对齐空间中的部分词对齐对这些参数进行估计。比较简单且直接的方法就是仅利用Viterbi对齐来进行参数估计\footnote{Viterbi词对齐可以被简单的看作搜索到的最好词对齐。}。 遗憾的是,在模型3中并没有方法直接获得Viterbi对齐。这样只能采用一种折中的策略,即仅考虑那些使得$\textrm{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t})$达到较高值的词对齐。这里把这部分词对齐组成的集合记为$S$。式\ref{eq:1.2}可以被修改为:
\parinterval 在模型3中,因为繁衍率的引入,并不能像模型1和模型2那样,在保证正确性的情况下加速参数估计的过程。这就使得每次迭代过程中,都不得不面对大小为$(l+1)^m$的词对齐空间。遍历所有$(l+1)^m$个词对齐所带来的高时间复杂度显然是不能被接受的。因此就要考虑能否仅利用词对齐空间中的部分词对齐对这些参数进行估计。比较简单的方法是仅使用Viterbi对齐来进行参数估计,这里Viterbi 词对齐可以被简单的看作搜索到的最好词对齐。遗憾的是,在模型3中并没有方法直接获得Viterbi对齐。这样只能采用一种折中的策略,即仅考虑那些使得$\funp{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t})$ 达到较高值的词对齐。这里把这部分词对齐组成的集合记为$S$。式\ref{eq:1.2}可以被修改为:
\begin{eqnarray}
c(s|t,\mathbf{s},\mathbf{t}) \approx \sum_{\mathbf{a} \in \mathbf{S}}\big[\textrm{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \sum_{j=1}^{m}(\delta(s_j,\mathbf{s}) \cdot \delta(t_{a_{j}},\mathbf{t})) \big]
c(s|t,\mathbf{s},\mathbf{t}) \approx \sum_{\mathbf{a} \in S}\big[\funp{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times \sum_{j=1}^{m}(\delta(s_j,\mathbf{s}) \cdot \delta(t_{a_{j}},\mathbf{t})) \big]
\label{eq:1.11}
\end{eqnarray}
......@@ -217,15 +247,15 @@ S = N(b^{\infty}(V(\mathbf{s}|\mathbf{t};2))) \cup (\mathop{\cup}\limits_{ij} N(
\parinterval 为了理解这个公式,先介绍几个概念。
\begin{itemize}
\item $V(\mathbf{s}|\mathbf{t})$表示Viterbi词对齐,$V(\mathbf{s}|\mathbf{t},1)$$V(\mathbf{s}|\mathbf{t},2)$$V(\mathbf{s}|\mathbf{t},3)$就分别对应了模型1、2 和3 的Viterbi 词对齐;
\item 把那些满足第$j$个源语言单词对应第$i$个目标语言单词($a_j=i$)的词对齐构成的集合记为$\mathbf{A}_{i \leftrightarrow j}(\mathbf{s},\mathbf{t})$。通常称这些对齐中$j$$i$被``钉''在了一起。在$\mathbf{A}_{i \leftrightarrow j}(\mathbf{s},\mathbf{t})$中使$\textrm{P}(\mathbf{a}|\mathbf{s},\mathbf{t})$达到最大的那个词对齐被记为$V_{i \leftrightarrow j}(\mathbf{s},\mathbf{t})$
\item 把那些满足第$j$个源语言单词对应第$i$个目标语言单词($a_j=i$)的词对齐构成的集合记为$\mathbf{A}_{i \leftrightarrow j}(\mathbf{s},\mathbf{t})$。通常称这些对齐中$j$$i$被``钉''在了一起。在$\mathbf{A}_{i \leftrightarrow j}(\mathbf{s},\mathbf{t})$中使$\funp{P}(\mathbf{a}|\mathbf{s},\mathbf{t})$达到最大的那个词对齐被记为$V_{i \leftrightarrow j}(\mathbf{s},\mathbf{t})$
\item 如果两个词对齐,通过交换两个词对齐连接就能互相转化,则称它们为邻居。一个词对齐$\mathbf{a}$的所有邻居记为$N(\mathbf{a})$
\end{itemize}
\vspace{0.5em}
\parinterval 公式\ref{eq:1.12}中,$b^{\infty}(V(\mathbf{s}|\mathbf{t};2))$$b_{i \leftrightarrow j}^{\infty}(V_{i \leftrightarrow j}(\mathbf{s}|\mathbf{t},2))$ 分别是对 $V(\mathbf{s}|\mathbf{t};3)$$V_{i \leftrightarrow j}(\mathbf{s}|\mathbf{t},3)$ 的估计。在计算$S$的过程中,需要知道一个对齐$\bf{a}$的邻居$\bf{a}^{'}$的概率,即通过$\textrm{P}_{\theta}(\mathbf{a},\mathbf{s}|\mathbf{t})$计算$\textrm{p}_{\theta}(\mathbf{a}',\mathbf{s}|\mathbf{t})$。在模型3中,如果$\bf{a}$$\bf{a}'$仅区别于某个源语单词对齐到的目标位置上($a_j \neq a_{j}'$),那么
\parinterval 公式\ref{eq:1.12}中,$b^{\infty}(V(\mathbf{s}|\mathbf{t};2))$$b_{i \leftrightarrow j}^{\infty}(V_{i \leftrightarrow j}(\mathbf{s}|\mathbf{t},2))$ 分别是对 $V(\mathbf{s}|\mathbf{t};3)$$V_{i \leftrightarrow j}(\mathbf{s}|\mathbf{t},3)$ 的估计。在计算$S$的过程中,需要知道一个对齐$\bf{a}$的邻居$\bf{a}^{'}$的概率,即通过$\funp{P}_{\theta}(\mathbf{a},\mathbf{s}|\mathbf{t})$计算$\funp{P}_{\theta}(\mathbf{a}',\mathbf{s}|\mathbf{t})$。在模型3中,如果$\bf{a}$$\bf{a}'$仅区别于某个源语单词对齐到的目标位置上($a_j \neq a_{j}'$),那么
\begin{eqnarray}
\textrm{P}_{\theta}(\mathbf{a}',\mathbf{s}|\mathbf{t}) & = & \textrm{P}_{\theta}(\mathbf{a},\mathbf{s}|\mathbf{t}) \cdot \nonumber \\
\funp{P}_{\theta}(\mathbf{a}',\mathbf{s}|\mathbf{t}) & = & \funp{P}_{\theta}(\mathbf{a},\mathbf{s}|\mathbf{t}) \cdot \nonumber \\
& & \frac{\varphi_{i'}+1}{\varphi_i} \cdot \frac{n(\varphi_{i'}+1|t_{i'})}{n(\varphi_{i'}|t_{i'})} \cdot \frac{n(\varphi_{i}-1|t_{i})}{n(\varphi_{i}|t_{i})} \cdot \nonumber \\
& & \frac{t(s_j|t_{i'})}{t(s_{j}|t_{i})} \cdot \frac{d(j|i',m,l)}{d(j|i,m,l)}
\label{eq:1.13}
......@@ -233,7 +263,7 @@ S = N(b^{\infty}(V(\mathbf{s}|\mathbf{t};2))) \cup (\mathop{\cup}\limits_{ij} N(
\parinterval 如果$\bf{a}$$\bf{a}'$区别于两个位置$j_1$$j_2$的对齐上,$a_{j_{1}}=a_{j_{2}^{'}}$$a_{j_{2}}=a_{j_{1}^{'}}$,那么
\begin{eqnarray}
\textrm{P}_{\theta}(\mathbf{a'},\mathbf{s}|\mathbf{t}) = \textrm{P}_{\theta}(\mathbf{a},\mathbf{s}|\mathbf{t}) \cdot \frac{t(s_{j_{2}}|t_{a_{j_{2}}})}{t(s_{j_{1}}|t_{a_{j_{1}}})} \cdot \frac{d(j_{2}|a_{j_{2}},m,l)}{d(j_{1}|a_{j_{1}},m,l)}
\funp{P}_{\theta}(\mathbf{a'},\mathbf{s}|\mathbf{t}) = \funp{P}_{\theta}(\mathbf{a},\mathbf{s}|\mathbf{t}) \cdot \frac{t(s_{j_{2}}|t_{a_{j_{2}}})}{t(s_{j_{1}}|t_{a_{j_{1}}})} \cdot \frac{d(j_{2}|a_{j_{2}},m,l)}{d(j_{1}|a_{j_{1}},m,l)}
\label{eq:1.14}
\end{eqnarray}
......@@ -247,15 +277,15 @@ S = N(b^{\infty}(V(\mathbf{s}|\mathbf{t};2))) \cup (\mathop{\cup}\limits_{ij} N(
\parinterval 模型4的参数估计基本与模型3一致。需要修改的是扭曲度的估计公式,对于目标语第$i$个cept.生成的第一单词,可以得到(假设有$K$个训练样本):
\begin{eqnarray}
d_1(\Delta_j|ca,cb;\mathbf{s},\mathbf{t}) = \mu_{1cacb}^{-1} \times \sum_{k=1}^{K}c_1(\Delta_j|ca,cb;\mathbf{s}^{[k]},\mathbf{t}^{[k]})
d_1(\Delta_j|ca,cb) = \mu_{1cacb}^{-1} \times \sum_{k=1}^{K}c_1(\Delta_j|ca,cb;\mathbf{s}^{[k]},\mathbf{t}^{[k]})
\label{eq:1.15}
\end{eqnarray}
其中,
\begin{eqnarray}
c_1(\Delta_j|ca,cb;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\textrm{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times s_1(\Delta_j|ca,cb;\mathbf{a},\mathbf{s},\mathbf{t})\big] \label{eq:1.16} \\
s_1(\Delta_j|ca,cb;\rm{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \big[\varepsilon(\phi_i) \cdot \delta(\pi_{i1}-\odot _{i},\Delta_j) \cdot \nonumber \\
c_1(\Delta_j|ca,cb;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\funp{P}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times s_1(\Delta_j|ca,cb;\mathbf{a},\mathbf{s},\mathbf{t})\big] \label{eq:1.16} \\
s_1(\Delta_j|ca,cb;\rm{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \big[\varepsilon(\varphi_i) \cdot \delta(\pi_{i1}-\odot _{i},\Delta_j) \cdot \nonumber \\
& & \delta(A(t_{i-1}),ca) \cdot \delta(B(\tau_{i1}),cb) \big] \label{eq:1.17}
\end{eqnarray}
......@@ -272,7 +302,7 @@ s_1(\Delta_j|ca,cb;\rm{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \big[\vareps
对于目标语第$i$个cept.生成的其他单词(非第一个单词),可以得到:
\begin{eqnarray}
d_{>1}(\Delta_j|cb;\mathbf{s},\mathbf{t}) = \mu_{>1cb}^{-1} \times \sum_{k=1}^{K}c_{>1}(\Delta_j|cb;\mathbf{s}^{[k]},\mathbf{t}^{[k]})
d_{>1}(\Delta_j|cb) = \mu_{>1cb}^{-1} \times \sum_{k=1}^{K}c_{>1}(\Delta_j|cb;\mathbf{s}^{[k]},\mathbf{t}^{[k]})
\label{eq:1.18}
\end{eqnarray}
......@@ -280,7 +310,7 @@ d_{>1}(\Delta_j|cb;\mathbf{s},\mathbf{t}) = \mu_{>1cb}^{-1} \times \sum_{k=1}^{K
\begin{eqnarray}
c_{>1}(\Delta_j|cb;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\big[\textrm{p}_{\theta}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times s_{>1}(\Delta_j|cb;\mathbf{a},\mathbf{s},\mathbf{t}) \big] \label{eq:1.19} \\
s_{>1}(\Delta_j|cb;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \big[\varepsilon(\phi_i-1)\sum_{k=2}^{\phi_i}\delta(\pi_{[i]k}-\pi_{[i]k-1},\Delta_j) \cdot \nonumber ß\\
s_{>1}(\Delta_j|cb;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \big[\varepsilon(\varphi_i-1)\sum_{k=2}^{\varphi_i}\delta(\pi_{[i]k}-\pi_{[i]k-1},\Delta_j) \cdot \nonumber ß\\
& & \delta(B(\tau_{[i]k}),cb) \big] \label{eq:1.20}
\end{eqnarray}
......@@ -291,7 +321,7 @@ s_{>1}(\Delta_j|cb;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \big[\va
\label{eq:1.22}
\end{eqnarray}
\parinterval 对于一个对齐$\mathbf{a}$,可用模型3对它的邻居进行排名,即按$\textrm{P}_{\theta}(b(\mathbf{a})|\mathbf{s},\mathbf{t};3)$排序,其中$b(\mathbf{a})$表示$\mathbf{a}$的邻居。$\tilde{b}(\mathbf{a})$ 表示这个排名表中满足$\textrm{P}_{\theta}(\mathbf{a}'|\mathbf{s},\mathbf{t};4) > \textrm{P}_{\theta}(\mathbf{a}|\mathbf{s},\mathbf{t};4)$的最高排名的$\mathbf{a}'$。同理可知$\tilde{b}_{i \leftrightarrow j}^{\infty}(\mathbf{a})$ 的意义。这里之所以不用模型3中采用的方法直接利用$b^{\infty}(\mathbf{a})$得到模型4中高概率的对齐,是因为模型4中,要想获得某个对齐$\mathbf{a}$的邻居$\mathbf{a}'$必须做很大调整,比如:调整$\tau_{[i]1}$$\odot_{i}$等等。这个过程要比模型3的相应过程复杂得多。因此在模型4中只能借助于模型3的中间步骤来进行参数估计。
\parinterval 对于一个对齐$\mathbf{a}$,可用模型3对它的邻居进行排名,即按$\funp{P}_{\theta}(b(\mathbf{a})|\mathbf{s},\mathbf{t};3)$排序,其中$b(\mathbf{a})$表示$\mathbf{a}$的邻居。$\tilde{b}(\mathbf{a})$ 表示这个排名表中满足$\funp{P}_{\theta}(\mathbf{a}'|\mathbf{s},\mathbf{t};4) > \funp{P}_{\theta}(\mathbf{a}|\mathbf{s},\mathbf{t};4)$的最高排名的$\mathbf{a}'$。 同理可知$\tilde{b}_{i \leftrightarrow j}^{\infty}(\mathbf{a})$ 的意义。这里之所以不用模型3中采用的方法直接利用$b^{\infty}(\mathbf{a})$得到模型4中高概率的对齐,是因为模型4中要想获得某个对齐$\mathbf{a}$的邻居$\mathbf{a}'$必须做很大调整,比如:调整$\tau_{[i]1}$$\odot_{i}$等等。这个过程要比模型3的相应过程复杂得多。因此在模型4中只能借助于模型3的中间步骤来进行参数估计。
\setlength{\belowdisplayskip}{3pt}%调整空白大小
%----------------------------------------------------------------------------------------
......@@ -299,45 +329,45 @@ s_{>1}(\Delta_j|cb;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \big[\va
%----------------------------------------------------------------------------------------
\section{IBM模型5训练方法}
\parinterval 模型5的参数估计过程也与模型3的过程基本一致,二者的区别在于扭曲度的估计公式。在模型5中,对于目标语第$i$个cept.生成的第一单词,可以得到(假设有$K$个训练样本):
\parinterval 模型5的参数估计过程也模型4的过程基本一致,二者的区别在于扭曲度的估计公式。在模型5中,对于目标语第$i$个cept.生成的第一单词,可以得到(假设有$K$个训练样本):
\begin{eqnarray}
d_1(\Delta_j|cb;\mathbf{s},\mathbf{t}) = \mu_{1cb}^{-1} \times \sum_{k=1}^{K}c_1(\Delta_j|cb;\mathbf{s}^{[k]},\mathbf{t}^{[k]})
d_1(\Delta_j|cb) = \mu_{1cb}^{-1} \times \sum_{k=1}^{K}c_1(\Delta_j|cb;\mathbf{s}^{[k]},\mathbf{t}^{[k]})
\label{eq:1.23}
\end{eqnarray}
其中,
\begin{eqnarray}
c_1(\Delta_j|cb,v_x,v_y;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\Big[ \textrm{P}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times s_1(\Delta_j|cb,v_x,v_y;\mathbf{a},\mathbf{s},\mathbf{t}) \Big] \label{eq:1.24} \\
s_1(\Delta_j|cb,v_x,v_y;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \Big [ \varepsilon(\phi_i) \cdot \delta(v_{\pi_{i1}},\Delta_j) \cdot \delta(v_{\odot _{i-1}},v_x) \nonumber \\
& & \cdot \delta(v_m-\phi_i+1,v_y) \cdot \delta(v_{\pi_{i1}},v_{\pi_{i1}-1} )\Big] \label{eq:1.25}
c_1(\Delta_j|cb,v_x,v_y;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\Big[ \funp{P}(\mathbf{s},\mathbf{a}|\mathbf{t}) \times s_1(\Delta_j|cb,v_x,v_y;\mathbf{a},\mathbf{s},\mathbf{t}) \Big] \label{eq:1.24} \\
s_1(\Delta_j|cb,v_x,v_y;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l \Big [ \varepsilon(\varphi_i) \cdot \delta(v_{\pi_{i1}},\Delta_j) \cdot \delta(v_{\odot _{i-1}},v_x) \nonumber \\
& & \cdot \delta(v_m-\varphi_i+1,v_y) \cdot \delta(v_{\pi_{i1}},v_{\pi_{i1}-1} )\Big] \label{eq:1.25}
\end{eqnarray}
对于目标语第$i$个cept.生成的其他单词(非第一个单词),可以得到:
\begin{eqnarray}
d_{>1}(\Delta_j|cb,v;\mathbf{s},\mathbf{t}) = \mu_{>1cb}^{-1} \times \sum_{k=1}^{K}c_{>1}(\Delta_j|cb,v;\mathbf{s}^{[k]},\mathbf{t}^{[k]})
d_{>1}(\Delta_j|cb,v) = \mu_{>1cb}^{-1} \times \sum_{k=1}^{K}c_{>1}(\Delta_j|cb,v;\mathbf{s}^{[k]},\mathbf{t}^{[k]})
\label{eq:1.26}
\end{eqnarray}
其中,
\begin{eqnarray}
c_{>1}(\Delta_j|cb,v;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\Big[\textrm{P}(\mathbf{a},\mathbf{s}|\mathbf{t}) \times s_{>1}(\Delta_j|cb,v;\mathbf{a},\mathbf{s},\mathbf{t}) \Big] \label{eq:1.27} \\
s_{>1}(\Delta_j|cb,v;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l\Big[\varepsilon(\phi_i-1)\sum_{k=2}^{\phi_i} \big[\delta(v_{\pi_{ik}}-v_{\pi_{[i]k}-1},\Delta_j) \nonumber \\
& & \cdot \delta(B(\tau_{[i]k}) ,cb) \cdot \delta(v_m-v_{\pi_{i(k-1)}}-\phi_i+k,v) \nonumber \\
c_{>1}(\Delta_j|cb,v;\mathbf{s},\mathbf{t}) & = & \sum_{\mathbf{a}}\Big[\funp{P}(\mathbf{a},\mathbf{s}|\mathbf{t}) \times s_{>1}(\Delta_j|cb,v;\mathbf{a},\mathbf{s},\mathbf{t}) \Big] \label{eq:1.27} \\
s_{>1}(\Delta_j|cb,v;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l\Big[\varepsilon(\varphi_i-1)\sum_{k=2}^{\varphi_i} \big[\delta(v_{\pi_{ik}}-v_{\pi_{[i]k}-1},\Delta_j) \nonumber \\
& & \cdot \delta(B(\tau_{[i]k}) ,cb) \cdot \delta(v_m-v_{\pi_{i(k-1)}}-\varphi_i+k,v) \nonumber \\
& & \cdot \delta(v_{\pi_{i1}},v_{\pi_{i1}-1}) \big] \Big] \label{eq:1.28}
\end{eqnarray}
\vspace{0.5em}
\parinterval 从式(\ref{eq:1.24})中可以看出因子$\delta(v_{\pi_{i1}},v_{\pi_{i1}-1})$保证了,即使对齐$\mathbf{a}$不合理(一个源语位置对应多个目标语位置)也可以避免在这个不合理的对齐上计算结果。需要注意的是因子$\delta(v_{\pi_{p1}},v_{\pi_{p1-1}})$,确保了$\mathbf{a}$中不合理的部分不产生坏的影响,而$\mathbf{a}$中其他正确的部分仍会参与迭代。
\parinterval 从式\ref{eq:1.24}中可以看出因子$\delta(v_{\pi_{i1}},v_{\pi_{i1}-1})$保证了,即使对齐$\mathbf{a}$不合理(一个源语言位置对应多个目标语言位置)也可以避免在这个不合理的对齐上计算结果。需要注意的是因子$\delta(v_{\pi_{p1}},v_{\pi_{p1-1}})$,确保了$\mathbf{a}$中不合理的部分不产生坏的影响,而$\mathbf{a}$中其他正确的部分仍会参与迭代。
\parinterval 不过上面的参数估计过程与IBM前4个模型的参数估计过程并不完全一样。IBM前4个模型在每次迭代中,可以在给定$\mathbf{s}$$\mathbf{t}$和一个对齐$\mathbf{a}$的情况下直接计算并更新参数。但是在模型5的参数估计过程中(如公式\ref{eq:1.24}),需要模拟出由$\mathbf{t}$生成$\mathbf{s}$的过程才能得到正确的结果,因为从$\mathbf{t}$$\mathbf{s}$$\mathbf{a}$中是不能直接得到 的正确结果的。具体说,就是要从目标语言句子的第一个单词开始到最后一个单词结束,依次生成每个目标语言单词对应的源语言单词,每处理完一个目标语言单词就要暂停,然后才能计算式\ref{eq:1.24}中求和符号里面的内容。这也就是说即使给定了$\mathbf{s}$$\mathbf{t}$和一个对齐$\mathbf{a}$,也不能直接在它们上进行计算,必须重新模拟$\mathbf{t}$$\mathbf{s}$的生成过程。
\parinterval 从前面的分析可以看出,虽然模型5比模型4更精确,但是模型5过于复杂以至于给参数估计增加了计算量(对于每组$\mathbf{t}$$\mathbf{s}$$\mathbf{a}$都要模拟$\mathbf{t}$生成$\mathbf{s}$的翻译过程)。因此模型5的开发对于系统实现是一个挑战。
\parinterval 从前面的分析可以看出,虽然模型5比模型4更精确,但是模型5过于复杂以至于给参数估计增加了计算量(对于每组$\mathbf{t}$$\mathbf{s}$$\mathbf{a}$都要模拟$\mathbf{t}$生成$\mathbf{s}$的翻译过程)。因此模型5的系统实现是一个挑战。
\parinterval 在模型5中同样需要定义一个词对齐集合$S$,使得每次迭代都在$S$上进行。可以对$S$进行如下定义
\begin{eqnarray}
......@@ -346,7 +376,7 @@ s_{>1}(\Delta_j|cb,v;\mathbf{a},\mathbf{s},\mathbf{t}) & = & \sum_{i=1}^l\Big[\v
\end{eqnarray}
\vspace{0.5em}
\parinterval 这里$\tilde{\tilde{b}}(\mathbf{a})$借用了模型4中$\tilde{b}(\mathbf{a})$的概念。不过$\tilde{\tilde{b}}(\mathbf{a})$表示在利用模型3进行排名的列表中满足$\textrm{P}_{\theta}(\mathbf{a}'|\mathbf{s},\mathbf{t};5)$的最高排名的词对齐
\noindent 其中,$\tilde{\tilde{b}}(\mathbf{a})$借用了模型4中$\tilde{b}(\mathbf{a})$的概念。不过$\tilde{\tilde{b}}(\mathbf{a})$表示在利用模型3进行排名的列表中满足$\funp{P}_{\theta}(\mathbf{a}'|\mathbf{s},\mathbf{t};5)$的最高排名的词对齐,这里$\mathbf{a}'$表示$\mathbf{a}$的邻居
\end{appendices}
......
......@@ -3,112 +3,74 @@
\begin{tikzpicture}
\tikzstyle{secnode} =[font=\scriptsize,minimum height=4.0em,minimum width=22em,draw,thick,fill=white,drop shadow]
\tikzstyle{conceptnode} =[font=\scriptsize,minimum height=1.5em,minimum width=5em]
\tikzstyle{conceptnodesmall} =[font=\scriptsize,minimum height=1.0em,minimum width=4.4em]
% section 1
\node [secnode,anchor=south west,minimum width=22.5em,red,fill=white] (sec1) at (0,0) {};
\node [anchor=north] (sec1label) at ([yshift=-0.2em]sec1.north) {\small{机器翻译简介}};
\node [anchor=north west,draw=red,thick,fill=white,rounded corners] (sec1title) at ([xshift=-0.3em,yshift=0.3em]sec1.north west) {{\footnotesize\bfnew{\color{red} 第一章}}};
\node [conceptnode,anchor=south west,fill=red!15,thin] (sec1box1) at ([xshift=0.5em,yshift=0.5em]sec1.south west) {\footnotesize{发展历史}};
\node [conceptnode,anchor=west,fill=red!15,thin] (sec1box2) at ([xshift=0.5em]sec1box1.east) {\footnotesize{评价方法}};
\node [conceptnode,anchor=west,fill=red!15,thin] (sec1box3) at ([xshift=0.5em]sec1box2.east) {\footnotesize{应用情况}};
\node [conceptnode,anchor=west,fill=red!15,thin] (sec1box4) at ([xshift=0.5em]sec1box3.east) {\footnotesize{系统\&数据}};
% section 2
\node [secnode,anchor=south,blue,fill=white] (sec2) at ([xshift=-6.5em,yshift=3em]sec1.north) {};
\node [anchor=north] (sec2label) at (sec2.north) {\small{词法、语法及统计建模基础}};
\node [anchor=north west,draw=blue,thick,fill=white,rounded corners] (sec2title) at ([xshift=-0.3em,yshift=0.3em]sec2.north west) {{\footnotesize\bfnew{\color{blue} 第二章}}};
\node [conceptnode,anchor=south west,fill=ublue!15,thin,minimum width=4em,align=left] (sec2box1) at ([xshift=0.5em,yshift=0.4em]sec2.south west) {\tiny{概率论与}\\\tiny{统计建模基础}};
\node [anchor=west,draw,dotted,thick,minimum height=2em,minimum width=16.6em,align=left] (sec2box2) at ([xshift=0.3em]sec2box1.east) {};
\node [conceptnodesmall,minimum width=5em,anchor=south west,fill=blue!15,thin] (sec2box3) at ([xshift=0.4em,yshift=0.3em]sec2box2.south west) {\scriptsize{中文分词}};
\node [conceptnodesmall,minimum width=5em,anchor=west,fill=blue!15,thin] (sec2box4) at ([xshift=0.4em]sec2box3.east) {\scriptsize{$n$元语法模型}};
\node [conceptnodesmall,minimum width=5em,anchor=west,fill=blue!15,thin] (sec2box5) at ([xshift=0.4em]sec2box4.east) {\scriptsize{句法分析}};
\draw [->,very thick] ([xshift=-1em,yshift=0.2em]sec1.north) .. controls +(north:2.5em) and +(south:2.5em) .. ([xshift=-3em,yshift=-0.2em]sec2.south);
% section 5
\node [secnode,anchor=south,orange,fill=white] (sec5) at ([xshift=7em,yshift=10em]sec1.north) {};
\node [anchor=north] (sec5label) at (sec5.north) {\small{人工神经网络和神经语言建模}};
\node [anchor=north west,draw=orange,thick,fill=white,rounded corners] (sec5title) at ([xshift=-0.3em,yshift=0.3em]sec5.north west) {{\footnotesize\bfnew{\color{orange} 第五章}}};
\node [conceptnode,minimum width=4em,anchor=south west,fill=orange!15,thin,align=left] (sec5box1) at ([xshift=0.5em,yshift=0.4em]sec5.south west) {\tiny{线性代数基础}\\\tiny{与感知机}};
\node [conceptnode,minimum width=4em,anchor=west,fill=orange!15,thin,align=left] (sec5box2) at ([xshift=0.2em]sec5box1.east) {\tiny{多层神经网络}\\\tiny{与实现方法}};
\node [conceptnode,minimum width=4em,anchor=west,fill=orange!15,thin,align=left] (sec5box3) at ([xshift=0.2em]sec5box2.east) {\tiny{模型训练}\\\tiny{(反向传播)}};
\node [conceptnode,minimum width=4em,anchor=west,fill=purple!15,thin,align=left] (sec5box4) at ([xshift=0.2em]sec5box3.east) {\tiny{神经语言模型}\\\tiny{(FNN等)}};
\node [conceptnode,minimum width=4em,anchor=west,fill=purple!15,thin,align=left] (sec5box5) at ([xshift=0.2em]sec5box4.east) {\tiny{表示学习与}\\\tiny{预训练模型}};
\node [draw,dotted,thick,inner sep=1pt] [fit = (sec5box4) (sec5box5)] (pretrainbox) {};
\draw [->,very thick] ([yshift=-9.8em]sec5.south) -- ([yshift=-0.2em]sec5.south);
\draw [->,thick,dotted] ([xshift=0.2em,yshift=1em]sec2.east) .. controls +(east:3em) and +(south:4em) .. ([xshift=3em,yshift=-0.0em]pretrainbox.south);
% section 3
\node [secnode,anchor=south,ugreen,fill=white] (sec3) at ([yshift=10em]sec2.north) {};
\node [anchor=north] (sec3label) at (sec3.north) {\small{基于词的机器翻译模型}};
\node [anchor=north west,draw=ugreen,thick,fill=white,rounded corners] (sec3title) at ([xshift=-0.3em,yshift=0.3em]sec3.north west) {{\footnotesize\bfnew{\color{ugreen} 第三章}}};
\node [conceptnode,minimum width=4em,anchor=south west,fill=ublue!15,thin,align=left] (sec3box1) at ([xshift=0.5em,yshift=0.4em]sec3.south west) {\tiny{机器翻译的统计}\\\tiny{描述(实例)}};
\node [conceptnode,minimum width=4em,anchor=west,fill=green!20,thin,align=left] (sec3box2) at ([xshift=0.2em]sec3box1.east) {\tiny{噪声信道模型}\\\tiny{与生成式模型}};
\node [conceptnode,minimum width=4em,anchor=west,fill=green!20,thin,align=left] (sec3box3) at ([xshift=0.2em]sec3box2.east) {\tiny{IBM模型、隐}\\\tiny{马尔可夫模型}};
\node [conceptnode,minimum width=4em,anchor=west,fill=green!20,thin,align=left] (sec3box4) at ([xshift=0.2em]sec3box3.east) {\tiny{\hspace{0.9em}参数学习}\\\tiny{=优化}};
\node [conceptnode,minimum width=3.8em,anchor=west,fill=green!20,thin,align=left,minimum height=2em,inner sep=2pt] (sec3box5) at ([xshift=0.2em]sec3box4.east) {\scriptsize{EM算法}};
\draw [->,very thick] ([yshift=0.2em,xshift=-3em]sec2.north) -- ([yshift=-0.2em,xshift=-3em]sec3.south);
% section 4
\node [secnode,anchor=south,ugreen,fill=white] (sec4) at ([yshift=3em]sec3.north) {};
\node [anchor=north] (sec4label) at (sec4.north) {\small{基于短语和句法的机器翻译模型}};
\node [anchor=north west,draw=ugreen,thick,fill=white,rounded corners] (sec4title) at ([xshift=-0.3em,yshift=0.3em]sec4.north west) {{\footnotesize\bfnew{\color{ugreen} 第四章}}};
\node [conceptnode,minimum width=4em,anchor=south west,fill=ublue!15,thin,align=left] (sec4box1) at ([xshift=0.5em,yshift=0.4em]sec4.south west) {\tiny{判别式模型与}\\\tiny{最小错误率训练}};
\node [conceptnode,minimum width=4em,anchor=west,fill=green!20,thin,align=left] (sec4box2) at ([xshift=0.2em]sec4box1.east) {\tiny{基于翻译推导}\\\tiny{的建模}};
\node [conceptnode,minimum width=4em,anchor=west,fill=green!20,thin,align=left] (sec4box3) at ([xshift=0.2em]sec4box2.east) {\tiny{短语及句法}\\\tiny{翻译规则抽取}};
\node [conceptnode,minimum width=4em,anchor=west,fill=green!20,thin,align=left,minimum height=2em,inner sep=2pt] (sec4box4) at ([xshift=0.2em]sec4box3.east) {\scriptsize{调序模型}};
\node [conceptnode,minimum width=3.8em,anchor=west,fill=green!20,thin,align=left,minimum height=2em,inner sep=2pt] (sec4box5) at ([xshift=0.2em]sec4box4.east) {\scriptsize{解码}};
\draw [->,very thick] ([yshift=0.2em,xshift=-3em]sec3.north) -- ([yshift=-0.2em,xshift=-3em]sec4.south);
% section 6
\node [secnode,anchor=south,purple,fill=white] (sec6) at ([yshift=19em]sec5.north) {};
\node [anchor=north] (sec6label) at (sec6.north) {\small{神经机器翻译模型}};
\node [anchor=north west,draw=purple,thick,fill=white,rounded corners] (sec6title) at ([xshift=-0.3em,yshift=0.3em]sec6.north west) {{\footnotesize\bfnew{\color{purple} 第六章}}};
\node [conceptnode,minimum width=4em,anchor=south west,fill=ublue!15,thin,align=left] (sec6box1) at ([xshift=0.5em,yshift=0.4em]sec6.south west) {\tiny{编码器-解码器}\\\tiny{框架}};
\node [conceptnode,minimum width=4em,anchor=west,fill=ublue!15,thin,align=left,minimum height=2em] (sec6box2) at ([xshift=0.2em]sec6box1.east) {\scriptsize{注意力机制}};
\node [conceptnode,minimum width=7.5em,anchor=west,fill=purple!15,thin,align=left] (sec6box3) at ([xshift=0.2em]sec6box2.east) {\tiny{基于RNN和Transformer}\\\tiny{的神经机器翻译建模}};
\node [conceptnode,minimum width=4em,anchor=west,fill=purple!15,thin,align=left,minimum height=2em] (sec6box4) at ([xshift=0.2em]sec6box3.east) {\scriptsize{训练与推断}};
\draw [->,very thick] ([yshift=0.2em]sec5.north) -- ([yshift=-0.2em]sec6.south);
\draw [->,very thick,dotted] ([yshift=0.2em,xshift=-2em]sec4.north) .. controls +(north:5.0em) and +(west:4em) .. ([xshift=-0.2em]sec6.west);
\draw [->,thick,dotted] ([xshift=3em,yshift=0.2em]pretrainbox.north) .. controls +(north:15em) and +(south:15em) .. ([xshift=0em,yshift=-0.0em]sec6box3.south);
% section 7
\node [secnode,anchor=south,purple,fill=white,minimum height=6.3em] (sec7) at ([yshift=3em]sec6.north) {};
\node [anchor=north] (sec7label) at (sec7.north) {\small{神经机器翻译实战}};
\node [anchor=north west,draw=purple,thick,fill=white,rounded corners] (sec7title) at ([xshift=-0.3em,yshift=0.3em]sec7.north west) {{\footnotesize\bfnew{\color{purple} 第七章}}};
\node [conceptnode,minimum width=4em,anchor=south west,fill=ublue!15,thin,align=left,minimum height=4.2em] (sec7box1) at ([xshift=0.5em,yshift=0.4em]sec7.south west) {\tiny{数据处理、}\\\tiny{子词切分}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box2) at ([xshift=0.5em,yshift=-0.2em]sec7box1.north east) {\tiny{正则化}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box3) at ([yshift=-0.1em]sec7box2.south west) {\tiny{增大模型容量}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box4) at ([yshift=-0.1em]sec7box3.south west) {\tiny{大批量训练}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box5) at ([xshift=0.6em]sec7box2.north east) {\tiny{推断优化}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box6) at ([yshift=-0.1em]sec7box5.south west) {\tiny{译文长度控制}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box7) at ([yshift=-0.1em]sec7box6.south west) {\tiny{多模型集成}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box8) at ([xshift=0.6em]sec7box5.north east) {\tiny{深层模型}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box9) at ([yshift=-0.1em]sec7box8.south west) {\tiny{知识精炼}};
\node [anchor=north west,minimum width=5em,anchor=north west,fill=purple!15] (sec7box10) at ([yshift=-0.1em]sec7box9.south west) {\tiny{单语数据使用}};
\node [draw,dotted,thick,inner sep=1pt] [fit = (sec7box2) (sec7box3) (sec7box4)] (trainbox) {};
\node [draw,dotted,thick,inner sep=1pt] [fit = (sec7box5) (sec7box6) (sec7box7)] (inferencebox) {};
\node [draw,dotted,thick,inner sep=1pt] [fit = (sec7box8) (sec7box9) (sec7box10)] (advancedbox) {};
\draw [->,very thick] ([yshift=0.2em]sec6.north) -- ([yshift=-0.2em]sec7.south);
\draw [->,very thick,dotted] ([yshift=0.2em,xshift=-3em]sec4.north) .. controls +(north:7.0em) and +(west:6em) .. ([xshift=-0.2em]sec7.west);
%caption
\node [anchor=north] (caption) at ([xshift=0.4em,yshift=-1em]sec1.south) {\footnotesize{本书各章节及核心概念关系图}};
\tikzstyle{partnode} =[font=\scriptsize,minimum height=2.0em,minimum width=15em,draw,thick,fill=white,drop shadow]
\tikzstyle{secnode} =[font=\footnotesize,minimum height=1.6em,minimum width=14em,align=flush left]
\begin{scope}
% part 1
\node [partnode,anchor=south,blue,minimum height=9.0em,minimum width=22.7em,fill=white] (part1) at ([yshift=-0.5em]0,0) {};
\node [anchor=north] (part1label) at ([yshift=-0.3em]part1.north) {\sffamily\bfseries{机器翻译基础}};
\node [anchor=north west,draw=blue,thick,fill=white,rounded corners] (part1title) at ([xshift=-0.3em,yshift=0.3em]part1.north west) {{\color{blue} {\sffamily\bfseries 第一部分}}};
\node [secnode,anchor=south,fill=ugreen!20,minimum width=21.6em,align=center] (sec01) at (0,0) {第一章\hspace{1em} 机器翻译的前世今生};
\node [secnode,anchor=south west,fill=blue!20] (sec02) at ([yshift=0.8em]sec01.north west) {第二章\hspace{1em} 统计语言建模基础\hspace{3em}};
\node [secnode,anchor=south west,fill=blue!20] (sec03) at ([yshift=0.8em]sec02.north west) {第三章\hspace{1em} 词法分析和语法分析基础};
\node [secnode,anchor=north west,fill=blue!20,minimum width=7em,minimum height=4.1em,align=center] (sec04) at ([xshift=0.6em]sec03.north east) {第四章\\ 翻译质量评价};
\draw [->,very thick] ([yshift=-0.7em]sec02.south) -- ([yshift=-0.1em]sec02.south);
\draw [->,very thick] ([yshift=-0.7em]sec03.south) -- ([yshift=-0.1em]sec03.south);
\draw [->,very thick] ([yshift=-0.7em]sec04.south) -- ([yshift=-0.1em]sec04.south);
% part 2
\node [partnode,anchor=south,orange,minimum height=11.5em,minimum width=18.1em,fill=white] (part2) at ([yshift=3em]part1.north west) {};
\node [anchor=north] (part2label) at ([yshift=-0.3em]part2.north) {\sffamily\bfseries{统计机器翻译}};
\node [anchor=north west,draw=orange,thick,fill=white,rounded corners] (part2title) at ([xshift=-0.3em,yshift=0.3em]part2.north west) {{\color{orange} {\sffamily\bfseries 第二部分}}};
\node [secnode,anchor=south,fill=orange!20,minimum width=17em,align=left] (sec04) at ([yshift=0.5em]part2.south) {第四章\hspace{1em} 基于词的机器翻译建模 \hspace{2.0em}};
\node [secnode,anchor=south,fill=orange!20,minimum width=17em,align=center] (sec05) at ([yshift=0.8em]sec04.north) {第五章\hspace{1em} 基于扭曲度和繁衍率的模型};
\node [secnode,anchor=south,fill=orange!20,minimum width=17em,align=center] (sec06) at ([yshift=0.8em]sec05.north) {第六章\hspace{1em} 基于短语的模型 \hspace{4.7em}};
\node [secnode,anchor=south,fill=orange!20,minimum width=17em,align=center] (sec07) at ([yshift=0.8em]sec06.north) {第七章\hspace{1em} 基于句法的模型 \hspace{4.7em}};
\draw [->,very thick] ([yshift=-0.7em]sec05.south) -- ([yshift=-0.1em]sec05.south);
\draw [->,very thick] ([yshift=-0.7em]sec06.south) -- ([yshift=-0.1em]sec06.south);
\draw [->,very thick] ([yshift=-0.7em]sec07.south) -- ([yshift=-0.1em]sec07.south);
% part 3
\node [partnode,anchor=south,red,minimum height=9.5em,minimum width=22.7em,fill=white] (part3) at ([yshift=3em,xshift=2.5em]part2.north east) {};
\node [anchor=north] (part3label) at ([yshift=-0.3em]part3.north) {\sffamily\bfseries{神经机器翻译}};
\node [anchor=north west,draw=red,thick,fill=white,rounded corners] (part3title) at ([xshift=-0.3em,yshift=0.3em]part3.north west) {{\color{red} {\sffamily\bfseries 第三部分}}};
\node [secnode,anchor=south,fill=magenta!20,minimum width=21.6em,align=center] (sec09) at ([yshift=0.5em]part3.south) {第九章\hspace{1em} 人工神经网络基础及神经语言模型};
\node [secnode,anchor=south west,fill=red!20,minimum width=6.6em,minimum height=4.5em,align=center] (sec10) at ([yshift=0.8em]sec09.north west) {第十章\\ 基于循环神经 \\ 网络的模型};
\node [secnode,anchor=south west,fill=red!20,minimum width=6.6em,minimum height=4.5em,align=center] (sec11) at ([xshift=0.8em]sec10.south east) {第十一章\\ 基于卷积神经 \\ 网络的模型};
\node [secnode,anchor=south west,fill=red!20,minimum width=6.6em,minimum height=4.5em,align=center] (sec12) at ([xshift=0.8em]sec11.south east) {第十二章\\ 基于自注意力 \\ 的模型};
\draw [->,very thick] ([yshift=-0.7em]sec10.south) -- ([yshift=-0.1em]sec10.south);
\draw [->,very thick] ([yshift=-0.7em]sec11.south) -- ([yshift=-0.1em]sec11.south);
\draw [->,very thick] ([yshift=-0.7em]sec12.south) -- ([yshift=-0.1em]sec12.south);
% part 4
\node [partnode,anchor=south,ugreen,minimum height=12.0em,minimum width=29.7em,fill=white] (part4) at ([yshift=3em,xshift=6em]part3.north west) {};
\node [anchor=north] (part4label) at ([yshift=-0.3em]part4.north) {\sffamily\bfseries{机器翻译前沿}};
\node [anchor=north west,draw=ugreen,thick,fill=white,rounded corners] (part4title) at ([xshift=-0.3em,yshift=0.3em]part4.north west) {{\color{ugreen} {\sffamily\bfseries 第四部分}}};
\node [secnode,anchor=south west,fill=cyan!20,minimum width=14.0em,align=center] (sec13) at ([yshift=0.5em,xshift=0.5em]part4.south west) {第十三章\hspace{1em} 神经机器翻译模型训练};
\node [secnode,anchor=west,fill=cyan!20,minimum width=14.0em,align=center] (sec14) at ([xshift=0.6em]sec13.east) {第十四章\hspace{1em} 神经机器翻译模型推断};
\node [secnode,anchor=south west,fill=green!30,minimum width=9em,minimum height=4.5em,align=center] (sec15) at ([yshift=0.8em]sec13.north west) {第十五章\\ 神经机器翻译 \\ 结构优化};
\node [secnode,anchor=south west,fill=green!30,minimum width=9em,minimum height=4.5em,align=center] (sec16) at ([xshift=0.8em]sec15.south east) {第十六章\\ 低资源 \\ 机器翻译};
\node [secnode,anchor=south west,fill=green!30,minimum width=9em,minimum height=4.5em,align=center] (sec17) at ([xshift=0.8em]sec16.south east) {第十七章\\ 多模态、多层次 \\ 机器翻译};
\node [secnode,anchor=south west,fill=amber!25,minimum width=28.7em,align=center] (sec18) at ([yshift=0.8em]sec15.north west) {第十八章\hspace{1em} 机器翻译工业实践};
\node [rectangle,draw,dotted,thick,inner sep=0.1em,fill opacity=1] [fit = (sec13) (sec14)] (nmtbasebox) {};
\draw [->,very thick] ([yshift=-0.7em]sec15.south) -- ([yshift=-0.1em]sec15.south);
\draw [->,very thick] ([yshift=-0.7em]sec16.south) -- ([yshift=-0.1em]sec16.south);
\draw [->,very thick] ([yshift=-0.7em]sec17.south) -- ([yshift=-0.1em]sec17.south);
\draw [<-,very thick] ([yshift=0.7em]sec15.north) -- ([yshift=0.1em]sec15.north);
\draw [<-,very thick] ([yshift=0.7em]sec16.north) -- ([yshift=0.1em]sec16.north);
\draw [<-,very thick] ([yshift=0.7em]sec17.north) -- ([yshift=0.1em]sec17.north);
\draw [->,very thick,dotted] ([yshift=-0.7em,xshift=0.4em]sec15.south east) -- ([yshift=0.7em,xshift=0.4em]sec15.north east);
\draw [->,very thick,dotted] ([yshift=-0.7em,xshift=0.4em]sec16.south east) -- ([yshift=0.7em,xshift=0.4em]sec16.north east);
% lines and arrows
\draw [->,line width=0.2em] ([xshift=-0.1em]part1.west) .. controls +(west:5em) and +(south:3em) .. ([yshift=-0.1em,xshift=-5em]part2.south);
\draw [->,line width=0.2em] ([xshift=-2em,yshift=0.1em]part1.north east) -- ([xshift=-2em,yshift=17.3em]part1.north east);
\draw [->,line width=0.2em] ([xshift=0.3em,yshift=-2em]part2.east) .. controls +(east:6em) and +(south:4em) .. ([yshift=-0.3em,xshift=4em]part3.south);
\draw [->,line width=0.2em] ([xshift=-5em,yshift=0.5em]part2.north) -- ([xshift=-5em,yshift=15.3em]part2.north);
\draw [->,line width=0.2em] ([xshift=4em,yshift=0.1em]part3.north) -- ([xshift=4em,yshift=2.7em]part3.north);
\end{scope}
\end{tikzpicture}
......@@ -16,41 +16,96 @@
%----------------------------------------------------------------------------------------
{\color{white}}
\vspace{0.5em}
\vspace{1em}
\begin{center}
{\Huge \bfnew{\ \ \ \ }}
{\Huge \bfnew{\ \ \ \ }}
\end{center}
\vspace{2em}
\begin{spacing}{1.18}
让计算机进行自然语言的翻译是人类长期的梦想,也是人工智能的终极目标之一。自上世纪九十年代起,机器翻译迈入了基于统计建模的时代,发展到今天,深度学习等机器学习方法已经在机器翻译中得到了大量的应用,取得了令人瞩目的进步。
\noindent {\sffamily\bfseries 1. 本书的由来}
在这个时代背景下,对机器翻译的模型、方法和实现技术进行深入了解是自然语言处理领域研究者和实践者所渴望的。本书全面回顾了近三十年内机器翻译的技术发展历程,并围绕统计建模和深度学习两个主题对机器翻译的技术方法进行了全面介绍。在写作中,笔者力求用朴实的语言和简洁的实例阐述机器翻译的基本模型和方法,同时对相关的技术前沿进行讨论。本书可以供计算机相关专业高年级本科生及研究生学习之用,也可以作为自然语言处理,特别是机器翻译领域相关研究人员的参考资料。
\vspace{0.5em}
本书共分为七个章节,章节的顺序参考了机器翻译技术发展的时间脉络,同时兼顾了机器翻译知识体系的内在逻辑。各章节的主要内容包括:
让计算机进行自然语言的翻译是人类长期的梦想,也是人工智能的终极目标之一。自上世纪九十年代起,机器翻译迈入了基于统计建模的时代,发展到今天,已经大量应用了深度学习等机器学习方法,并且取得了令人瞩目的进步。在这个时代背景下,对机器翻译的模型、方法和实现技术进行深入了解是自然语言处理领域研究者和实践者所渴望的。
与所有从事机器翻译研究的人一样,笔者也梦想着有朝一日机器翻译能够完全实现。这个想法可以追溯到1980年,姚天顺教授和王宝库教授创立了东北大学自然语言处理实验室,把机器翻译作为毕生为之奋斗的目标。这也影响了包括笔者在内的许多人。虽然,那时的机器翻译技术并不先进,研究条件也异常艰苦,但是实现机器翻译的梦想从未改变。
步入二十一世纪后,统计学习方法的兴起给机器翻译带来了全新的思路,同时也带来了巨大的技术进步。笔者有幸经历了那个年代,目睹了机器翻译的成长。同时,也加入到机器翻译研究的浪潮中。从2007年开始研发NiuTrans开源系统,到2012年正式进行机器翻译产业化,并创立小牛翻译,笔者不断地被机器翻译所取得的进步所感动。那时,笔者就曾经思考过将机器翻译的模型和方法进行总结,形成资料供人阅读。虽然粗略写过一些文字,但是未成体系,只是在相关的教学环节中进行使用,供实验室同学闲暇时参考阅读。
但是机器翻译领域进展之快是无法预见的。2016年之后,随着深度学习方法在机器翻译中的进一步应用,机器翻译迎来了前所未有的大好机遇。新的技术方法层出不穷,机器翻译系统也得到了广泛应用。这时,笔者心里又涌现出将机器翻译的技术内容编撰成书的想法。这种强烈的念头使得笔者完成了本书的第一个版本(包含七章),并开源供人广泛阅读。承蒙同行们厚爱,得到了很多反馈,包括一些批评意见。这些使得笔者可以更加全面地梳理思路。
最初,笔者的想法仅仅是将机器翻译的技术内容做成资料供人阅读。但是,朋友、同事们一直鼓励将内容正式出版。虽然担心书的内容不够精致,无法给同行作为参考,但是最终还是下定决心重构内容。所幸,得到电子工业出版社的支持,形成新版,共十八章。
写作中,每当笔者翻起以前的资料,都会想起当年的一些故事。与其说这部书是写给读者,还不如说这本书是写给笔者自己,写给所有同笔者一样,经历过或正在经历机器翻译蓬勃发展年代的人。希望本书可以作为一个时代的记录,但是这个时代并未结束,还将继续,并更加美好。
\vspace{1.0em}
\noindent {\sffamily\bfseries 2. 本书的特色}
\begin{itemize}
\vspace{0.5em}
\item 第一章:机器翻译简介
\vspace{0.5em}
\item 第二章:词法、语法及统计建模基础
\vspace{0.5em}
\item 第三章:基于词的机器翻译模型
本书全面回顾了近三十年内机器翻译的技术发展历程,并围绕{\sffamily\bfseries 机器翻译的建模}这一主题对机器翻译的技术方法进行了全面介绍。在写作中,笔者力求用朴实的语言和简洁的实例阐述机器翻译的基本模型,同时对相关的技术前沿进行讨论。其中也会涉及大量的实践经验,包括许多机器翻译系统开发的细节。从这个角度来说,本书不单单是一本理论书籍,它还结合了机器翻译的应用,给读者提供了很多机器翻译技术落地的具体思路。
本书可以供计算机相关专业高年级本科生及研究生学习之用,也可以作为自然语言处理领域,特别是机器翻译方向相关研究人员的参考资料。此外,本书各章的主题都十分明确,内容也相对集中。因此,读者也可将每章作为某一专题的学习资料。
{\sffamily\bfseries 用最简单的方式阐述机器翻译的基本思想}是笔者所期望达到的目标。但是,书中不可避免会使用一些形式化定义和算法的抽象描述,因此,笔者尽所能通过图例进行解释(本书共XXX张插图)。不过,本书所包含的内容较为广泛,难免会有疏漏,望读者海涵,并指出不当之处。
\vspace{1.0em}
\noindent {\sffamily\bfseries 3. 本书的内容}
\vspace{0.5em}
\item 第四章:基于短语和句法的机器翻译模型
本书共分为四个部分,十八章。章节的顺序参考了机器翻译技术发展的时间脉络,同时兼顾了机器翻译知识体系的内在逻辑。本书的主要内容包括:
\begin{itemize}
\vspace{0.5em}
\item 第五章:人工神经网络和神经语言建模
\item 第一部分:机器翻译基础
\begin{itemize}
\item 第一章\ 机器翻译的前世今生
\item 第二章\ 统计语言建模基础
\item 第三章\ 词法分析和语法分析基础
\item 第四章\ 翻译质量评价
\end{itemize}
\vspace{0.5em}
\item 第六章:神经机器翻译模型
\item 第二部分:统计机器翻译
\begin{itemize}
\item 第五章\ 基于词的机器翻译建模
\item 第六章\ 基于扭曲度和繁衍率的模型
\item 第七章\ 基于短语的模型
\item 第八章\ 基于句法的模型
\end{itemize}
\vspace{0.5em}
\item 第七章:神经机器翻译实战 \ \dash \ 参加一次比赛
\item 第三部分:神经机器翻译
\begin{itemize}
\item 第九章\ 人工神经网络基础及神经语言模型
\item 第十章\ 基于循环神经网络的模型
\item 第十一章\ 基于卷积神经网络的模型
\item 第十二章\ 基于自注意力的模型
\end{itemize}
\vspace{0.5em}
\item 第四部分:机器翻译前沿
\begin{itemize}
\item 第十三章\ 神经机器翻译模型训练
\item 第十四章\ 神经机器翻译模型推断
\item 第十五章\ 神经机器翻译结构优化
\item 第十六章\ 低资源机器翻译
\item 第十七章\ 多模态、多层次机器翻译
\item 第十八章\ 机器翻译工业实践
\end{itemize}
\end{itemize}
其中,第一章是对机器翻译的整体介绍。第二章和第五章是对统计建模和深度学习方法的介绍,分别建立了两个机器翻译范式的基础知识体系 \ \dash \ 统计机器翻译和神经机器翻译。统计机器翻译部分(第三、四章)涉及早期的基于单词的翻译模型,以及本世纪初流行的基于短语和句法的翻译模型。神经机器翻译(第六、七章)代表了当今机器翻译的前沿,内容主要涉及了基于端到端表示学习的机器翻译建模方法。特别地,第七章对一些最新的神经机器翻译方法进行了讨论,为相关科学问题的研究和实用系统的开发提供了可落地的思路。下图展示了本书各个章节及核心概念之间的关系。
\vspace{0.5em}
其中,第一部分是本书的基础知识部分,包含统计建模、语言分析、机器翻译评价等。在第一章对机器翻译的历史及现状进行介绍之后,第二章通过语言建模任务将统计建模的思想阐述出来,同时这部分内容也会作为后续机器翻译模型及方法的基础。第三章重点介绍机器翻译所涉及的词法和句法分析方法,旨在为后续相关概念的使用进行铺垫,同时进一步展示统计建模思想在相关问题上的应用。第四章相对独立,系统地介绍了机器翻译结果的评价方法,这部分内容也是机器翻译建模及系统设计所需的前置知识。
本书的第二部分主要介绍统计机器翻译的基本模型。第五章是整个机器翻译建模的基础。第六章进一步对扭曲度和产出率两个概念进行介绍,同时给出相关的翻译模型,这些模型在后续章节的内容中都有涉及。第七章和第八章分别介绍了基于短语和句法的模型。它们都是统计机器翻译的经典模型,其思想也构成了机器翻译成长过程中最精华的部分。
本书的第三部分主要介绍神经机器翻译模型,该模型也是近些年机器翻译的热点。第九章介绍了神经网络和深度学习的基础知识以保证本书知识体系的完备性。同时,第九章也介绍了基于神经网络的语言模型,其建模思想在神经机器翻译中被大量使用。第十、十一、十二章分别对三种经典的神经机器翻译模型进行介绍,以模型提出的时间为序,从最初的基于循环网络的模型,到最新的Transformer模型均有涉及。其中也会对编码器-解码器框架、注意力机制等经典方法和技术进行介绍。
{\red 用最简单的方式阐述机器翻译的基本思想}是笔者所期望达到的目标。但是,书中不可避免会使用一些形式化定义和算法的抽象描述,因此,笔者尽所能通过图例进行解释(本书共320张插图)。不过,本书所包含的内容较为广泛,难免会有疏漏,望读者海涵,并指出不当之处
本书的第四部分会进一步对机器翻译的前沿技术进行讨论,以神经机器翻译为主。第十三、十四、十五章是神经机器翻译研发的三个主要方面,也是近几年机器翻译领域讨论最多的几个方向。第十六章也是机器翻译的热门方向之一,包括无监督翻译等主题都会在这里被讨论。第十六章会对语音、图像翻译等多模态方法以及篇章级翻译等方法进行介绍,它们可以被看作是机器翻译在更多任务上的扩展。第十七章会结合笔者在各种机器翻译比赛和机器翻译产品研发的经验,对机器翻译系统搭建的具体流程和一些常见技术进行讨论,包括调优方法、前后处理等,都是机器翻译工业应用中的常见问题
%-------------------------------------------
\begin{figure}[htp]
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -131,24 +131,25 @@
% CHAPTERS
%----------------------------------------------------------------------------------------
\include{Chapter1/chapter1}
\include{Chapter2/chapter2}
\include{Chapter3/chapter3}
%\include{Chapter1/chapter1}
%\include{Chapter2/chapter2}
%\include{Chapter3/chapter3}
\include{Chapter4/chapter4}
\include{Chapter5/chapter5}
\include{Chapter6/chapter6}
\include{Chapter7/chapter7}
\include{Chapter8/chapter8}
\include{Chapter9/chapter9}
\include{Chapter10/chapter10}
\include{Chapter11/chapter11}
\include{Chapter12/chapter12}
\include{Chapter13/chapter13}
\include{Chapter14/chapter14}
\include{Chapter15/chapter15}
\include{Chapter16/chapter16}
\include{Chapter17/chapter17}
\include{ChapterAppend/chapterappend}
%\include{Chapter5/chapter5}
%\include{Chapter6/chapter6}
%\include{Chapter7/chapter7}
%\include{Chapter8/chapter8}
%\include{Chapter9/chapter9}
%\include{Chapter10/chapter10}
%\include{Chapter11/chapter11}
%\include{Chapter12/chapter12}
%\include{Chapter13/chapter13}
%\include{Chapter14/chapter14}
%\include{Chapter15/chapter15}
%\include{Chapter16/chapter16}
%\include{Chapter17/chapter17}
%\include{Chapter18/chapter18}
%\include{ChapterAppend/chapterappend}
%----------------------------------------------------------------------------------------
......
File mode changed from 100644 to 100755
......@@ -2,7 +2,7 @@
% !TEX encoding = UTF-8 Unicode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file was modified on top of
% This file was modified on top of
% The Legrand Orange Book
% Structural Definitions File
%
......@@ -10,7 +10,7 @@
% Mathias Legrand (legrand.mathias@gmail.com) with modifications by:
% Vel (vel@latextemplates.com)
%
% Current Version is maintained by
% Current Version is maintained by
% Tong Xiao (xiaotong@mail.neu.edu.cn)
% Runzhe Cao (854581319@qq.com)
%
......@@ -76,7 +76,7 @@
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------
\usepackage[style=numeric,citestyle=numeric,sorting=anyt,sortcites=true,maxbibnames=40,minbibnames=30,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]{biblatex}
\usepackage[style=numeric,citestyle=numeric,sorting=none,sortcites=true,maxbibnames=40,minbibnames=30,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber,autocite=plain]{biblatex}
%maxbibnames 设置参考文献最多显示作者数目
%minbibnames 如果作者数目超过maxbibnames,则只显示minbibnames个作者
\addbibresource{bibliography.bib} % BibTeX bibliography file
......@@ -212,6 +212,12 @@
\usepackage{amsmath,amsfonts,amssymb,amsthm} % For math equations, theorems, symbols, etc
\DeclareSymbolFont{EulerExtension}{U}{euex}{m}{n}%将积分号修改为正体
\DeclareMathSymbol{\euintop}{\mathop} {EulerExtension}{"52}
%\DeclareMathSymbol{\euointop}{\mathop} {EulerExtension}{"48}
\let\intop\euintop
%\let\ointop\euointop
\newcommand{\intoo}[2]{\mathopen{]}#1\,;#2\mathclose{[}}
\newcommand{\ud}{\mathop{\mathrm{{}d}}\mathopen{}}
\newcommand{\intff}[2]{\mathopen{[}#1\,;#2\mathclose{]}}
......@@ -238,7 +244,7 @@
{\small\bf\sffamily}% Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily{\tiny\ensuremath{\blacksquare}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
{\small\sffamily{\tiny\ensuremath{}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)\blacksquare去除
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note
\newtheoremstyle{blacknumbox} % Theorem style name
......@@ -348,12 +354,14 @@ leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=5pt]{cBox}
% Creates an environment for each type of theorem and assigns it a theorem text style from the "Theorem Styles" section above and a colored box from above
\newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}}
\newenvironment{exercise}{\begin{eBox}\begin{exerciseT}}{\hfill{\color{ocre}\tiny\ensuremath{\blacksquare}}\end{exerciseT}\end{eBox}}
\newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}}
\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}
%\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}
\newenvironment{example}{\begin{exampleT}}{\end{exampleT}}
\newenvironment{corollary}{\begin{cBox}\begin{corollaryT}}{\end{corollaryT}\end{cBox}}
%----------------------------------------------------------------------------------------
......@@ -560,6 +568,8 @@ addtohook={%
\usepackage{type1cm}%设置公式字体
\usepackage{caption}%设置图片标题字体大小
\captionsetup{font={footnotesize}}
\captionsetup[figure]{labelsep=quad}%图序号后面跟空格
\captionsetup[table]{labelsep=quad}%表序号后面跟空格
\usepackage{pstricks}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
......@@ -624,7 +634,7 @@ addtohook={%
\definecolor{ublue}{rgb}{0.152,0.250,0.545}
\definecolor{ugreen}{rgb}{0,0.5,0}
\definecolor{lgreen}{rgb}{0.9,1,0.8}
\definecolor{xtgreen1}{rgb}{0.824,0.898,0.8}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{xtgreen}{rgb}{0.914,0.945,0.902}
\definecolor{lightgray}{gray}{0.85}
......@@ -655,4 +665,26 @@ addtohook={%
\usepackage[mathscr]{euscript}
\newcommand{\mychapter}[1]{\ref{#1}}%chapter用
\newcommand{\mysection}[1]{\ref{#1}}%section、subsection、subsubsection用
\ No newline at end of file
\newcommand{\mysection}[1]{\ref{#1}}%section、subsection、subsubsection用
\newcommand\chapterone{第一章}%*
\newcommand\chaptertwo{第二章}%*
\newcommand\chapterthree{第三章}
\newcommand\chapterfour{第四章}
\newcommand\chapterfive{第五章}%*
\newcommand\chaptersix{第六章}
\newcommand\chapterseven{第七章}%*
\newcommand\chaptereight{第八章}
\newcommand\chapternine{第九章}%*
\newcommand\chapterten{第十章}%*
\newcommand\chaptereleven{第十一章}
\newcommand\chaptertwelve{第十二章}%*
\newcommand\chapterthirteen{第十三章}
\newcommand\chapterfourteen{第十四章}
\newcommand\chapterfifteen{第十五章}
\newcommand\chaptersixteen{第十六章}
\newcommand\chapterseventeen{第十七章}
\newcommand\chaptereighteen{第十八章}%*
\newcommand\funp{}%函数P等使用,空是斜体,textrm是加粗
\newcommand\vectorn{\mathbf}%向量N等使用
\newcommand\seq{\mathbf}%序列N等使用
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论