🚀 用於命名實體識別的微調模型
本項目是一個經過微調的模型,專門用於命名實體識別(NER)任務。它基於Google的electra small discriminator架構,能夠準確識別英文文本中的地點、人物和組織實體,為自然語言處理相關應用提供了有力支持。
🚀 快速開始
使用以下代碼即可開始使用該模型:
from transformers import AutoModelForTokenClassification, AutoTokenizer
from transformers import pipeline
model = AutoModelForTokenClassification.from_pretrained("rv2307/electra-small-ner")
tokenizer = AutoTokenizer.from_pretrained("rv2307/electra-small-ner")
nlp = pipeline("ner",
model=model,
tokenizer=tokenizer,device="cpu",
aggregation_strategy = "max")
✨ 主要特性
- 實體識別能力:能夠準確識別文本中的地點、人物和組織三種實體。
- 基於預訓練模型:基於Google的electra small discriminator進行微調,具有較好的性能。
📦 安裝指南
本模型依賴transformers
庫,可使用以下命令進行安裝:
pip install transformers
💻 使用示例
基礎用法
from transformers import AutoModelForTokenClassification, AutoTokenizer
from transformers import pipeline
model = AutoModelForTokenClassification.from_pretrained("rv2307/electra-small-ner")
tokenizer = AutoTokenizer.from_pretrained("rv2307/electra-small-ner")
nlp = pipeline("ner",
model=model,
tokenizer=tokenizer,device="cpu",
aggregation_strategy = "max")
text = "Vipin works at Google."
result = nlp(text)
print(result)
高級用法
texts = ["Vipin works at Google.", "Ashwin lives in New York."]
results = [nlp(text) for text in texts]
print(results)
📚 詳細文檔
模型詳情
模型描述
本模型是基於electra-small進行微調的,用於命名實體識別(NER)預測任務。目前,該模型可以預測以下三種實體:
- 地點
- 人物
- 組織
- 開發者:விபின் (Vipin)
- 模型類型:Google的electra small discriminator
- 語言:英語
- 許可證:Apache 2.0
- 微調基礎模型:Google的electra small discriminator
模型來源
- 倉庫:https://huggingface.co/google/electra-small-discriminator
使用說明
本模型使用的分詞器來自distilbert家族。因此,對於同一個單詞(不同的子詞),模型可能會預測出錯誤的實體。在使用transformer的管道時,將aggregation_strategy
設置為"max"。例如,對於"ashwin":
適用範圍外的使用
對於一些長句子,模型的表現可能不佳。
訓練詳情
訓練過程
本模型在學習率為3e-4的情況下訓練了6個epoch。
[39168/39168 41:18, Epoch 6/6]
Step Training Loss Validation Loss Precision Recall F1 Accuracy
10000 0.086300 0.088625 0.863476 0.876271 0.869827 0.972581
20000 0.059800 0.079611 0.894612 0.884521 0.889538 0.976563
30000 0.050400 0.074552 0.895812 0.902591 0.899188 0.978380
評估
該模型的驗證損失為0.07。
🔧 技術細節
本模型基於Google的electra small discriminator進行微調,在命名實體識別任務上進行了優化。訓練過程中,使用了特定的學習率和訓練輪數,以達到較好的性能。在使用時,由於分詞器的特性,可能會出現對同一單詞不同子詞預測錯誤實體的情況,需要使用aggregation_strategy
進行處理。
📄 許可證
本模型使用Apache 2.0許可證。