本文的内容主要是基于英法平行语料库来实现一个简单的英法翻译模型。没有使用注意力机制和双向LSTM等技术,主要是为了掌握基本的Seq2Seq结构和TensorFlow函数使用。使用TensorFlow 1.12.0,主要依靠 tf.contrib.seq2seq.BasicDecoder 函数。python
手撸可运行代码 github.com/yuanxiaosc/…git
【Input】
Word Ids: [120, 89, 131, 217, 171, 38, 180, 204, 208, 89, 103, 192, 213, 177]
English Words: ['france', 'is', 'never', 'cold', 'during', 'september', ',', 'and', 'it', 'is', 'snowy', 'in', 'october', '.']
【Prediction】
Word Ids: [47, 235, 302, 325, 64, 204, 127, 81, 284, 117, 302, 72, 204, 63, 256, 1]
French Words: ['la', 'france', 'est', 'jamais', 'froid', 'en', 'septembre', ',', 'et', 'il', 'est', 'neigeux', 'en', 'janvier', '.', '<EOS>']
【Full Sentence】
la france est jamais froid en septembre , et il est neigeux en janvier . <EOS>
复制代码
Code reference github.com/NELSONZHAO/…github
基于TensorFlow框架的Seq2Seq英法机器翻译模型bash
更多机器翻译实战 github.com/yuanxiaosc/…函数