LoRA 微调中文NER模型

这是一个使用 LoRA (Low-Rank Adaptation) 技术微调的中文命名实体识别 (NER) 模型。

模型概述

  • 基础模型: uer/roberta-base-finetuned-cluener2020-chinese
  • 任务: 命名实体识别 (Token Classification)
  • LoRA 配置:
    • r: 8
    • lora_alpha: 16
    • lora_dropout: 0.1
  • 支持的实体类型:
    • TIME: 时间
    • LOCATION: 地点
    • PERSON: 人名
    • ORGANIZATION: 组织机构
    • PRODUCT: 产品
    • EVENT: 事件
    • TOPIC: 主题
    • CONCEPT: 概念
    • SEARCH_INTENT: 搜索意图

使用方法

您可以使用 Hugging Face Transformers 库加载和使用此模型进行推理:

from transformers import AutoModelForTokenClassification,AutoTokenizer,pipeline
model = AutoModelForTokenClassification.from_pretrained('lujin/search-ner-lora-model')
tokenizer = AutoTokenizer.from_pretrained('lujin/search-ner-lora-model')
ner_pipe = pipeline(
    "token-classification",
    model=model,
    tokenizer=tokenizer,
    aggregation_strategy="simple",
    device=0 if torch.cuda.is_available() else -1
)

# 示例文本
text = "对比 MacBook Pro 和 MacBook Air"
predictions = ner_pipe(text)
for entity in predictions:
    print(f"实体: {entity['word']}, 标签: {entity['entity_group']}, 置信度: {entity['score']:.4f}")

text = "明天在北京故宫博物院举行长城文化论坛"
predictions = ner_pipe(text)
for entity in predictions:
    print(f"实体: {entity['word']}, 标签: {entity['entity_group']}, 置信度: {entity['score']:.4f}")

训练详情

  • 数据集: 使用私有数据集进行训练
  • 训练框架: Hugging Face Transformers, PEFT (LoRA)
  • 训练参数:
    • 学习率: 0.0003
    • 批次大小: 16
    • 训练轮数: 10

评估结果 (在验证集上)

  • F1 Score: 1.0000
  • Precision: 1.0000
  • Recall: 1.0000

局限性

此模型在训练时使用的私有数据集上表现良好。在其他领域或特定语料上可能需要进一步微调。

Downloads last month
-
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for lujin/search-ner-lora-model

Finetuned
(1)
this model