HuggingFace镜像/bert-large-NER
模型介绍文件和版本分析
下载使用量0

bert-large-NER

模型说明

bert-large-NER 是一款经过微调的 BERT 模型,可直接用于命名实体识别(Named Entity Recognition) 任务,并在该任务上实现了最先进(state-of-the-art)的性能。该模型经过训练,能够识别四种实体类型:地点(LOC)、组织(ORG)、人物(PER)和其他(MISC)。

具体而言,此模型基于 bert-large-cased 模型,在标准的英语版 CoNLL-2003 命名实体识别 数据集上进行了微调。

预期用途与局限性

使用方法

您可以将此模型与 Transformers 的 pipeline 配合使用,以进行命名实体识别。

from transformers import AutoModelForTokenClassification
from openmind import pipeline, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("Changchun_Ascend/bert-large-NER")
model = AutoModelForTokenClassification.from_pretrained("Changchun_Ascend/bert-large-NER")

nlp = pipeline("ner", model=model, tokenizer=tokenizer)
example = "My name is Wolfgang and I live in Berlin"

ner_results = nlp(example)
print(ner_results)
[{'entity': 'B-PER', 'score': 0.9971501, 'index': 4, 'word': 'Wolfgang', 'start': 11, 'end': 19}, {'entity': 'B-LOC', 'score': 0.9986046, 'index': 9, 'word': 'Berlin', 'start': 34, 'end': 40}]

局限性与偏差

本模型受限于其训练数据集,该数据集包含特定时间段内带有实体标注的新闻文章。因此,它在不同领域的所有使用场景中可能无法很好地泛化。此外,模型偶尔会将子词标记为实体,可能需要对结果进行后处理以应对这些情况。

训练数据

本模型在标准的CoNLL-2003命名实体识别数据集的英文版本上进行了微调。

训练数据集对实体的起始和延续进行了区分,这样如果存在连续的相同类型实体,模型就能输出第二个实体的起始位置。与数据集中一致,每个标记将被分类为以下类别之一:

缩写描述
O非命名实体
B-MIS紧接另一个 miscellaneous 实体之后的 miscellaneous 实体的起始
I-MISMiscellaneous 实体
B-PER紧接另一个人名之后的人名的起始
I-PER人名
B-ORG紧接另一个组织之后的组织的起始
I-ORG组织
B-LOC紧接另一个地点之后的地点的起始
I-LOC地点

CoNLL-2003英文数据集统计

该数据集源自路透社语料库,包含路透社新闻报道。你可以在CoNLL-2003论文中了解更多关于该数据集的创建方式。

各实体类型的训练样本数量

数据集LOCMISCORGPER
Train7140343863216600
Dev183792213411842
Test166870216611617

各数据集的文章/句子/标记数量

数据集文章数句子数标记数
Train94614,987203,621
Dev2163,46651,362
Test2313,68446,435

训练过程

本模型在单个NVIDIA V100 GPU上进行训练,采用了原始BERT论文中推荐的超参数,该论文在CoNLL-2003 NER任务上对模型进行了训练和评估。

评估结果

指标开发集测试集
f195.791.7
精确率95.391.2
召回率96.192.3

测试集指标略低于 Google BERT 官方结果,后者对文档上下文进行了编码并尝试使用了 CRF。关于复现原始结果的更多信息,请参见此处。

BibTeX 条目和引用信息

@article{DBLP:journals/corr/abs-1810-04805,
  author    = {Jacob Devlin and
               Ming{-}Wei Chang and
               Kenton Lee and
               Kristina Toutanova},
  title     = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language
               Understanding},
  journal   = {CoRR},
  volume    = {abs/1810.04805},
  year      = {2018},
  url       = {http://arxiv.org/abs/1810.04805},
  archivePrefix = {arXiv},
  eprint    = {1810.04805},
  timestamp = {Tue, 30 Oct 2018 20:39:56 +0100},
  biburl    = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}
@inproceedings{tjong-kim-sang-de-meulder-2003-introduction,
    title = "Introduction to the {C}o{NLL}-2003 Shared Task: Language-Independent Named Entity Recognition",
    author = "Tjong Kim Sang, Erik F.  and
      De Meulder, Fien",
    booktitle = "Proceedings of the Seventh Conference on Natural Language Learning at {HLT}-{NAACL} 2003",
    year = "2003",
    url = "https://www.aclweb.org/anthology/W03-0419",
    pages = "142--147",
}