Upload BioBERT medical classifier
Browse files- README.md +68 -0
- config.json +45 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
- training_args.bin +3 -0
README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- medical
|
| 6 |
+
- classification
|
| 7 |
+
- biobert
|
| 8 |
+
- pubmedqa
|
| 9 |
+
- healthcare-rag
|
| 10 |
+
datasets:
|
| 11 |
+
- qiaojin/PubMedQA
|
| 12 |
+
metrics:
|
| 13 |
+
- f1
|
| 14 |
+
pipeline_tag: text-classification
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# BioBERT Medical Query Classifier
|
| 18 |
+
|
| 19 |
+
Fine-tuned `dmis-lab/biobert-v1.1` for classifying medical questions into 6 categories.
|
| 20 |
+
|
| 21 |
+
## Categories
|
| 22 |
+
| ID | Category |
|
| 23 |
+
|----|----------|
|
| 24 |
+
| 0 | Diagnosis |
|
| 25 |
+
| 1 | General |
|
| 26 |
+
| 2 | Medication |
|
| 27 |
+
| 3 | Prevention |
|
| 28 |
+
| 4 | Symptoms |
|
| 29 |
+
| 5 | Treatment |
|
| 30 |
+
|
| 31 |
+
## Results
|
| 32 |
+
| Metric | Score |
|
| 33 |
+
|--------|-------|
|
| 34 |
+
| Macro F1 | 0.9066 |
|
| 35 |
+
| Weighted F1 | 0.9094 |
|
| 36 |
+
| Accuracy | 0.9088 |
|
| 37 |
+
|
| 38 |
+
## Training Config
|
| 39 |
+
| Item | Value |
|
| 40 |
+
|------|-------|
|
| 41 |
+
| Base model | dmis-lab/biobert-v1.1 |
|
| 42 |
+
| Dataset | qiaojin/PubMedQA (211,186 rows) |
|
| 43 |
+
| Split | 80/10/10 |
|
| 44 |
+
| Epochs | 3 |
|
| 45 |
+
| Learning rate | 2e-5 |
|
| 46 |
+
| Batch size | 16 |
|
| 47 |
+
| Class weights | Balanced (custom WeightedTrainer) |
|
| 48 |
+
|
| 49 |
+
## Usage
|
| 50 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 51 |
+
import torch
|
| 52 |
+
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained("AbdoMatrix/biobert-medical-classifier")
|
| 54 |
+
model = AutoModelForSequenceClassification.from_pretrained("AbdoMatrix/biobert-medical-classifier")
|
| 55 |
+
|
| 56 |
+
text = "What are the symptoms of diabetes?"
|
| 57 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
|
| 58 |
+
|
| 59 |
+
with torch.no_grad():
|
| 60 |
+
outputs = model(**inputs)
|
| 61 |
+
|
| 62 |
+
predicted = model.config.id2label[torch.argmax(outputs.logits, dim=1).item()]
|
| 63 |
+
print(predicted) # → Symptoms
|
| 64 |
+
|
| 65 |
+
## Project
|
| 66 |
+
Healthcare RAG-Powered Medical Q&A Assistant
|
| 67 |
+
eyouth x DEPI | Microsoft Machine Learning Track | 2026
|
| 68 |
+
GitHub: https://github.com/AbdooMatrix/Healthcare-RAG-Powered-Medical-QA-Assistant
|
config.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": null,
|
| 11 |
+
"gradient_checkpointing": false,
|
| 12 |
+
"hidden_act": "gelu",
|
| 13 |
+
"hidden_dropout_prob": 0.1,
|
| 14 |
+
"hidden_size": 768,
|
| 15 |
+
"id2label": {
|
| 16 |
+
"0": "Diagnosis",
|
| 17 |
+
"1": "General",
|
| 18 |
+
"2": "Medication",
|
| 19 |
+
"3": "Prevention",
|
| 20 |
+
"4": "Symptoms",
|
| 21 |
+
"5": "Treatment"
|
| 22 |
+
},
|
| 23 |
+
"initializer_range": 0.02,
|
| 24 |
+
"intermediate_size": 3072,
|
| 25 |
+
"is_decoder": false,
|
| 26 |
+
"label2id": {
|
| 27 |
+
"Diagnosis": 0,
|
| 28 |
+
"General": 1,
|
| 29 |
+
"Medication": 2,
|
| 30 |
+
"Prevention": 3,
|
| 31 |
+
"Symptoms": 4,
|
| 32 |
+
"Treatment": 5
|
| 33 |
+
},
|
| 34 |
+
"layer_norm_eps": 1e-12,
|
| 35 |
+
"max_position_embeddings": 512,
|
| 36 |
+
"model_type": "bert",
|
| 37 |
+
"num_attention_heads": 12,
|
| 38 |
+
"num_hidden_layers": 12,
|
| 39 |
+
"pad_token_id": 0,
|
| 40 |
+
"tie_word_embeddings": true,
|
| 41 |
+
"transformers_version": "5.8.1",
|
| 42 |
+
"type_vocab_size": 2,
|
| 43 |
+
"use_cache": false,
|
| 44 |
+
"vocab_size": 28996
|
| 45 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c236119e06130ed02a30d63e7f5638dc4898b203fbb3807e0339ee802393e2ba
|
| 3 |
+
size 433283072
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": false,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_max_length": 512,
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"strip_accents": null,
|
| 12 |
+
"tokenize_chinese_chars": true,
|
| 13 |
+
"tokenizer_class": "BertTokenizer",
|
| 14 |
+
"unk_token": "[UNK]"
|
| 15 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f301ecc0fffa1089253190c30f4fc6c90d1450e2d7d706cc9f9be7d80cc5215d
|
| 3 |
+
size 4856
|