File size: 2,058 Bytes
37244c4
 
 
 
 
 
 
 
 
 
 
 
e303824
 
 
37244c4
 
 
eb53fd2
 
37244c4
f29339b
37244c4
f29339b
37244c4
 
 
 
f29339b
37244c4
 
eb53fd2
37244c4
eb53fd2
 
 
37244c4
eb53fd2
1f37230
37244c4
 
eb53fd2
 
37244c4
 
 
e5c49d5
 
37244c4
 
 
 
 
 
 
 
f29339b
37244c4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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)
}