medical_model / config.py
Deva1211's picture
Fixing issues
eb53fd2
# Configuration file for MedLLaMA2 model hosting
# Model configurations
MODEL_CONFIGS = {
"meditron": {
"name": "epfl-llm/meditron-7b",
"description": "Meditron 7B medical language model"
},
"dialogpt_medium": {
"name": "microsoft/DialoGPT-medium",
"description": "DialoGPT Medium (fallback)"
},
"flan_t5_small": {
"name": "google/flan-t5-small",
"description": "FLAN-T5 Small (instruction-following fallback)"
}
}
# Default model to use - reliable for medical chat
DEFAULT_MODEL = "dialogpt_medium"
# Model loading settings (optimized for CPU)
MODEL_SETTINGS = {
"use_quantization": False, # Disabled for CPU - causes slowdown
"quantization_bits": 4,
"torch_dtype": "float16",
"trust_remote_code": True,
"low_cpu_mem_usage": True,
"device_map": "cpu" # Force CPU to avoid device mapping issues
}
# Generation settings (optimized for T5 output)
GENERATION_DEFAULTS = {
"max_new_tokens": 256,
"temperature": 0.7,
"top_p": 0.9,
"do_sample": True,
"repetition_penalty": 1.5,
"no_repeat_ngram_size": 3
}
# Simplified medical prompt for T5
MEDICAL_SYSTEM_PROMPT = "You are a friendly medical assistant. Answer with short, clear health info. Use emojis like 😊. For serious issues, suggest seeing a doctor."
# UI settings
UI_CONFIG = {
"title": "πŸ₯ MedLLaMA2 Medical Chatbot",
"description": "A medical AI assistant powered by MedLLaMA2. Please note: This is for educational purposes only and should not replace professional medical advice.",
"examples": [
"What are the symptoms of diabetes?",
"How can I maintain a healthy heart?",
"What should I know about blood pressure?",
"Tell me about the importance of regular exercise.",
"What are the side effects of common pain medications?",
"How can I improve my sleep quality?"
],
"max_tokens_range": (50, 512), # Reduced max for CPU performance
"temperature_range": (0.1, 1.0),
"top_p_range": (0.1, 1.0)
}