自然语言处理(六): Deep Learning for NLP: Feedforward Networks

这篇具有很好参考价值的文章主要介绍了自然语言处理(六): Deep Learning for NLP: Feedforward Networks。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

1. Deep Learning

1.2 Feed-forward NN

1.3 Neuron

1.4 Matrix Vector Notation 矩阵向量表示法

1.5 Output Layer

1.6 Learning from Data

1.7 Regularisation 正则化

1.8 Dropout

2. Applications in NLP

2.1 Topic Classification

2.2 Topic Classification - Training

2.3 Topic Classification - Prediction

2.4 Topic Classification - Improvements

2.5 Language Model Revisited

2.6 Language Models as Classifiers

2.6 Feed-forward NN Language Model

2.7 Word Embeddings

2.8 Topic Classification 

2.9 Training a FFNN LM

2.10 Input and Output Word Embeddings

2.11 Language Model: Architecture

2.12 Advantages of FFNN LM 

3. Convolutional Networks

3.1 Convolutional Networks for NLP

4. Final Words


1. Deep Learning

  • A branch of machine learning 机器学习的一个分支
  • Re-branded name for neural networks 神经网络的改名
  • Why deep? Many layers are chained together in modern deep learning models 为什么是深度?在现代深度学习模型中,许多层都是连在一起的。
  • Neural networks: historically inspired by the way computation works in the brain 神经网络:历史上受到大脑中计算方式的启发
    • Consists of computation units called neurons 由称为神经元的计算单元组成

1.2 Feed-forward NN

  • Aka multilayer perceptrons 又名多层感知器
  • Each arrow carries a weight, reflecting its importance 每个箭头都有一个权重,反映其重要性
  • Certain layers have nonlinear activation functions 某些层有非线性激活函数

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

1.3 Neuron

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

Each neuron is a function 每个神经元都是一个函数

- given input x, computes real-value (scalar) h 给定输入x,计算实值(标量)

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

- scales input (with weights, w) and adds offset (bias, b)

- applies non-linear function:

  • logistic sigmoid
  • hyperbolic sigmoid (tanh)
  • rectified linear unit

- w and b are parameters of the model

1.4 Matrix Vector Notation 矩阵向量表示法

- Typically have several hidden units, i.e.

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

- Each with its own weights (自然语言处理(六): Deep Learning for NLP: Feedforward Networks) and bias term (自然语言处理(六): Deep Learning for NLP: Feedforward Networks)

- Can be expressed using matrix and vector operators 可以用矩阵和向量运算符表示

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

- Where 自然语言处理(六): Deep Learning for NLP: Feedforward Networks a matrix comprisine the weight vectors, and 自然语言处理(六): Deep Learning for NLP: Feedforward Networks is a vector of all bias terms

- Non-linear function applied element-wise 非线性函数的单元应用

1.5 Output Layer

- Binary classification problem, e.g. classify whether a tweet is + or - in sentiment

  • sigmoid activation function

- Multi-class classification problem, e.g. native language identification

  • softmax ensures probabilities > 0 and sum to 1

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

1.6 Learning from Data

- How to learn the parameters from data?

- Consider how well the model "fits" the training data, in terms of the probability it assigns to the correct output

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

  • want to maximise total probability, L 想要使总概率最大化,L
  • equivalently minimise -log L with respect to parameters 等效地使-log L 相对于参数最小化

- Trained using gradient descent 用梯度下降法训练的

  • tools like tensorflow, pytorch, dynet use autodiff to compute gradients automatically

1.7 Regularisation 正则化

- Have many parameters, overfits easily 有很多参数,很容易过拟合

- Low bias, high variance 过拟合的体现就是偏差小,方差大

- Regularisation is very very important in NNs 正规化在NNs中非常重要

- L1-norm: sum of absolute values of all parameters (W, b, etc)  所有参数(W、 b 等)的绝对值之和

- L2-norm: sum of squares 平方和

- Dropout: randomly zero-out some neurons of a layer 随机地使一层中的某些神经元中断

1.8 Dropout

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

- If dropout rate = 0.1, a random 10% of neurons now have 0 values 如果辍学率 = 0.1,那么随机抽取的10% 的神经元现在的值为0

- Can apply dropout to any layer, but in practice, mostly to the hidden layers 可以应用到任何图层,但在实践中,大多数是隐藏的图层

2. Applications in NLP

2.1 Topic Classification

Given a document, classify it into a predefined set of topics (e.g. economy, politics, sports) 给定一个文档,将其分类为一组预定义的主题(如经济、政治、体育)

Input: bag-of-words

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

2.2 Topic Classification - Training

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

2.3 Topic Classification - Prediction

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

2.4 Topic Classification - Improvements

- + Bag of bigrams as input

- Preprocess text to lemmatise words and remove stopwords 对文本进行预处理,使单词词干化,并删除stopwords

- Instead of raw counts, we can weight words using TF-IDF or indicators (0 or 1 depending on presence of words) 我们可以使用 TF-IDF 或指示器(0或1取决于单词的存在)来为单词加权,而不是原始计数

2.5 Language Model Revisited

- Assign a probability to a sequence of words 给一系列单词赋予一个概率

- Framed as "sliding a window" over the sentence, predicting each word from finite context 在句子上方设置“滑动窗口”,从有限的上下文中预测每个单词

        E.g., n=3, a trigram model 例如,n = 3,一个三元模型

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

- Training involves collecting frequency counts 训练包括收集频率计数

- Difficulty with rare events 一 smoothing 平滑

2.6 Language Models as Classifiers

- LMs can be considered simple classifiers, e.g. for a trigram model LM 可以被认为是简单的分类器,例如对于一个三元模型:

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

- classifies the likely next word in a sequence, given “salt” and “and” 根据“ salt”和“ and”将可能的下一个单词按顺序分类

2.6 Feed-forward NN Language Model

- Use neural network as a classifier to model 使用神经网络作为分类器进行建模

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

- Input features = the previous two words 输入特征 = 前两个单词

- Output class = the next word 输出类 = 下一个单词

- How to represent words? Embeddings 如何表示单词? Embeddings

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

2.7 Word Embeddings

- Maps discrete word symbols to continuous vectors in a relatively low dimensional space 在一个相对低维的空间中将离散的单词符号映射到连续的向量

- Word embeddings allow the model to capture similarity between words 词语嵌入允许模型捕获词语之间的相似性

  • dog vs. cat
  • walking vs. running

2.8 Topic Classification 

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

2.9 Training a FFNN LM

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

2.10 Input and Output Word Embeddings

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

2.11 Language Model: Architecture

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

2.12 Advantages of FFNN LM 

- Count-based N-gram models (lecture 3) 基于计数的 N-gram 模型

  • cheap to train (just collect counts) 
  • problems with sparsity and scaling to larger contexts
  • don't adequately capture properties of words (grammatical and semantic similarity ), e.g., film vs movie 不能充分捕捉单词的属性(语法和语义相似性)

- FFNN N-gram models

  • automatically capture word properties, leading to more robust estimates

3. Convolutional Networks

- Commonly used in computer vision 常用于计算机视觉

- Identify indicative local predictors 识别指示性局部预测因子

- Combine them to produce a fixed-size representation 将它们组合起来生成一个固定大小的表示

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

3.1 Convolutional Networks for NLP

自然语言处理(六): Deep Learning for NLP: Feedforward Networks

4. Final Words

Pros

- Excellent performance

- Less hand-engineering of features

- Flexible — customised architecture for different tasks

Cons

- Much slower than classical ML models... needs GPU

- Lots of parameters due to vocabulary size

- Data hungry, not so good on tiny data sets文章来源地址https://www.toymoban.com/news/detail-406738.html

  • Pre-training on big corpora helps

到了这里,关于自然语言处理(六): Deep Learning for NLP: Feedforward Networks的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • NLP(自然语言处理)

     一、NLP是什么 自然语言处理( Natural Language Processing, NLP)是计算机科学领域与人工智能领域中的一个重要方向。它研究能实现人与计算机之间用自然语言进行有效通信的各种理论和方法。自然语言处理是一门融语言学、计算机科学、数学于一体的科学。因此,这一领域的研究

    2024年02月02日
    浏览(43)
  • 自然语言处理NLP介绍——NLP简介

    2024年02月15日
    浏览(57)
  • 自然语言处理2-NLP

    目录 自然语言处理2-NLP 如何把词转换为向量 如何让向量具有语义信息 在CBOW中 在Skip-gram中 skip-gram比CBOW效果更好 CBOW和Skip-gram的算法实现 Skip-gram的理想实现 Skip-gram的实际实现 在自然语言处理任务中, 词向量(Word Embedding)是表示自然语言里单词的一种方法 ,即把每个词都表

    2024年02月11日
    浏览(56)
  • 聊聊自然语言处理NLP

    自然语言处理(NLP)的正式定义:是一个使用计算机科学、人工智能(AI)和形式语言学概念来分析自然语言的研究领域。不太正式的定义表明:它是一组工具,用于从自然语言源(如web页面和文本文档)获取有意义和有用的信息。 NLP工具的实现一般是基于机器学习与深度学习、其它

    2024年02月14日
    浏览(53)
  • 自然语言处理(NLP)技术

            自然语言处理技术是一种人工智能技术,它的目标是使计算机能够理解、分析、处理和生成自然语言(人类使用的语言)。NLP技术包括文本分类、情感分析、机器翻译、语音识别、语音合成、信息检索、信息抽取、问答系统等。NLP技术的应用非常广泛,例如智能客

    2024年02月14日
    浏览(46)
  • NLP自然语言处理介绍

    自然语言处理(NLP,Natural Language Processing)是一门涉及计算机与人类语言之间交互的学科。它的目标是使计算机能够理解和生成人类语言,从而更好地处理和解析大量的文本数据。NLP不仅是人工智能领域中一个重要的分支,也是当今社会应用广泛的领域之一。 在NLP中,一个基

    2024年01月21日
    浏览(46)
  • 自然语言处理NLP:一文了解NLP自然语言处理技术,NLP在生活中的应用,图导加深了解,NLP语料库,NLP开源工具

    目录 1.自然语言处理NLP 1.1 NLP中英对照(双份) 1.2 相关文章  2.NLP语料库

    2024年02月09日
    浏览(48)
  • 自然语言处理(NLP) —— 心理语言学

            认知科学和心理语言学是两个密切相关的领域,它们研究 认知过程和语言使用是如何相互作用的。         在历史上,这两个领域的发展经历了几个重要的阶段: 1.1.1 19世纪晚期(内省法)         Wundt 和其他德国心理学家使用一种叫做 内省法 的研究方

    2024年02月21日
    浏览(45)
  • NLP(自然语言处理)是什么?

    NLP基本概念: 自然语言处理( Natural Language Processing, NLP)是以语言为对象,利用计算机技术来分析、理解和处理自然语言的一门学科,即把计算机作为语言研究的强大工具,在计算机的支持下对语言信息进行定量化的研究,并提供可供人与计算机之间能共同使用的语言描写。包括

    2024年02月12日
    浏览(34)
  • 自然语言处理(NLP)是什么?

    您有没有和聊天机器人互动过?或者您是否向虚拟助手,例如 Siri、Alexa 或您车上的车载娱乐系统发出过某些请求?您使用过在线翻译吗?我们大多数人都曾与这些人工智能 (AI) 互动过,我们也从未停止过思考如何便捷地表达我们的需求并获得适当的回应。如果我和Siri说:“

    2024年02月10日
    浏览(51)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包