Branis333/symptom-gpt2-chatbot
015
๐ฅ 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
Final Model Performance:
- โ Training Loss: 0.2781
- โ Validation Loss: 0.4024
- โ Validation Perplexity: 1.50
๐ Usage
Basic Usage
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
- Kaggle Symptom-Disease Dataset - Disease descriptions, symptom mappings, precautions
- MedQuAD - Expert-curated medical Q&A from multiple domains
โ ๏ธ Limitations
- Not a Medical Professional: Cannot replace professional medical advice
- Training Data Bias: Limited to information in training data
- Hallucination Risk: May generate plausible but incorrect information
- 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
