Views
No views yet
1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4# Load the fine-tuned model and tokenizer
5model = AutoModelForSequenceClassification.from_pretrained("your_model_path")
6tokenizer = AutoTokenizer.from_pretrained("dmis-lab/biobert-v1.1")
7
8def predict(text):
9 inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=256)
10 with torch.no_grad():
11 logits = model(**inputs).logits
12 return "urgent" if torch.argmax(logits) == 1 else "non-urgent"
13
14# Example usage
15print(predict("Patient has chest pain and difficulty breathing."))| Epoch | Training Loss | Validation Loss | Accuracy | Precision | Recall | F1 Score |
|---|---|---|---|---|---|---|
| 1 | No log | 0.606408 | 0.681326 | 0.436587 | 0.656415 | 0.524395 |
| 2 | 0.639200 | 0.564773 | 0.706726 | 0.467656 | 0.692443 | 0.558271 |
| 3 | 0.639200 | 0.562810 | 0.718721 | 0.481095 | 0.648506 | 0.552395 |
| 4 | 0.551200 | 0.559481 | 0.701317 | 0.462286 | 0.710896 | 0.560249 |
| 5 | 0.522800 | 0.560782 | 0.710019 | 0.471334 | 0.686292 | 0.558855 |
| 6 | 0.522800 | 0.559855 | 0.705786 | 0.466978 | 0.702109 | 0.560899 |