CoolFace
Modelpublic

cihatyldz/sifahane-bert-turkish-medical

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
1likes22downloads
Model Card

🏥 Şifahane — Turkish Medical Text Classification (BERT)

A fine-tuned Turkish BERT model for classifying patient complaints into 12 medical departments with high accuracy.

This model is part of the Şifahane project, a dual-model medical triage demo comparing a fine-tuned BERT classifier against a zero-shot LLM.

Model Overview

PropertyValue
Base Model`dbmdz/bert-base-turkish-cased`
LanguageTurkish (tr)
TaskMulti-class Text Classification (12 classes)
Parameters~111M
Inference Speed~15–130 ms on CPU
LicenseApache 2.0

Intended Use

Primary use case: Classifying Turkish patient complaints into the appropriate medical department for triage routing.

Input: Free-text patient complaint in Turkish. Output: Predicted department label with confidence scores.

Example

Input:  "Göğsümde şiddetli ağrı var, sol koluma yayılıyor, terleme eşlik ediyor."
Output: Kardiyoloji (98.7%)

Supported Classes (12 Departments)

#DepartmentDescription
0DermatolojiSkin conditions (eczema, fungal infections, allergies)
1EndokrinolojiHormonal/metabolic disorders (diabetes, thyroid)
2GastroenterolojiDigestive system (gastritis, liver, IBS)
3Göğüs HastalıklarıRespiratory (asthma, COPD, pneumonia)
4Göz HastalıklarıEye conditions (conjunctivitis, glaucoma)
5KBBEar, nose, throat (sinusitis, otitis, tonsillitis)
6Kadın DoğumObstetrics & gynecology
7KardiyolojiCardiovascular (hypertension, arrhythmia, coronary)
8NörolojiNeurological (migraine, epilepsy, stroke, vertigo)
9OrtopediMusculoskeletal (disc herniation, meniscus, fractures)
10PsikiyatriMental health (depression, anxiety, sleep disorders)
11ÜrolojiUrological (UTI, kidney stones, prostate)

Quick Start

With Transformers Pipeline

python
from transformers import pipeline

classifier = pipeline(
    "text-classification",
    model="cihatyldz/sifahane-bert-turkish-medical",
    top_k=3,
)

result = classifier("Midemde şiddetli yanma var, 2 haftadır devam ediyor.")
print(result)
# [[{'label': 'Gastroenteroloji', 'score': 0.98}, ...]]

Manual Inference

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import torch.nn.functional as F

model_name = "cihatyldz/sifahane-bert-turkish-medical"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval()

text = "Başımın sol tarafında zonklayıcı ağrı var, ışığa hassaslaştım."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)

with torch.no_grad():
    outputs = model(**inputs)
    probs = F.softmax(outputs.logits, dim=-1)[0]

pred_id = probs.argmax().item()
label = model.config.id2label[pred_id]
confidence = probs[pred_id].item()

print(f"Department: {label} ({confidence:.1%})")
# Department: Nöroloji (97.2%)

Training Details

Dataset

  • —Source: `cihatyldz/sifahane-turkish-medical-complaints`
  • —Size: ~6,000 synthetic Turkish patient complaints
  • —Generation Method: Template-based synthesis with randomized clinical parameters (duration, intensity, symptoms, body location)
  • —Coverage: 12 departments × 36 conditions × 3 urgency levels
  • —Split: 80% train / 10% validation / 10% test (stratified)

Training Configuration

HyperparameterValue
Base modeldbmdz/bert-base-turkish-cased
Epochs4
Batch size32
Learning rate2e-5
Weight decay0.01
Warmup ratio0.1
Max sequence length128
OptimizerAdamW
LR schedulerLinear with warmup
FP16Enabled
Early stoppingPatience = 2 (metric: F1 macro)

Training Infrastructure

  • —Hardware: NVIDIA Tesla T4 (Google Colab)
  • —Training time: ~5–10 minutes
  • —Framework: Hugging Face Transformers + Trainer API

Evaluation Results

Evaluated on the held-out test split (~600 examples):

MetricScore
Accuracy~99.3%
F1 (macro)~99.3%
F1 (weighted)~99.3%
Note: High scores reflect the synthetic nature of the training data with clear template patterns. Real-world clinical text would yield lower but still useful performance. The model demonstrates strong pattern recognition within its training distribution.

Live Demo

Try the model in action at the Şifahane Space, where it runs side-by-side with a zero-shot LLM (Qwen2.5-7B):

🚀 [Şifahane Demo](https://huggingface.co/spaces/cihatyldz/sifahane-turkish-medical)

The demo compares two approaches:

BERT Classifier (this model)LLM (Qwen2.5-7B)
Speed~15–130 ms (CPU)~1–3 s (Inference API)
ApproachFine-tuned, single-taskZero-shot, multi-task
FlexibilityFixed categoriesOpen-ended
CostFree (CPU)Free (HF Inference API)

Project Portfolio

This model is part of a Turkish NLP portfolio demonstrating three different AI architectures across three domains:

ProjectDomainArchitectureLink
🪙 AkçeBankingFine-tuned LLM (Generative)Space
🐪 KervanLogisticsRAG (Retrieval + Generative)Space
🏥 ŞifahaneHealthcareDual-Model (Classifier vs LLM)Space

Limitations & Ethical Considerations

  • —Not a medical device: This model is for research and educational purposes only. It should never be used for actual medical diagnosis or triage decisions.
  • —Synthetic training data: The model was trained on template-generated data, not real clinical records. Performance on real-world patient language may differ.
  • —Turkish only: The model is designed for Turkish text and will not perform well on other languages.
  • —Fixed taxonomy: The model only supports the 12 predefined departments. Complaints outside these categories may be misclassified.
  • —No urgency assessment: This model predicts department only. Urgency classification requires additional logic (see the Şifahane Space for a rule-based urgency module).

Citation

bibtex
@misc{yildiz2025sifahane,
  author       = {Cihat Yıldız},
  title        = {Şifahane: Turkish Medical Text Classification with Fine-tuned BERT},
  year         = {2025},
  publisher    = {Hugging Face},
  url          = {https://huggingface.co/cihatyldz/sifahane-bert-turkish-medical}
}

Contact