Lecture 9: Practical Tips for Final Projects

Here Insert Picture Description

The Final Project

  • Or do the default project --SQuAD Q & A
  • Or find yourself a project - must TA / prof / post / PhD agree
  • You can use any language / framework, recommended Pytorch

The Default Final Project

Building atextualquestionanswering systemforSQuAD
data sets: https://rajpurkar.github.io/SQuAD-explorer/
Example:
Here Insert Picture Description
should pay attention to several points
Here Insert Picture Description

Project Proposal

  1. Find a topic related to your research paper
    for the default project, a paper on SQuAD list on it, but you should probably look for some other interesting places from QA / reading-related work
  2. Write a research paper abstracts, describe how you want to use it or get ideas, and how you plan to extend or improve it to your final project work
  3. Description needed, especially for customized projects:
    a project plan, relevant existing literature, you will use the type of model / exploration; you will use data (and how to obtain), and how you will evaluate the success.

Project Milestone

  • This is a progress report
  • You should not give up halfway!
  • Describe experiments you have done
  • Preliminary results obtained as described
  • Describe how you intend to spend the rest of the time

Expected so far, you've implemented a number of systems, and have some preliminary results (except for certain unusual items)

Finding Research Topics

For all science, there are two kinds of methods at the beginning of the

  • [钉子]从感兴趣的(域)问题开始,并尝试找到比当前已知/使用的更好/更好的解决方法
  • [锤子]从感兴趣的技术方法开始,找出扩展或改进它的好方法或新的应用方法

Project types
这不是一个详尽的列表,但大多数项目是其中之一

  1. 兴趣的应用/任务,探索如何有效地接近/解决它,通常应用现有的神经网络模型
  2. 实现一个复杂的神经架构并在一些数据上演示其性能
  3. 提出一种新的或变异的神经网络模型并探索其实证成功
  4. 分析项目。分析一个模型的行为:它如何表示语言知识,它能处理什么样的现象或它所犯的错误
  5. 稀有理论项目:显示模型类型、数据或数据表示的一些有趣的、非平凡的属性

一些例子

  1. 使用词级别和字符级别的莎士比亚分格诗歌生成
    提出了门控LSTM
    Here Insert Picture Description

Here Insert Picture Description
3.
Here Insert Picture Description
4.
Here Insert Picture Description
How to find an interesting place to start?

  • 看ACL论文选集https://aclanthology.info
  • 也可以看主要的机器学习会议:NeurIPS,ICML,ICLR
  • 看cs224n过去的项目
  • 看看在线预印本服务器,尤其是: https://arxiv.org
  • 甚至可以在现实生活中找一个有趣的问题

一个统计各种任务当前最优解决方案的网站
https://paperswithcode.com/sota

**Finding a topic **

图灵奖获得者、斯坦福大学名誉教授艾德·费根鲍姆说,要听从他的导师艾未未先驱、图灵奖和诺贝尔奖获得者赫伯·西蒙的建议:
“如果你看到一个有很多人工作的研究领域,就去别的地方。”
“If you see a research area where many people are working, go somewhere else.”

对于大多数自定的项目,必须含有

  • 合适的数据,Usuallyaimingat:10,000+ labeled examples by milestone
  • 可行的任务
  • 自动评价标准
  • NLP是项目的中心

Finding data

  • 可以自己收集数据
    • 模型可能采用无监督数据
    • 可以自己标注少量数据
    • 可以找一个提供有效标注的网站,比如likes,stars,ratings等等
  • 大多数人使用前人建立的数据集

一些数据来源

再看门控循环单元和MT

直觉上,RNN会发生什么?

  1. 衡量过去对未来的影响
    Here Insert Picture Description
    如上图,相同颜色为所指。使用了链导法则,上式表明了过去( h t h_t )对未来( l o g p ( x t + n x < t + n ) logp(x_{t+n}|x_{<t+n}) )的影响,此影响用未来的误差对现在的偏导衡量
  2. 在t处的扰动是如何影响 l o g p ( x t + n x < t + n ) logp(x_{t+n}|x_{<t+n}) 的?
    Here Insert Picture Description

Backpropagation through Time

问题:梯度消失是个大问题

  • 当梯度为0时,我们无法判断
    1. 数据中t和t+n之间没有依赖关系,或者
    2. 参数配置错误(消失梯度条件)
  • 普通RNN是否存在这个问题
    Here Insert Picture Description
    存在,如下图,会导致梯度消失
    Here Insert Picture Description

Gated Recurrent Unit

  • 这意味着错误必须通过所有中间节点反向传播:
    Here Insert Picture Description
  • 也许我们可以创建自适应的快捷连接
    Here Insert Picture Description
    上图与HighwayNet很像,通过 u t u_t 向量控制哪部分数据(更新后的 ( ^ h t ) \hat (h_t) 还是未更新的 h t 1 h_{t-1} )传递下去
  • 或者让网络自适应地剪除不必要的连接Here Insert Picture Description
    注意图中的颜色,与上一种方法相比,这种方法增加了一个重置门。不再是全盘接收上一个时间步的隐藏状态,而是使用向量 r t r_t 来控制。

下面用图来总结普通RNN和门控RNN

  • 普通RNN:对于前一时间步的输出全盘读取,然后全盘更新
    Here Insert Picture Description

  • 门控RNN:
    改进在于

    • 不再是全盘读取,而是选择一个可读取子集,通过向量 γ \gamma 来决定前一时间步的输出 h h 有多少参与下一时间步的更新
    • 不再是全部更新到下一时间步,而是选择一个可写子集,通过向量 u u 来决定哪些数据( h h 还是 γ h \gamma \cdot h )选择为下一时间步的输出
      Here Insert Picture Description
      注:
      • 门控循环单元更加实际一些
      • 这里的思想与注意力有些重叠
  • 两个最常用的门控循环单元:GRU和LSTM
    GRU和我们之间讲的门控RNN差不多,而LSTM有三个门,其中两个来控制从之前的时间步读取多少内容,一个控制向下一时间步传递多少内容。
    Here Insert Picture Description

    • LSTM的计算图
      Here Insert Picture Description
      LSTM将所有的操作都用作门,所以所有的东西都可以被遗忘或者忽视。
      Here Insert Picture Description
      底部非线性的更新就和普通RNN相同
      Here Insert Picture Description
      上图中的这部分是关键点,这里没有使用乘,而是使用了加,将非线性的部分与 c t 1 c_{t-1} 相加得到 c t c_t ,类似 c t c_t c t 1 c_{t-1} 之间增加了一个直接的线性连接。(与最近出现的一些新的架构很类似,如ResNets)

The large output vocabulary problem in NMT (or all NLG)

Here Insert Picture Description

  • 在seq2seq任务中,我们在解码器部分生成目标序列时,在每个时间步都使用softmax对词表中所有单词求生成概率。这样会消耗大量计算资源
  • 词生成问题:词表规模适中,通常为50K

可能的解决方法

  • Hierarchical softmax:树结构的词表
  • Noise-contrastive estimation:binary classification
  • 一次训练一部分词汇;测试一组可能的翻译:Jean, Cho, Memisevic, Bengio. ACL2015
  • 使用注意力弄清楚你在翻译什么:你可以做一些简单的事情,比如查字典
  • 更多的想法:单词片段;char。模型

MT评价

  • 人工评价
    • 忠实度和流利度(5 or 7个分数段)
    • 错误分类
    • 翻译排名比较(例如人工判断两个翻译哪一个更好)
  • 在一个应用中测试,将MT作为子组件
    • 例如,外语文献问答
      • 可能无法测试翻译的许多方面(例如,跨语言信息检索)
  • 自动评测:BLEU、其余如TER,METEOR

BLEU Evaluation Metric

(Papineni et al, ACL-2002)

  • n-gram精确度(分数介于0~1)

    • n-gram既能衡量忠实度和流利度
    • 对不同n-gram结果几何平均加和
  • 简短惩罚:短的句子更容易得到高分,因此对较短的句子乘一个惩罚
    具体计算例子:https://www.cnblogs.com/by-dream/p/7679284.html

  • 初始的结果显示BLEU分数与人类判断具有线性相关
    Here Insert Picture Description

  • MT的自动评测

    • 人们开始优化系统来提高BLEU分数
      • BLEU分数很快增加
      • 但BLEU与人类对质量的判断之间的相关性一直在下降
      • BLEU的分数现在接近人工翻译的分数,但它们的真实质量仍然远远低于人工翻译
    • 提出自动机器翻译评估已经成为它自己的研究领域
      • 有很多建议:TER,METEOR,MaxSim,SEPIA,RTE-MT
      • TERpA 是一个具有代表性的,好处理一些词的选择变化的度量
    • MT研究需要一些自动的度量,以允许快速的开发和评估

如何做一个研究

  1. 定义任务,例如:Summarization(摘要)
  2. 定义数据集
    1. 寻找学术数据集
      它们已有baselines
      例如:Newsroom Summarization Dataset:https://summari.es/
    2. 定义自己的数据(更难一些,需要新的baselines)
      允许连接到自己的研究
      新的问题提供新的机会
      有创意:Twitter、博客、新闻等。有很多整洁的网站,为新的任务提供创造性的机会
  3. Dataset hygiene :分离 devtest 和 test,稍后会讨论更多
  4. 定义自己的度量
    在网上搜索在该任务上已有的度量方法
    摘要: Rouge (Recall-Oriented Understudy for GistingEvaluation) ,它定义了人工摘要的 n-gram重叠
    人工评价仍然更适合于摘要;你可以做一个小规模的人类计算
  5. 建立一个baseline
    首先实现一个最简单的模型(通常对unigrams、bigrams 或平均字向量进行逻辑回归)
    计算训练集和开发集的度量
    分析错误
    如果度量令人惊讶且没有错误,那么,完成!问题太简单了。需要重新找个任务
  6. 实现现有的神经网络模型
    计算训练集和开发集的指标
    分析输出和错误
    这门课的最低标准
  7. 永远要接近您的数据(除了最后的测试集),即要总是在当前数据集上进行实验,不能根据其他数据集去改进模型等等
    可视化数据集
    收集汇总统计信息
    查看错误
    分析不同的超参数如何影响性能
  8. 尝试一些不同的模型以及模型变体,旨在通过有一个好的实验设置快速迭代
    9.

Pots of data

  • 许多公开可用的数据集都是使用train/dev/test结构发布的。我们应该只在开发完成时才运行测试集
  • 这样的拆分以相当大的数据集为前提。
  • 如果没有dev集或者您想要一个单独的tune集,那么您可以通过分割训练数据来创建一个tune集,但你必须权衡它的大小/有用性与减少的train集大小
  • 有一个固定的测试集可以确保所有系统都是根据相同的gold数据进行评估的。这通常是好的,但是如果测试集具有不寻常的属性,从而扭曲了任务的进度,则会出现问题。

Training models and pots of data

  • 在训练时,可能会发生过拟合,即模型在训练集上表现很好,但在测试集上表现很差
  • 监测和避免过拟合的方法时使用独立的验证集(开发集)和测试集
    Here Insert Picture Description
  • 在训练集上建立(估计/训练)模型。
  • 通常,然后在另一组独立的数据上设置更多的超参数,即调整集(tuning set ),调整集是超参数的训练集!
  • 当您在dev set(开发测试集或验证集)上运行时,您可以测量进度;如果您经常这样做,那么您就太适合dev集了,所以最好有第二个dev集,即dev2集
  • 只有在最后,你才能在一个测试集上评估和呈现最终的数字•使用最终的测试集极值几次…理想情况下只有一次
  • train、tune、dev和testset必须完全不同
  • 在训练集上测试是无效的,你会得到一个错误的好成绩。因为可能在训练集上发生过拟合
  • 您需要一个独立的验证集,如果验证集与训练集相同,则无法正确设置超参数
  • 我们需要意识到,每一次通过评估结果的变化而完成的调整,都是对数据集的拟合过程。我们需要对数据集的过拟合,但是不可以在独立测试集上过拟合,否则就失去了测试集的意义

Getting your neural network to train

  • 以积极的态度开始
  • 认识到残酷的现实
    • 有很多事情会导致神经网络不会学习或学习的不好,找到并修正它们(“debuggingandtuning”)可能会花费比实现模型更多的时间
  • 很难弄清楚这些东西是什么,但经验、实验护理和经验法则会有帮助!

Models are sensitive to learning rates
Here Insert Picture Description
Models are sensitive to initialization
Here Insert Picture Description
Training a (gated) RNN

  1. Use LSTM or GRU: It makes your life a lot easier!
  2. Recursive matrix is ​​an orthogonal matrix Initialization
  3. With an appreciable proportion of a (small) initialize other matrix
  4. Forget door initialization deviation of 1: Default Remember
  5. Adaptive learning rate algorithm: Adam, AdaDelta, ...
  6. Gradient norm cut: 1-5 appear to be a reasonable threshold value, or when used with Adam AdaDelta
  7. Either use only dropout vertically, or studies using Bayesian dropout (Gal and Gahramani - PyTorch not natively support)
  8. be patient! Optimization takes time

Experimental strategy

  • Incremental work!
  • From the beginning of a very simple model
  • One by one add modifications to get it to work, so that the use of a model for each of them (or give them up)
  • Initially run on a small amount of data
    • You would be easier in a small data set to see the bug
    • Like eight such thing as a good example
    • Typically, this data is useful synthesis
    • Make sure you can get 100% data
      • Otherwise your model or certainly not strong enough, or is broken
  • In a large data set to run
    • Training data model optimization should still be close to 100%
      • Otherwise, you might want to consider a more powerful pattern over-fitting the training data
      • Overfitting the training data is not terrible during deep learning
        • These models are usually good at generalization, because the distributed shared statistics indicate strength, and overfitting the training data independent of
  • However, it still requires good generalization performance
    • The model regularization, until it does not fit the data with far too dev
    • Such as L2 regularization strategy is useful
    • But usually Dropout is the secret of success

Details matter!

  • View your data collect aggregate statistical information
  • Check your model's output, error analysis
  • Super tuning parameters are very important for almost all successful neural network

Reporting requirements
Here Insert Picture Description

Published 29 original articles · won praise 10 · views 7163

Guess you like

Origin blog.csdn.net/weixin_42017042/article/details/104175085