Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
M
mtbookv2
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
NiuTrans
mtbookv2
Commits
8f6870b6
Commit
8f6870b6
authored
Jan 24, 2021
by
曹润柘
Browse files
Options
Browse Files
Download
Plain Diff
合并分支 'caorunzhe' 到 'master'
Caorunzhe 查看合并请求
!969
parents
e36c44f1
73668afe
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
20 行增加
和
14 行删除
+20
-14
Chapter13/Figures/figure-difference-between-word-level-and-sequence-level-in-knowledge-distillation.tex
+10
-8
Chapter13/Figures/figure-unk-of-bpe.tex
+6
-2
Chapter13/chapter13.tex
+0
-0
Chapter15/chapter15.tex
+1
-1
Chapter4/chapter4.tex
+1
-1
Chapter9/chapter9.tex
+2
-2
没有找到文件。
Chapter13/Figures/figure-difference-between-word-level-and-sequence-level-in-knowledge-distillation.tex
查看文件 @
8f6870b6
...
...
@@ -32,8 +32,8 @@
\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)
{
}
;
\node
[prob,minimum size=0.
1cm,anchor=center] (prob43) at ([yshift=-0.5cm]prob33.center)
{
}
;
\node
[prob,minimum size=0.
4cm,anchor=center] (prob53) at ([yshift=-0.5cm]prob43.center)
{$
.
6
$
}
;
\begin{pgfonlayer}
{
background
}
\coordinate
(bottomleft) at ([shift=
{
(-0.25cm,-0.25cm)
}
]prob53.center);
\coordinate
(topright) at ([shift=
{
(0.25cm,0.25cm)
}
]prob13.center);
...
...
@@ -76,15 +76,16 @@
\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)
{$
\langle
$
eos
$
\rangle
$}
;
\node
[word,anchor=south] (input1) at ([yshift=-1.8
7
cm]prob1.south)
{$
\langle
$
eos
$
\rangle
$}
;
\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
}
\foreach
\i
in
{
2,3
,4
}
\draw
[-latex,thick] ([yshift=0.3cm]input
\i
.south) to ([yshift=0.8cm]input
\i
.south);
\draw
[-latex,thick] ([yshift=0.36cm]input1.south) to ([yshift=0.86cm]input1.south);
\node
[word,anchor=south] (ns) at ([xshift=-1
cm]input1.south)
{
输入
:
}
;
\node
[word,anchor=south] (ns) at ([xshift=-1
.2cm]input1.south)
{
真实数据
:
}
;
\node
[word,anchor=north] () at ([xshift=2.1cm,yshift=-0.5cm]ns.south)
{
(a)
\
Word-level
}
;
\end{scope}
...
...
@@ -163,16 +164,17 @@
\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)
{$
\langle
$
eos
$
\rangle
$}
;
\node
[word,anchor=south] (input1) at ([yshift=-1.8
5
cm]prob1.south)
{$
\langle
$
eos
$
\rangle
$}
;
\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
}
\foreach
\i
in
{
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);
\draw
[-latex,thick] ([yshift=0.36cm]input1.south) to ([yshift=0.86cm]input1.south);
\node
[word,anchor=south] (ns) at ([xshift=-1
cm]input1.south)
{
输入
:
}
;
\node
[word,anchor=south] (ns) at ([xshift=-1
.2cm]input1.south)
{
教师译文
:
}
;
\node
[word,anchor=north] () at ([xshift=2.1cm,yshift=-0.5cm]ns.south)
{
(b)
\
Sequence-level
}
;
\end{scope}
\end{tikzpicture}
Chapter13/Figures/figure-unk-of-bpe.tex
查看文件 @
8f6870b6
...
...
@@ -3,23 +3,27 @@
\node
[rounded corners=3pt,minimum width=1.0em,minimum height=2.0em,font=\scriptsize,fill=red!10,drop shadow,thick]
(top) at (0,0)
{
\begin{tabular}
{
lllllll
}
\multicolumn
{
7
}{
c
}{
符号合并表
}
\\
(r,
$
<
$
e
$
>
$
),
&
(e,s),
&
(l,o),
&
(es,t),
&
(lo,w),
&
(est,
$
<
$
e
$
>
$
),
&
(e,r
$
<
$
e
$
>
$
)
,
(r,
$
<
$
e
$
>
$
),
&
(e,s),
&
(l,o),
&
(es,t),
&
(lo,w),
&
(est,
$
<
$
e
$
>
$
),
&
(e,r
$
<
$
e
$
>
$
)
\end{tabular}
}
;
\node
[font=\footnotesize,anchor=north]
(l1) at ([xshift=0em,yshift=-1em]top.south)
{
(a) 符号合并表
}
;
\node
[font=\scriptsize,anchor=west]
(n1) at ([xshift=-4.5em,yshift=-6em]top.west)
{
l
\
o
\
w
\
e
\
r
\
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(n2) at ([xshift=2.6em]n1.east)
{
l
\
o
\
w
\
e
\
{
\red
r
$
<
$
e
$
>
$}}
;
\node
[font=\scriptsize,anchor=west]
(n3) at ([xshift=2.6em]n2.east)
{{
\red
lo
}
\
w
\
e
\
r
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(n4) at ([xshift=2.6em]n3.east)
{{
\red
low
}
\
e
\
r
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(n5) at ([xshift=2.6em]n4.east)
{
low
\
{
\red
er
$
<
$
e
$
>
$}}
;
\node
[font=\scriptsize,anchor=west]
(t1) at ([yshift=-
1
.5em]n1.south west)
{
l
\
o
\
w
\
e
\
s
\
t
\
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(t1) at ([yshift=-
2
.5em]n1.south west)
{
l
\
o
\
w
\
e
\
s
\
t
\
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(t2) at ([xshift=0.8em]t1.east)
{
l
\
o
\
w
\
{
\red
es
}
\
t
\
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(t3) at ([xshift=0.8em]t2.east)
{{
\red
lo
}
\
w
\
es
\
t
\
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(t4) at ([xshift=0.8em]t3.east)
{
lo
\
w
\
{
\red
est
}
\
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(t5) at ([xshift=0.8em]t4.east)
{{
\red
low
}
\
est
\
$
<
$
e
$
>
$}
;
\node
[font=\scriptsize,anchor=west]
(t6) at ([xshift=0.8em]t5.east)
{
low
\
{
\red
est
$
<
$
e
$
>
$}}
;
\node
[font=\scriptsize,anchor=north east]
(s1) at ([yshift=0.1em]n1.north west)
{
样例1:
}
;
\node
[font=\scriptsize,anchor=north east]
(s1) at ([yshift=0.1em]t1.north west)
{
样例2:
}
;
\node
[font=\footnotesize,anchor=north]
(l2) at ([xshift=2em,yshift=-1em]t3.south)
{
(b) 合并样例
}
;
\draw
[->,thick]
(n1.east) -- (n2.west);
...
...
Chapter13/chapter13.tex
查看文件 @
8f6870b6
差异被折叠。
点击展开。
Chapter15/chapter15.tex
查看文件 @
8f6870b6
...
...
@@ -46,7 +46,7 @@
\parinterval
但是,Transformer模型中的自注意力机制本身并不具有这种性质,而且它直接忽略了输入单元之间的位置关系。虽然,Transformer中引入了基于正余弦函数的绝对位置编码(见
{
\chaptertwelve
}
),但是该方法仍然无法显性区分局部依赖与长距离依赖
\footnote
[1]
{
局部依赖指当前位置与局部的相邻位置之间的联系。
}
。
\parinterval
针对上述问题,研究人员设计了“相对位置”编码,对原有的“绝对位置”编码进行补充,强化了局部依赖
\upcite
{
Dai2019TransformerXLAL,Shaw2018SelfAttentionWR
}
。此外,由于模型中每一层均存在自注意力机制计算,因此模型捕获位置信息的能力也逐渐减弱,这种现象在深层模型中尤为明显。而利用相对位置编码能够把位置信息显性加入到每一层的注意力机制的计算中,进而强化深层模型中局部位
相对位置编码和绝对位置编码方法置
的表示能力
\upcite
{
li2020shallow
}
。图
\ref
{
fig:15-1
}
对比了Transformer中相对位置编码和绝对位置编码方法。
\parinterval
针对上述问题,研究人员设计了“相对位置”编码,对原有的“绝对位置”编码进行补充,强化了局部依赖
\upcite
{
Dai2019TransformerXLAL,Shaw2018SelfAttentionWR
}
。此外,由于模型中每一层均存在自注意力机制计算,因此模型捕获位置信息的能力也逐渐减弱,这种现象在深层模型中尤为明显。而利用相对位置编码能够把位置信息显性加入到每一层的注意力机制的计算中,进而强化深层模型中局部位
置相对位置编码和绝对位置编码方法
的表示能力
\upcite
{
li2020shallow
}
。图
\ref
{
fig:15-1
}
对比了Transformer中相对位置编码和绝对位置编码方法。
%----------------------------------------------
\begin{figure}
[htp]
...
...
Chapter4/chapter4.tex
查看文件 @
8f6870b6
...
...
@@ -211,7 +211,7 @@
\parinterval
在这个实例中,将机器译文序列转换为参考答案序列,需要进行两次替换操作,将“A” 替换为“The”,将“in” 替换为“on”。所以
$
\textrm
{
edit
}
(
c,r
)
$
= 2,归一化因子
$
l
$
为参考答案的长度8(包括标点符号),所以该机器译文的TER 结果为2/8。
\parinterval
PER与
TER的基本思想与W
ER相同,这三种方法的主要区别在于对“错误” 的定义和考虑的操作类型略有不同。WER使用的编辑操作包括:增加、删除、替换,由于没有移位操作,当机器译文出现词序问题时,会发生多次替代,因而一般会低估译文质量;而PER只考虑增加和删除两个动作,在不考虑词序的情况下,PER计算两个句子中出现相同单词的次数,根据机器译文与参考答案的长度差距,其余操作无非是插入词或删除词,这样往往会高估译文质量。
\parinterval
PER与
WER的基本思想与T
ER相同,这三种方法的主要区别在于对“错误” 的定义和考虑的操作类型略有不同。WER使用的编辑操作包括:增加、删除、替换,由于没有移位操作,当机器译文出现词序问题时,会发生多次替代,因而一般会低估译文质量;而PER只考虑增加和删除两个动作,在不考虑词序的情况下,PER计算两个句子中出现相同单词的次数,根据机器译文与参考答案的长度差距,其余操作无非是插入词或删除词,这样往往会高估译文质量。
%----------------------------------------------------------------------------------------
% NEW SUBSUB-SECTION
...
...
Chapter9/chapter9.tex
查看文件 @
8f6870b6
...
...
@@ -1597,11 +1597,11 @@ z_t&=&\gamma z_{t-1}+(1-\gamma) \frac{\partial J}{\partial {\theta}_t} \cdot \f
\subsection
{
过拟合
}
\label
{
sec:9.4.5
}
\parinterval
理想中,我们总是希望尽可能地拟合输入和输出之间的函数关系,即让模型尽量模拟训练数据
的
中由输入预测答案的行为。然而,在实际应用中,模型在训练数据上的表现不一定代表了其在未见数据上的表现。如果模型训练过程中过度拟合训练数据,最终可能无法对未见数据做出准确的判断,这种现象叫做
{
\small\sffamily\bfseries
{
过拟合
}}
\index
{
过拟合
}
(Overfitting)
\index
{
Overfitting
}
。随着模型复杂度增加,特别在神经网络变得更深、更宽时,过拟合问题会表现得更为突出。如果训练数据量较小,而模型又很复杂,可以“完美”地拟合这些数据,这时过拟合也很容易发生。所以在模型训练时,往往不希望去完美拟合训练数据中的每一个样本。
\parinterval
理想中,我们总是希望尽可能地拟合输入和输出之间的函数关系,即让模型尽量模拟训练数据中由输入预测答案的行为。然而,在实际应用中,模型在训练数据上的表现不一定代表了其在未见数据上的表现。如果模型训练过程中过度拟合训练数据,最终可能无法对未见数据做出准确的判断,这种现象叫做
{
\small\sffamily\bfseries
{
过拟合
}}
\index
{
过拟合
}
(Overfitting)
\index
{
Overfitting
}
。随着模型复杂度增加,特别在神经网络变得更深、更宽时,过拟合问题会表现得更为突出。如果训练数据量较小,而模型又很复杂,可以“完美”地拟合这些数据,这时过拟合也很容易发生。所以在模型训练时,往往不希望去完美拟合训练数据中的每一个样本。
\parinterval
{
\small\sffamily\bfseries
{
正则化
}}
\index
{
正则化
}
(Regularization)
\index
{
Regularization
}
是常见的缓解过拟合问题的手段,通过在损失函数中加上用来刻画模型复杂程度的正则项来惩罚过度复杂的模型,从而避免神经网络过度学习造成过拟合。引入正则化处理之后目标函数变为
$
J
(
{
\bm
\theta
}
)+
\lambda
R
(
{
\bm
\theta
}
)
$
,其中
$
J
(
{
\bm
\theta
}
)
$
是原来的代价函数,
$
R
(
{
\bm
\theta
}
)
$
即为正则项,
$
\lambda
$
用来调节正则项对结果影响的程度。
\parinterval
过拟合的模型通常会表现为部分非零参数过多或者参数的值过大。这种参数产生的原因在于模型需要复杂的参数才能匹配样本中的个别现象甚至噪声。基于此,常见的正则化方法有L1正则化和L2正则化,其命名方式是由
$
R
(
{
\bm
\theta
}
)
$
的计算形式来决定的。在L1正则化中,
$
R
(
{
\bm
\theta
}
)
$
即为参数
$
{
\bm
\theta
}
$
的
$
l
_
1
$
范数,即
$
R
(
{
\bm
\theta
}
)
=
{
\Vert
{
\bm
\theta
}
\Vert
}_
1
=
\sum\limits
_{
i
=
1
}^{
n
}{
\vert
\theta
_
i
\vert
}
$
;在L2正则化中,
$
R
(
\bm
\theta
)
$
即为参数
${
\bm
\theta
}
$
的
$
l
_
2
$
范数的平方,即
$
R
(
\bm
\theta
)
=(
{
\Vert
{
\bm
\theta
}
\Vert
}_
2
)
^
2
=
\sum\limits
_{
i
=
1
}^{
n
}{
\theta
_
i
^
2
}
$
。L1正则化中的正则项衡量了模型
权数中
的绝对值大小,倾向于生成值为0的参数,从而让参数变得更加稀疏;而L2正则化由于平方的加入,当参数中的某一项小到一定程度,比如0.001的时候,参数的平方结果已经可以忽略不计了,因此L2正则化会倾向生成很小的参数,在这种情况下,即便训练数据中含有少量随机噪音,模型也不太容易通过增加个别参数的值来对噪声进行过度拟合,即提高了模型的抗扰动能力。
\parinterval
过拟合的模型通常会表现为部分非零参数过多或者参数的值过大。这种参数产生的原因在于模型需要复杂的参数才能匹配样本中的个别现象甚至噪声。基于此,常见的正则化方法有L1正则化和L2正则化,其命名方式是由
$
R
(
{
\bm
\theta
}
)
$
的计算形式来决定的。在L1正则化中,
$
R
(
{
\bm
\theta
}
)
$
即为参数
$
{
\bm
\theta
}
$
的
$
l
_
1
$
范数,即
$
R
(
{
\bm
\theta
}
)
=
{
\Vert
{
\bm
\theta
}
\Vert
}_
1
=
\sum\limits
_{
i
=
1
}^{
n
}{
\vert
\theta
_
i
\vert
}
$
;在L2正则化中,
$
R
(
\bm
\theta
)
$
即为参数
${
\bm
\theta
}
$
的
$
l
_
2
$
范数的平方,即
$
R
(
\bm
\theta
)
=(
{
\Vert
{
\bm
\theta
}
\Vert
}_
2
)
^
2
=
\sum\limits
_{
i
=
1
}^{
n
}{
\theta
_
i
^
2
}
$
。L1正则化中的正则项衡量了模型
中参数
的绝对值大小,倾向于生成值为0的参数,从而让参数变得更加稀疏;而L2正则化由于平方的加入,当参数中的某一项小到一定程度,比如0.001的时候,参数的平方结果已经可以忽略不计了,因此L2正则化会倾向生成很小的参数,在这种情况下,即便训练数据中含有少量随机噪音,模型也不太容易通过增加个别参数的值来对噪声进行过度拟合,即提高了模型的抗扰动能力。
\parinterval
此外,在
{
\chaptertwelve
}
即将介绍的Dropout和标签平滑方法也可以被看作是一种正则化操作。它们都可以提高模型在未见数据上的泛化能力。
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论