🚀 distilbert-NER
distilbert-NER 是一個基於 DistilBERT 微調的命名實體識別(NER)模型。DistilBERT 是 BERT 模型的蒸餾版本,參數更少,模型更小、運行更快且效率更高。該模型在英文 CoNLL - 2003 數據集上微調,能準確識別地點、組織、人物和其他雜項四類實體,在大小、速度和準確性之間取得了良好平衡。
🚀 快速開始
如果你覺得我的開源模型對你有幫助,請考慮支持我為大家構建小型實用的 AI 模型(也能幫我支付醫學院的學費或在經濟上幫助我的父母)。感謝!

✨ 主要特性
- 輕量級高效:基於 DistilBERT 微調,相比 BERT 模型參數更少,運行速度更快。
- 精準識別:能準確識別地點(LOC)、組織(ORG)、人物(PER)和雜項(MISC)四類實體。
- 數據豐富:在英文 CoNLL - 2003 數據集上微調,該數據集實體類型豐富多樣。
可用的 NER 模型
📦 安裝指南
暫未提及安裝相關內容,可參考 Transformers 庫的安裝方法。
💻 使用示例
基礎用法
from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
tokenizer = AutoTokenizer.from_pretrained("dslim/distilbert-NER")
model = AutoModelForTokenClassification.from_pretrained("dslim/distilbert-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)
📚 詳細文檔
預期用途與限制
如何使用
該模型可以像 BERT 模型一樣,使用 Transformers 的 pipeline 進行命名實體識別任務。
限制和偏差
distilbert-NER 的性能與在 CoNLL - 2003 數據集上的訓練有關。因此,對於與該訓練集差異較大的文本數據,其效果可能有限。用戶應注意訓練數據中可能存在的固有偏差,以及在複雜句子中實體誤分類的可能性。
訓練數據
該模型在英文標準 CoNLL - 2003 命名實體識別 數據集上進行了微調。
訓練數據集區分了實體的開始和延續,這樣如果有連續的同類型實體,模型可以輸出第二個實體的起始位置。在數據集中,每個標記將被分類為以下類別之一:
縮寫 |
描述 |
O |
命名實體之外 |
B - MISC |
另一個雜項實體之後的雜項實體的開始 |
I - MISC |
雜項實體 |
B - PER |
另一個人名之後的人名的開始 |
I - PER |
人名 |
B - ORG |
另一個組織之後的組織的開始 |
I - ORG |
組織 |
B - LOC |
另一個地點之後的地點的開始 |
I - LOC |
地點 |
CoNLL - 2003 英文數據集統計
該數據集源自路透社語料庫,由路透社新聞故事組成。你可以在 CoNLL - 2003 論文中瞭解更多關於該數據集的創建方式。
每個實體類型的訓練示例數量
數據集 |
LOC |
MISC |
ORG |
PER |
訓練集 |
7140 |
3438 |
6321 |
6600 |
驗證集 |
1837 |
922 |
1341 |
1842 |
測試集 |
1668 |
702 |
1661 |
1617 |
每個數據集的文章/句子/標記數量
數據集 |
文章數量 |
句子數量 |
標記數量 |
訓練集 |
946 |
14,987 |
203,621 |
驗證集 |
216 |
3,466 |
51,362 |
測試集 |
231 |
3,684 |
46,435 |
訓練過程
該模型在單個 NVIDIA V100 GPU 上進行訓練,使用了 原始 BERT 論文 中推薦的超參數,該論文在 CoNLL - 2003 NER 任務上對模型進行了訓練和評估。
評估結果
指標 |
得分 |
損失 |
0.0710 |
精確率 |
0.9202 |
召回率 |
0.9232 |
F1 值 |
0.9217 |
準確率 |
0.9810 |
訓練和驗證損失隨訓練輪數減少,表明模型學習效果良好。精確率、召回率和 F1 得分具有競爭力,展示了模型在 NER 任務中的穩健性。
BibTeX 引用和引用信息
對於 DistilBERT:
@article{sanh2019distilbert,
title={DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter},
author={Sanh, Victor and Debut, Lysandre and Chaumond, Julien and Wolf, Thomas},
journal={arXiv preprint arXiv:1910.01108},
year={2019}
}
對於基礎 BERT 模型:
@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}
}
📄 許可證
本項目採用 Apache - 2.0 許可證。