A Survey on Deep Learning for Named Entity Recognition 札记

1.NER 进化

  • 早期 ner :需要很多的human effort 来指定规则和特征
(1)什么是 NER

有两种主张:

serving as a name for something or someone

proper names and natural kind terms like biological species
and substances.

不论如何,现在主要把NER 划分为general NE ,domain-specific NE

按照粒度划分NER 任务

  • coarse-grained NER:仅有少数类别,并且一个NE 只有一个entity type
  • fine-grained NER:有很多类别,一个NE 可能有不同的 entity types
(2) DL 中的 NER
  • 需要最少的feature engineering,原文中 引用17-21已经提到了一些 SOTA 的 DL 模型,原文中引用 22-26 提到了一些关于NER 的 survey

论文中系统地 把DL NER 划分为三个部分:

  • distributed representations for input
  • context encoder (for capturing contextual dependencies for tag decoder)
  • tag decoder (for predicting labels of words in the given sequence)
(3) NER 数据集和工具

见原文

(4) NER 评估

boundarytype 都是对才为分类正确

  1. 三个类别:
  • True Positive (TP): entities that are recognized by
    NER and match ground truth.

  • False Positive (FP): entities that are recognized byNER but do not match ground truth.

  • False Negative (FN): entities annotated in the ground
    truth that are not recognized by NER.
    有两个分类标准: precision recall
    F_beta用于综合两者

                  precision = TP / TP+FP
                  recall = TP / TP+FN
    

2.macro-averaged F-score: 单独计算每个类取平均
micro-averaged F-score:一块算,大烩菜!!

2.NER传统方法

(1)依赖 手工构造规则

依赖于手工构造的规则,可能是基于<

### BERT NER Transformer-Based Named Entity Recognition Overview Transformer架构下的命名实体识别(NER)方法,尤其是基于BERT的实现,在处理不平衡数据集方面表现出显著优势[^2]。这些模型通过预训练阶段获取丰富的语义信息,并在微调过程中针对具体任务优化参数。 #### 实现概述 BERT-NER的主要流程如下: - **预训练**:采用大规模无标注文本进行双向编码器表示(Bidirectional Encoder Representations from Transformers),即BERT模型的学习过程。 - **特征提取**:对于给定句子中的每一个token,BERT能够提供深层次的语言理解能力,捕捉到复杂的语法和语义模式。 - **分类层构建**:在BERT之上添加一层或多层全连接神经网络用于预测各个位置上的标签类别,如`O`, `B-Person`, `I-Person`等。 ```python import torch from transformers import BertTokenizer, BertForTokenClassification tokenizer = BertTokenizer.from_pretrained('bert-base-cased') model = BertForTokenClassification.from_pretrained('dbmdz/bert-large-cased-finetuned-conll03-english') def predict_entities(text): inputs = tokenizer.encode_plus( text, add_special_tokens=True, return_tensors="pt" ) outputs = model(**inputs)[0] predictions = torch.argmax(outputs, dim=2) tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0]) entities = [] current_entity = None for idx, pred in enumerate(predictions[0]): label = model.config.id2label[pred.item()] if not label.startswith("I") and current_entity is not None: entities.append(current_entity) current_entity = None if label != "O": token_text = tokens[idx].replace("##", "") if label.startswith("B"): current_entity = {"entity": label.split("-")[1], "text": token_text} elif label.startswith("I") and current_entity is not None: current_entity["text"] += f" {token_text}" if current_entity is not None: entities.append(current_entity) return entities ``` 此代码片段展示了如何加载预先训练好的BERT模型并应用于新的文本输入以执行命名实体识别的任务。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值