英文

这是一个基于SciBERT进行训练的模型,用于识别药物名称和不良药物反应。

该模型将输入的标记分类为以下五个类别:

  • B-DRUG:药物实体的开头
  • I-DRUG:药物实体内部
  • B-EFFECT:不良反应实体的开头
  • I-EFFECT:不良反应实体内部
  • O:上述实体之外

要开始使用此模型进行推理,只需设置一个NER pipeline,如以下所示:

from transformers import (AutoModelForTokenClassification, 
                          AutoTokenizer, 
                          pipeline,
                          )

model_checkpoint = "jsylee/scibert_scivocab_uncased-finetuned-ner"
model = AutoModelForTokenClassification.from_pretrained(model_checkpoint, num_labels=5,
                                                        id2label={0: 'O', 1: 'B-DRUG', 2: 'I-DRUG', 3: 'B-EFFECT', 4: 'I-EFFECT'} 
                                                        )                                                        
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)

model_pipeline = pipeline(task="ner", model=model, tokenizer=tokenizer)

print( model_pipeline ("Abortion, miscarriage or uterine hemorrhage associated with misoprostol (Cytotec), a labor-inducing drug."))

SciBERT: https://huggingface.co/allenai/scibert_scivocab_uncased

数据集: https://huggingface.co/datasets/ade_corpus_v2