Language Model

##20170801
##notes for lec2-2.pdf about language model

Evaluating a Language Model

Intuition about Perplexity

Evaluating N‐grams with Perplexity

Sparsity is Always a Problem
    Dealing with Sparsity
        General approach: modify observed counts to improve estimates
            – Discounting:  allocate  probability mass for unobserved
            events by discounting counts for observed events

– Interpolation: approximate counts of N‐gram using  
            combination of estimates from related denser histories

– Back‐off: approximate counts of unobserved N‐gram based
            on the proportion of back‐off events (e.g., N‐1 gram)

Add‐One Smoothing
                ? We have V words in the vocabulary, N is the number of words
                in the training set
                ? Smooth observed counts by adding one to all the counts and
                renormalize
                – Unigram case:
                – Bigram  case:
                ? More general case:  add‐α, when α is added instead of one.

Linear Interpolation

Tuning Hyperparameters
                ? Both add‐α and linear interpolation have hyperparameters.
                ? The selection of their values is crucial for the smoothing
                The selection of their values is crucial for the smoothing
                performance
                ? Their values are tuned to maximize the likelihood of held‐out
                data
                – For linear interpolation, we will use EM to find optimal
                parameters (in few lectures)

Kneser‐Ney Smoothing
                ? Observed n‐grams occur more in the training data than in the
                new data
                ? Absolute discounting: count*(x)=count(x)‐d
                P ad ( w i | w i ? 1 ) =
                count ( w i , w i ? 1 ) ? d
                + α P ? ( w i )
                count ( w i ? 1 )
                ? Distribute the remaining mass based on the skewness in the
                distribution of the lower order N‐gram (i.e., the number of
                words it can follow)
                P ? ( w i ) ∝ | w i ? 1 : count ( w i , w i ? 1 ) > 0 |
                ? Kneser‐Ney is repeatedly proven as very successful estimator

时间: 2024-07-29 23:00:12

Language Model的相关文章

用CNTK搞深度学习 (二) 训练基于RNN的自然语言模型 ( language model )

前一篇文章  用 CNTK 搞深度学习 (一) 入门    介绍了用CNTK构建简单前向神经网络的例子.现在假设读者已经懂得了使用CNTK的基本方法.现在我们做一个稍微复杂一点,也是自然语言挖掘中很火的一个模型: 用递归神经网络构建一个语言模型. 递归神经网络 (RNN),用图形化的表示则是隐层连接到自己的神经网络(当然只是RNN中的一种): 不同于普通的神经网络,RNN假设样例之间并不是独立的.例如要预测“上”这个字的下一个字是什么,那么在“上”之前出现过的字就很重要,如果之前出现过“工作”,

A Neural Probabilistic Language Model

A Neural Probabilistic Language Model,这篇论文是Begio等人在2003年发表的,可以说是词表示的鼻祖.在这里给出简要的译文 A Neural Probabilistic Language Model 一个神经概率语言模型 摘  要 统计语言模型的一个目标是学习一种语言的单词序列的联合概率函数.因为维数灾难,这是其本质难点:将被模型测试的单词序列很可能是与在训练中见过的所有单词的序列都不相同.传统的但非常成功的基于n-gram的方法通过将出现在训练集很短的重

NLP:language model(n-gram/Word2Vec/Glove)

首先,大概讲一下自然语言处理的背景.互联网上充斥着大规模.多样化.非结构化的自然语言描述的文本,如何较好的理解这些文本,服务于实际业务系统,如搜索引擎.在线广告.推荐系统.问答系统等, 给我们提出了挑战.例如在效果广告系统中,需要将 Query(User or Page) 和广告 Ad 投影到相同的特征语义空间做精准匹配,如果 Query 是用户,需要基于用户历史数据离线做用户行为分析,如果 Query 是网页,则需要离线或实时做网页语义分析.文本语义分析(又称文本理解.文本挖掘)技术研究基于词

Feedforward Neural Network Language Model(NNLM)c++核心代码实现

本文来自CSDN博客,转载请注明出处:http://blog.csdn.net/a635661820/article/details/44730507 参考文献: A Neural Probabilistic Language Model 参照我另一篇NNLM学习介绍的博客, 这一篇是对NNLM的简要实现, 自己简化了一些,输入层到输出层没有连接(加上直连边的真在原论文中没有明显的提高),并且没有并行算法.下面贴上自己的一些核心代码.总体来说,我用了c++面向对象来设计该算法,大概分为6个类,如

将迁移学习用于文本分类 《 Universal Language Model Fine-tuning for Text Classification》

将迁移学习用于文本分类 < Universal Language Model Fine-tuning for Text Classification> 2018-07-27 20:07:43 ttv56 阅读数 4552更多 分类专栏: 自然语言处理 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/u014475479/article/details/81253506 本文发表于自然语言

Knowledge-Augmented Language Model and its Application to Unsupervised Named-Entity Recognition(Facebook AI 2019) 文献综述

1.摘要: 传统的语言模型无法为文本中的实体名称进行有效建模,主要是因为这些命名实体不会在文本中频繁出现.近期研究发现相同的实体类型(如人名.地名)其上下文之间具有一定共性,同时训练语言模型时可以借助外部知识图谱.本文主要研究继续探索利用知识图谱来强化语言模型的训练,训练目标是优化语言模型的困惑度,模型全称Knowledge-Augmented Language Model(KALM).在这个过程并不依赖其他如命名实体识别工具.为了提升语言模型的效果,本模型在训练过程中学习到实体类型信息,然后模

language model —— basic model 语言模型之基础模型

一.发展 起源:统计语言模型起源于 Ponte 和 Croft 在 1998年的 SIGIR上发表的论文 应用:语言模型的应用很多: corsslingual retrieval distributed IR expert finding passage retrieval web search genomics retrieval 基因组学检索 topic tracking subtopic retrieval 二.basic model 1.Ponte and Croft 核心思想:quer

cs224d problem set2 (三) 用RNNLM模型实现Language Model,来预测下一个单词的出现

今天将的还是cs224d 的problem set2 的第三部分习题, 原来国外大学的系统难度真的如此之大,相比之下还是默默地再天朝继续搬砖吧 (注意前方高能,一大批天书即将来袭) ''' Created on 2017年9月26日 @author: weizhen ''' import getpass import sys import time import numpy as np from copy import deepcopy from utils import calculate_p

pytorch ---神经网络开篇之作 NNLM &lt;A Neural Probabilistic Language Model&gt;

论文地址:http://www.iro.umontreal.ca/~vincentp/Publications/lm_jmlr.pdf 论文给出了NNLM的框架图: 针对论文,实现代码如下: 1 # -*- coding: utf-8 -*- 2 # @time : 2019/10/26 12:20 3 4 import numpy as np 5 import torch 6 import torch.nn as nn 7 import torch.optim as optim 8 from