kamalkraj commited on
Commit
1c99584
1 Parent(s): 6afccd7

update model inference with pipeline

Browse files
Files changed (1) hide show
  1. README.md +4 -5
README.md CHANGED
@@ -26,7 +26,7 @@ The model is based on the [ClinicalBERT - Bio + Discharge Summary BERT Model](ht
26
 
27
  You can load the model via the transformers library:
28
  ```
29
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
30
  tokenizer = AutoTokenizer.from_pretrained("bvanaken/clinical-assertion-negation-bert")
31
  model = AutoModelForSequenceClassification.from_pretrained("bvanaken/clinical-assertion-negation-bert")
32
 
@@ -38,11 +38,10 @@ Example input and inference:
38
  ```
39
  input = "The patient recovered during the night and now denies any [entity] shortness of breath [entity]."
40
 
41
- tokenized_input = tokenizer(input, return_tensors="pt")
42
- output = model(**tokenized_input)
43
 
44
- import numpy as np
45
- predicted_label = np.argmax(output.logits.detach().numpy()) ## 1 == ABSENT
46
  ```
47
 
48
  ### Cite
 
26
 
27
  You can load the model via the transformers library:
28
  ```
29
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline
30
  tokenizer = AutoTokenizer.from_pretrained("bvanaken/clinical-assertion-negation-bert")
31
  model = AutoModelForSequenceClassification.from_pretrained("bvanaken/clinical-assertion-negation-bert")
32
 
 
38
  ```
39
  input = "The patient recovered during the night and now denies any [entity] shortness of breath [entity]."
40
 
41
+ classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer)
 
42
 
43
+ classification = classifier(input)
44
+ # [{'label': 'ABSENT', 'score': 0.9842607378959656}]
45
  ```
46
 
47
  ### Cite