Views
No views yet

B-DRUG: beginning of a drug entityI-DRUG: within a drug entityB-EFFECT: beginning of an AE entityI-EFFECT: within an AE entityO: outside either of the above entitiespipeline like below:1from transformers import (AutoModelForTokenClassification,
2 AutoTokenizer,
3 pipeline,
4 )
5
6model_checkpoint = "jsylee/scibert_scivocab_uncased-finetuned-ner"
7model = AutoModelForTokenClassification.from_pretrained(model_checkpoint, num_labels=5,
8 id2label={0: 'O', 1: 'B-DRUG', 2: 'I-DRUG', 3: 'B-EFFECT', 4: 'I-EFFECT'}
9 )
10tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
11
12model_pipeline = pipeline(task="ner", model=model, tokenizer=tokenizer)
13
14print( model_pipeline ("Abortion, miscarriage or uterine hemorrhage associated with misoprostol (Cytotec), a labor-inducing drug."))