Current statistical machine translation systems
源语言:法语
目标语言:英语
概率公式(利用贝叶斯定理):

在平行语料库(parallel corpora)上训练翻译模型p(f|e)
在英语语料库上训练语言模型p(e)

Step1: Alignment
目标:将源语言中的单词或者短语匹配到正确的目标语言中的单词或者短语

假如匹配好了单词和短语,那么又如何给这些单词和短语重新排序呢?

After many steps
每个源语言中的单词或者短语,在目标语言中都有不止一个相匹配的单词或者短语:

Decode: Search for best of many hypotheses

TradiBonal MT(Machine Translation)
直接跳过非常多的细节部分
需要非常多的人工处理特征信息
非常复杂的系统
Deep learning to the rescue! … ?
也许我们能直接使用RNN做机器翻译

MT with RNNs – Simplest Model

最小化基于源语言,对应的目标语言中的词的交叉熵:

然而并没有这么的简单:)
RNN Translation Model Extensions
1)decoding和encoding部分,训练得到的RNN的Weeights是不一样的:


2)在解码时,根据下面的三项计算当前的hidden层:
1.之前的hidden层
2.上一个编码器的hidden层:c=hT
3.之前预测得到的词yt-1


对上一幅图更详细的描述

3)训练多层 stacked/deep RNNs
4)也可训练双向RNN

5)将输入序列反向后训练,以使得优化更加简单,如:A B C-》X Y换成C B A-》X Y
6)Main Improvement: Better Units。在循环的时候使用更加复杂的hidden units,如Gated Recurrent Units(GRU)
GRUs
标准的RNN直接计算下一个time step的hidden layer:

而在GRU中,则是先计算一个update gate,update gate是由当前的输入向量以及上一个hidden 层决定:

再用不同的Weights计算reset gate

由update gate和reset gate的公式可以得到新的记忆内容,如果reset gate接近于0,则忽略之前的记忆单元(隐层单元),只取当前time step的词向量:

最终的time step的记忆单元(隐层单元)公式:

下面这张图有利于你理解GRU:

GRU intuition
如果reset gate接近于0,则忽略之前hidden层的h。这样做的好处是可以丢弃和后面训练过程无关的信息。
update gate z的作用则是控制之前的部分对当前time step计算结果的影响程度(大小)。如果z接近于1,我们就可以将信息直接copy过来,这样的话有利于避免vanishing gradient。
短期依赖(short term dependences)的reset gate很活跃
长期依赖(long term dependendces)的update gate很活跃
参考图:

x1*x2对x1的导数如何求?同样使用的是链式法则,不同的是这里是通过模块化(modularization)和自定区划(automatic differentiation)实现的
Long-‐short-‐term-‐memories(LSTMs)
我们可以使传统RNN中的单个Unit(time step)更加复杂
可以在每个time step中添加下图中的几项:

最终的记忆单元:

最终得到的hidden层的计算公式:

LSTM详解图:

LSTMs are currently very hip!
LSTM是大多数序列标记任务的默认模型
非常的管用,特别是在使模型deeper之后(即每一个hidden层都是由一个内部的深度网络计算得到)
数据越多越管用
但是Deep LSTM和一些传统的MT方法的测试结果相差不大:

Further Improvements: More Gates!
