update model inference with pipeline
Browse files
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 |
-
|
| 42 |
-
output = model(**tokenized_input)
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 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
|