qwerty45-uiop commited on
Commit
26a5b10
·
verified ·
1 Parent(s): d6adb09

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +43 -0
src/streamlit_app.py CHANGED
@@ -72,6 +72,49 @@ def extract_numeric_ram(ram) -> Optional[int]:
72
  return None
73
 
74
  # Streamlined LLM database with popular models and download sizes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  LLM_DATABASE = {
76
  "ultra_low": { # ≤2GB
77
  "general": [
 
72
  return None
73
 
74
  # Streamlined LLM database with popular models and download sizes
75
+ QUANTIZATION_INFO = {
76
+ "fp16": {"multiplier": 1.0, "label": "FP16 (Full)", "description": "Best quality, largest size"},
77
+ "8bit": {"multiplier": 0.5, "label": "8-bit", "description": "Good quality, 50% smaller"},
78
+ "4bit": {"multiplier": 0.25, "label": "4-bit", "description": "Decent quality, 75% smaller"}
79
+ }
80
+
81
+ def calculate_quantized_size(base_size_str: str, quantization: str) -> str:
82
+ """Calculate quantized model size based on base size and quantization type"""
83
+ try:
84
+ import re
85
+ match = re.match(r'(\d+(?:\.\d+)?)\s*(GB|MB)', base_size_str.upper())
86
+ if not match:
87
+ return base_size_str
88
+
89
+ value, unit = float(match.group(1)), match.group(2)
90
+ multiplier = QUANTIZATION_INFO[quantization]["multiplier"]
91
+
92
+ new_value = value * multiplier
93
+
94
+ if unit == "MB" and new_value >= 1024:
95
+ new_value = new_value / 1024
96
+ unit = "GB"
97
+ elif unit == "GB" and new_value < 1:
98
+ new_value = new_value * 1024
99
+ unit = "MB"
100
+
101
+ return f"{new_value:.0f}{unit}" if new_value >= 10 else f"{new_value:.1f}{unit}"
102
+ except:
103
+ return base_size_str
104
+
105
+ def get_quantization_recommendations(ram_gb: int) -> List[str]:
106
+ """Recommend best quantization options based on available RAM"""
107
+ if ram_gb <= 2:
108
+ return ["4bit"]
109
+ elif ram_gb <= 4:
110
+ return ["4bit", "8bit"]
111
+ elif ram_gb <= 8:
112
+ return ["4bit", "8bit"]
113
+ elif ram_gb <= 16:
114
+ return ["8bit", "fp16"]
115
+ else:
116
+ return ["fp16", "8bit", "4bit"]
117
+
118
  LLM_DATABASE = {
119
  "ultra_low": { # ≤2GB
120
  "general": [