🚀 用于命名实体识别的微调模型
本项目是一个经过微调的模型,专门用于命名实体识别(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许可证。