nlp

How to speed up spaCy lemmatization?

柔情痞子 提交于 2020-02-24 05:08:22
问题 I'm using spaCy (version 2.0.11) for lemmatization in the first step of my NLP pipeline but unfortunately it's taking a verrry long time. It is clearly the slowest part of my processing pipeline and I want to know if there are improvements I could be making. I am using a pipeline as: nlp.pipe(docs_generator, batch_size=200, n_threads=6, disable=['ner']) on a 8 core machine, and I have verified that the machine is using all the cores. On a corpus of about 3 million short texts totaling almost

How to speed up spaCy lemmatization?

我的未来我决定 提交于 2020-02-24 05:07:31
问题 I'm using spaCy (version 2.0.11) for lemmatization in the first step of my NLP pipeline but unfortunately it's taking a verrry long time. It is clearly the slowest part of my processing pipeline and I want to know if there are improvements I could be making. I am using a pipeline as: nlp.pipe(docs_generator, batch_size=200, n_threads=6, disable=['ner']) on a 8 core machine, and I have verified that the machine is using all the cores. On a corpus of about 3 million short texts totaling almost

Calculating topic distribution of an unseen document on GenSim

雨燕双飞 提交于 2020-02-22 08:48:48
问题 I am trying to use LDA module of GenSim to do the following task "Train a LDA model with one big document and keep track of 10 latent topics. Given a new, unseen document, predict probability distribution of 10 latent topics". As per tutorial here: http://radimrehurek.com/gensim/tut2.html, this seems possible for a document in a corpus, but I am wondering if it it would be possible for an unseen document. Thank you! 回答1: From the documentation you posted it looks like you can train your model

BERT

会有一股神秘感。 提交于 2020-02-22 05:35:39
转:https://www.cnblogs.com/rucwxb/p/10277217.html 【NLP】彻底搞懂BERT 自google在2018年10月底公布BERT在11项nlp任务中的卓越表现后,BERT(Bidirectional Encoder Representation from Transformers)就成为NLP领域大火、整个ML界略有耳闻的模型,网上相关介绍也很多,但很多技术内容太少,或是写的不全面半懂不懂,重复内容占绝大多数(这里弱弱吐槽百度的搜索结果多样化。。) 一句话概括,BERT的出现,彻底改变了预训练产生词向量和下游具体NLP任务的关系,提出龙骨级的训练词向量概念。 目录:   词向量模型:word2vec, ELMo, BERT比较   BERT细则:Masked LM, Transformer, sentence-level   迁移策略:下游NLP任务调用接口   运行结果:破11项NLP任务最优纪录 一、词向量模型 这里主要横向比较一下word2vec,ELMo,BERT这三个模型,着眼在模型亮点与差别处。 传统意义上来讲,词向量模型是一个工具,可以把真实世界抽象存在的文字转换成可以进行数学公式操作的向量,而对这些向量的操作,才是NLP真正要做的任务。因而某种意义上,NLP任务分成两部分,预训练产生词向量,对词向量操作(下游具体NLP任务

2020年中文NLP顶级预训练模块

半腔热情 提交于 2020-02-21 17:33:00
对于BERT后时代,不得不说强有力的预训练模型是刷榜、出色完成任务的基础,现在列举几个对此很有帮助的资源,同大家一起进步!!! 一:互联网新闻情感分析复赛top8(8/2745)解决方案及总结 ; 地址: https://zhuanlan.zhihu.com/p/101554661 大佬的这篇知乎博客总结的非常好,打开了另一块天地,同学们可以深挖这里面的内容 二:CCF BDCI 2019 互联网新闻情感分析 复赛top1解决方案 ;地址: https://github.com/cxy229/BDCI2019-SENTIMENT-CLASSIFICATION 站在巨人的肩膀上,你将成长更快 三:哈工大的RoBERTa-wwm-ext-large ; 地址: https://github.com/ymcui/Chinese-BERT-wwm 深入学习里面的东西 四:中文预训练RoBERTa模型 ;地址: https://github.com/brightmart/roberta_zh 也不错 少年们,加油吧!!! 来源: https://www.cnblogs.com/demo-deng/p/12342027.html

【NLP】_02_NLP经典任务

空扰寡人 提交于 2020-02-20 12:57:09
文章目录 【一】 NER (命名实体识别) 【二】 Relation Extraction (关系提取) 【三】 Text Matching (文本匹配) 【一】 NER (命名实体识别) ORG (组织), LOC (地点), PER (人物) 常用方法 (原文链接:https://blog.csdn.net/weixin_37665090/article/details/89454829) LSTM 的优点是能够通过双向的设置学习到观测序列(输入的单词)之间的依赖,在训练过程中,LSTM 能够根据目标(比如识别实体)自动提取观测序列的特征,但是缺点是无法学习到状态序列(输出的标注)之间的关系,要知道,在命名实体识别任务中,标注之间是有一定的关系的,比如 B类标注(表示某实体的开头)后面不会再接一个 B类标注,所以 LSTM 在解决 NER 这类序列标注任务时,虽然可以省去很繁杂的特征工程,但是也存在无法学习到标注上下文的缺点。 当用 Bi-LSTM 来做命名实体识别时,Bi-LSTM 的输出为实体标签的分数,且选择最高分数对应的标签。然而某些时候,Bi-LSTM 却不能得到真正正确的实体标签,这时候就需要加入 CRF 层。 CRF 由Lafferty 等人于2001 年提出,结合了 最大熵模型 和 隐马尔科夫模型 的特点,能对隐含状态建模,学习状态序列的特点

Spacy to extract specific noun phrase

邮差的信 提交于 2020-02-20 07:44:32
问题 Can I use spacy in python to find NP with specific neighbors? I want Noun phrases from my text that has verb before and after it. 回答1: You can merge the noun phrases ( so that they do not get tokenized seperately). Analyse the dependency parse tree, and see the POS of neighbouring tokens. >>> import spacy >>> nlp = spacy.load('en') >>> sent = u'run python program run, to make this work' >>> parsed = nlp(sent) >>> list(parsed.noun_chunks) [python program] >>> for noun_phrase in list(parsed

Spacy, Strange similarity between two sentences

大兔子大兔子 提交于 2020-02-20 07:22:27
问题 I have downloaded en_core_web_lg model and trying to find similarity between two sentences: nlp = spacy.load('en_core_web_lg') search_doc = nlp("This was very strange argument between american and british person") main_doc = nlp("He was from Japan, but a true English gentleman in my eyes, and another one of the reasons as to why I liked going to school.") print(main_doc.similarity(search_doc)) Which returns very strange value: 0.9066019751888448 These two sentences should not be 90% similar

《自然语言处理入门》12.依存句法分析--提取用户评论

橙三吉。 提交于 2020-02-18 21:26:39
笔记转载于GitHub项目 : https://github.com/NLP-LOVE/Introduction-NLP 12. 依存句法分析 语法分析 (syntactic parsing )是自然语言处理中一个重要的任务,其目标是分析句子的语法结构并将其表示为容易理解的结构(通常是树形结构)。同时,语法分析也是所有工具性NLP任务中较为高级、较为复杂的一种任务。 通过掌握语法分析的原理、实现和应用,我们将在NLP工程师之路上跨越一道分水岭。 本章将会介绍 短语结构树 和 依存句法树 两种语法形式,并且着重介绍依存句法分析的原理和实现。 12.1 短语结构树 语言其实具备自顶而下的层级关系,固定数量的语法结构能够生成无数句子。比如,仅仅利用下列两个语法规律,我们就能够生成所有名词短语。 名词短语可以由名词和名词短语组成。 名词短语还可以由名词和名词组成。 例如,“上海+浦东+机场+航站楼”,所以,汉语中大部分句子都可以通过这样的语法来生成。 在语言学中,这样的语法被称为 上下文无关文法 ,它由如下组件构成: 终结符结合 Σ,比如汉语的一个词表。 非终结符集合 V,比如“名词短语”“动词短语”等短语结构组成的集合。V 中至少包含一个特殊的非终结符,即句子符或初始符,计作 S。 推到规则 R,即推到非终结符的一系列规则: V -> V U Σ。 基于上下文无关文法理论,我们可以从 S

【NLP】_03_句法分析

南楼画角 提交于 2020-02-18 05:46:01
文章目录 【一】 Syntax Tree (句法树) 【二】 CKY 算法 (动态规划) 【一】 Syntax Tree (句法树) 【N:名词】【V:动词】【P:介词】【NP:名词短语】【PP:介词短语】 Old Machine Translation (老旧的机器翻译) From CFG (Context Free Grammars) to PCFG (Probability) Evaluate Syntax Tree (评估句法树) 【二】 CKY 算法 (动态规划) Transforming to CNF (Chomsky Noemal Form) 对于 CKY 算法来说,必须为 Binarization ,即右边的项为两个 算法思路 (有点繁琐) 来源: CSDN 作者: 欲戴皇冠 链接: https://blog.csdn.net/qq_34330456/article/details/104358925