使用神经架构搜索的方法,为 seq2seq 任务找到了一种比Transformer更好的前馈网络架构。架构搜索是基于Transformer进行演进,最终得到的Evolved Transformer 的新架构在四个成熟的语言任务(WMT 2014 英德、WMT 2014 英法、WMT 2014 英捷及十亿词语言模型基准(LM1B))上的表现均优于原版 Transformer。在用大型模型进行的实验中,Evolved Transformer 的效率(FLOPS)是 Transformer 的两倍,而且质量没有损失。在更适合移动设备的小型模型(参数量为 7M)中,Evolved Transformer 的 BLEU 值高出 Transformer 0.7。
国防科技大学 & MSRA 2019-2-26
摘要是指: “一段从一份或多份文本中提取出来的文字,它包含了原文本中的重要信息,其长度不超过或远少于原文本的一半”。自动文本摘要旨在通过机器自动输出简洁、流畅、保留关键信息的摘要。
自动文本摘要通常可分为两类,分别是抽取式(extractive)和生成式(abstractive)。抽取式摘要判断原文本中重要的句子,抽取这些句子成为一篇摘要。而生成式方法则应用先进的自然语言处理的算法,通过转述、同义替换、句子缩写等技术,生成更凝练简洁的摘要。比起抽取式,生成式更接近人进行摘要的过程。历史上,抽取式的效果通常优于生成式。伴随深度神经网络的兴起和研究,基于神经网络的生成式文本摘要得到快速发展,并取得了不错的成绩。
问题一:在监督式训练中,对一篇文本一般往往只提供一个参考摘要,基于 MLE 的监督式训练只鼓励模型生成一模一样的摘要,然而正如在介绍中提到的,对于一篇文本,往往可以有不同的摘要,因此监督式学习的要求太过绝对。
针对这个问题论文作者提出了两个解决问题:1.两阶段的summary生成方法;2.使用mixed objective优化误差。
生命是一种长期而持续的累积过程,绝不会因为单一的事件而毁了一个人的一生,也不会因为单一的事件而救了一个人的一生。属于我们该得的,迟早会得到;属于我们不该得的,即使侥幸巧取也不可能长久保有。如果我们看清这个事实,许多所谓“人生的重大抉择”就可以淡然处之,根本无需焦虑。而所谓”人生的困境”,也往往当下就变得无足挂齿。
——台湾清华彭明辉教授
聊天机器人的应用场景十分丰富,包括用户服务或者在线自动回复。以往的聊天机器人是基于自动的检索系统,根据用户的输入自动选取最合适的回答。这种机制在需要多领域知识或领域知识快速迭代的应用场景就显得捉襟见肘。使用深度学习的方法,只要提供语料库,机器就能够从中学习到对话的能力。
解析文本:
['lineID', 'characterID', 'movieID', 'characher', 'text']
;['character1ID', 'character2ID', 'movieID', 'utterranceIDs','lines']
,lines是根据uterranceIDs从第一步得到的字典中获取的台词。[inputLine, targetLine]
的列表。这里就得到了可以用于训练的原始问答对话qa_pairs。将qa_pairs写入datafile.csv文件,每行为一对问答。创建一个Voc词汇类,功能包括:
在将文本用于创建Voc词汇表之前,对文本进行编码转化、标准化和过滤
normalize()
第一个参数指定字符串标准化的方式。 NFC表示字符应该是整体组成(比如可能的话就使用单一编码),而NFD表示字符应该分解为多个组合字符表示。将文本pa_pair向量化,并通过pad方法成(max_length, batch_size)的形状
itertools.zip(*l, fillvalue='PAD')
进行空白部分的填充。返回填充后的index_batch和batch中个句子的长度lengths聊天机器人的核心:seq2seq
RNN/GRU/LSTM
的结果.定义训练步骤
定义输入的evaluate函数,对输入的句子生成回答
整个训练过程整合
超参数设置:
model_name | attn_model | hidden_size | encoder_n_layers | decoder_n_layers |
---|---|---|---|---|
cb_model | dot | 500 | 2 | 2 |
dropout | batch_size | checkpoint_iter | ||
0.1 | 64 | 400 |
初始化embedding层:nn.Embedding(voc.num_words, hidden_size)
初始化encoder = EncoderRNN(hidden_size, embedding, encoder_n_layers, dropout)
初始化decoder = LuongAttnDecoderRNN(attn_model, embedding, hidden_size, , voc.num_words, decoder_n_layers, dropout)
训练模型
clip | teacher_forcing_ratio | decoder_learning_ratio | n_iteration | print_every |
---|---|---|---|---|
50 | 1.0 | 5.0 | 4000 | 1 |
save_every | ||||
500 |
预测