CoolFace
Modelpublic

Branis333/symptom-gpt2-chatbot

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes15downloads
Model Card

๐Ÿฅ Medical Symptom Chatbot - GPT2 Fine-tuned

A specialized GPT-2 model fine-tuned on medical Q&A data to assist with symptom analysis, disease information, and health-related questions.

๐ŸŽฏ Model Description

This model is based on GPT-2 and has been fine-tuned on a comprehensive medical dataset combining:

  • โ€”Symptom-Disease mappings with descriptions and precautions
  • โ€”MedQuAD dataset with expert medical Q&A pairs
  • โ€”Custom medical knowledge base

โš ๏ธ IMPORTANT DISCLAIMER: This model is for informational and educational purposes only. Always consult qualified healthcare professionals for medical advice, diagnosis, or treatment.

๐Ÿ“Š Training Details

Dataset Statistics

  • โ€”Total Training Samples: 8,437
  • โ€”Validation Samples: 938
  • โ€”Total Dataset Size: 9,375 medical Q&A pairs

Training Configuration

  • โ€”Base Model: GPT-2 (124M parameters)
  • โ€”Training Epochs: 10
  • โ€”Batch Size: 4
  • โ€”Learning Rate: 3e-5
  • โ€”Optimizer: AdamW
  • โ€”Max Sequence Length: 512 tokens
  • โ€”Hardware: NVIDIA GPU (CUDA enabled)
  • โ€”Training Time: ~3.5 hours

Performance Metrics

EpochTrain LossVal LossPerplexity
10.55180.46641.59
20.45530.43661.55
30.41620.41961.52
40.38650.40881.51
50.36210.40151.49
60.34150.39751.49
70.32330.39881.49
80.30690.39841.49
90.29170.39771.49
100.27810.40241.50

Final Model Performance:

  • โ€”โœ… Training Loss: 0.2781
  • โ€”โœ… Validation Loss: 0.4024
  • โ€”โœ… Validation Perplexity: 1.50

๐Ÿš€ Usage

Basic Usage

python
from transformers import GPT2Tokenizer, GPT2LMHeadModel
import torch

# Load model and tokenizer
model_name = "Branis333/symptom-gpt2-chatbot"
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
model = GPT2LMHeadModel.from_pretrained(model_name)

# Set device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
model.eval()

# Generate response
question = "I have fever and cough. What could this be?"
prompt = f"User: {question} Bot:"

inputs = tokenizer(prompt, return_tensors="pt").to(device)
outputs = model.generate(
    **inputs,
    max_new_tokens=150,
    do_sample=True,
    temperature=0.7,
    top_p=0.9,
    pad_token_id=tokenizer.eos_token_id
)

response = tokenizer.decode(outputs[0], skip_special_tokens=True)
answer = response.split("Bot:")[-1].strip()
print(answer)

๐Ÿ’ก Example Queries

Symptom Analysis

User: I have fever and cough. What could this be?
Bot: You may be experiencing a respiratory infection...

Disease Information

User: What are the symptoms of diabetes?
Bot: Common symptoms include increased thirst, frequent urination...

๐Ÿ“ Dataset Sources

  1. 1.Kaggle Symptom-Disease Dataset - Disease descriptions, symptom mappings, precautions
  2. 2.MedQuAD - Expert-curated medical Q&A from multiple domains

โš ๏ธ Limitations

  1. 1.Not a Medical Professional: Cannot replace professional medical advice
  2. 2.Training Data Bias: Limited to information in training data
  3. 3.Hallucination Risk: May generate plausible but incorrect information
  4. 4.Language: Primarily English medical texts

๐Ÿ”’ Ethical Considerations

  • โ€”Informational Only: Should not be used for self-diagnosis
  • โ€”Professional Consultation Required: Always seek medical professionals for health concerns
  • โ€”Verification: Cross-check any medical information with reliable sources

๐Ÿ“„ License

MIT License - Free to use with attribution


Built with โค๏ธ using Hugging Face Transformers

Last Updated: October 2024