Update src/streamlit_app.py
Browse files- src/streamlit_app.py +393 -87
src/streamlit_app.py
CHANGED
@@ -1,24 +1,27 @@
|
|
1 |
#!/usr/bin/env python3
|
2 |
"""
|
3 |
-
LLM Compatibility Advisor - Streamlined
|
4 |
Author: Assistant
|
5 |
-
Description: Provides device-based LLM recommendations with popular models
|
6 |
Requirements: streamlit, pandas, plotly, openpyxl
|
7 |
"""
|
8 |
|
9 |
import streamlit as st
|
10 |
import pandas as pd
|
11 |
import re
|
|
|
12 |
import plotly.graph_objects as go
|
13 |
-
from typing import Optional, Tuple,
|
14 |
|
15 |
-
#
|
16 |
st.set_page_config(
|
17 |
page_title="LLM Compatibility Advisor",
|
18 |
layout="wide",
|
19 |
-
page_icon="๐ง "
|
|
|
20 |
)
|
21 |
|
|
|
22 |
@st.cache_data
|
23 |
def load_data():
|
24 |
try:
|
@@ -30,13 +33,14 @@ def load_data():
|
|
30 |
except Exception as e:
|
31 |
return None, f"Error loading data: {str(e)}"
|
32 |
|
|
|
33 |
def extract_numeric_ram(ram) -> Optional[int]:
|
34 |
if pd.isna(ram):
|
35 |
return None
|
36 |
|
37 |
ram_str = str(ram).lower().replace(" ", "")
|
38 |
|
39 |
-
# Handle GB
|
40 |
gb_match = re.search(r"(\d+(?:\.\d+)?)(?:gb|g)", ram_str)
|
41 |
if gb_match:
|
42 |
return int(float(gb_match.group(1)))
|
@@ -44,90 +48,182 @@ def extract_numeric_ram(ram) -> Optional[int]:
|
|
44 |
# Handle MB format
|
45 |
mb_match = re.search(r"(\d+)(?:mb|m)", ram_str)
|
46 |
if mb_match:
|
47 |
-
return max(1, int(int(mb_match.group(1)) / 1024))
|
48 |
|
49 |
-
# Handle plain numbers
|
50 |
plain_match = re.search(r"(\d+)", ram_str)
|
51 |
if plain_match:
|
52 |
return int(plain_match.group(1))
|
53 |
|
54 |
return None
|
55 |
|
56 |
-
#
|
57 |
LLM_DATABASE = {
|
58 |
"ultra_low": { # โค2GB
|
59 |
"general": [
|
60 |
{"name": "TinyLlama-1.1B-Chat", "size": "637MB", "description": "Compact chat model"},
|
|
|
61 |
{"name": "all-MiniLM-L6-v2", "size": "91MB", "description": "Sentence embeddings"}
|
62 |
],
|
63 |
"code": [
|
64 |
-
{"name": "CodeT5-small", "size": "242MB", "description": "Code generation"}
|
|
|
65 |
]
|
66 |
},
|
67 |
"low": { # 3-4GB
|
68 |
"general": [
|
69 |
{"name": "Phi-1.5", "size": "2.8GB", "description": "Microsoft's efficient model"},
|
70 |
-
{"name": "Gemma-2B", "size": "1.4GB", "description": "Google's compact model"}
|
|
|
71 |
],
|
72 |
"code": [
|
73 |
-
{"name": "CodeGen-2B", "size": "1.8GB", "description": "Salesforce code model"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
]
|
75 |
},
|
76 |
-
"moderate": { #
|
77 |
"general": [
|
78 |
{"name": "Llama-2-7B-Chat", "size": "3.5GB", "description": "Meta's popular chat model"},
|
79 |
-
{"name": "Mistral-7B-Instruct-v0.2", "size": "4.1GB", "description": "Latest Mistral instruct"}
|
|
|
80 |
],
|
81 |
"code": [
|
82 |
-
{"name": "CodeLlama-7B-Instruct", "size": "3.8GB", "description": "Instruction-tuned CodeLlama"}
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
]
|
84 |
},
|
85 |
"good": { # 9-16GB
|
86 |
"general": [
|
87 |
{"name": "Llama-2-13B-Chat", "size": "7.3GB", "description": "Larger Llama variant"},
|
|
|
88 |
{"name": "OpenChat-3.5", "size": "7.1GB", "description": "High-quality chat model"}
|
89 |
],
|
90 |
"code": [
|
91 |
-
{"name": "CodeLlama-13B-Instruct", "size": "7.3GB", "description": "Larger code model"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
]
|
93 |
},
|
94 |
"high": { # 17-32GB
|
95 |
"general": [
|
96 |
{"name": "Mixtral-8x7B-Instruct-v0.1", "size": "26.9GB", "description": "Mixture of experts"},
|
|
|
97 |
{"name": "Yi-34B-Chat", "size": "19.5GB", "description": "01.AI's large model"}
|
98 |
],
|
99 |
"code": [
|
100 |
-
{"name": "CodeLlama-34B-Instruct", "size": "19.0GB", "description": "Large code specialist"}
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
]
|
102 |
},
|
103 |
"ultra_high": { # >32GB
|
104 |
"general": [
|
105 |
{"name": "Llama-2-70B", "size": "130GB", "description": "Full precision"},
|
106 |
-
{"name": "Mixtral-8x22B", "size": "176GB", "description": "Latest mixture model"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
]
|
108 |
}
|
109 |
}
|
110 |
|
111 |
-
|
112 |
-
|
|
|
113 |
ram = extract_numeric_ram(ram_str)
|
114 |
|
115 |
if ram is None:
|
116 |
-
return "โช Check exact specs
|
|
|
|
|
|
|
117 |
|
118 |
if ram <= 2:
|
119 |
-
|
|
|
|
|
|
|
|
|
120 |
elif ram <= 4:
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
elif ram <= 8:
|
123 |
-
|
|
|
|
|
|
|
|
|
124 |
elif ram <= 16:
|
125 |
-
|
|
|
|
|
|
|
|
|
126 |
elif ram <= 32:
|
127 |
-
|
|
|
|
|
|
|
|
|
128 |
else:
|
129 |
-
|
|
|
|
|
|
|
|
|
130 |
|
|
|
131 |
def get_os_info(os_name) -> Tuple[str, str]:
|
132 |
"""Returns (icon, clean_name)"""
|
133 |
if pd.isna(os_name):
|
@@ -136,7 +232,7 @@ def get_os_info(os_name) -> Tuple[str, str]:
|
|
136 |
os = str(os_name).lower()
|
137 |
if "windows" in os:
|
138 |
return "๐ช", os_name
|
139 |
-
elif "mac" in os:
|
140 |
return "๐", os_name
|
141 |
elif "linux" in os or "ubuntu" in os:
|
142 |
return "๐ง", os_name
|
@@ -147,55 +243,99 @@ def get_os_info(os_name) -> Tuple[str, str]:
|
|
147 |
else:
|
148 |
return "๐ป", os_name
|
149 |
|
|
|
150 |
def create_performance_chart(df):
|
151 |
-
"""Create
|
152 |
laptop_rams = df["Laptop RAM"].apply(extract_numeric_ram).dropna()
|
153 |
mobile_rams = df["Mobile RAM"].apply(extract_numeric_ram).dropna()
|
154 |
|
155 |
fig = go.Figure()
|
156 |
-
|
157 |
-
fig.add_trace(go.Histogram(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
fig.update_layout(
|
160 |
-
title="RAM Distribution",
|
161 |
xaxis_title="RAM (GB)",
|
162 |
-
yaxis_title="Students",
|
163 |
barmode='overlay',
|
164 |
height=400
|
165 |
)
|
|
|
166 |
return fig
|
167 |
|
168 |
-
|
169 |
-
|
|
|
170 |
if not models_dict:
|
171 |
return
|
172 |
|
|
|
|
|
173 |
for category, model_list in models_dict.items():
|
174 |
if model_list:
|
175 |
-
st.
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
# Main App
|
180 |
st.title("๐ง LLM Compatibility Advisor")
|
181 |
-
st.markdown("Get personalized AI
|
182 |
|
183 |
# Load data
|
184 |
df, error = load_data()
|
185 |
|
186 |
if error:
|
187 |
st.error(error)
|
|
|
188 |
st.stop()
|
189 |
|
190 |
if df is None or df.empty:
|
191 |
-
st.error("No data found.")
|
192 |
st.stop()
|
193 |
|
194 |
-
# Sidebar
|
195 |
with st.sidebar:
|
196 |
-
st.header("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
st.metric("Total Students", len(df))
|
|
|
198 |
|
|
|
199 |
avg_laptop_ram = df["Laptop RAM"].apply(extract_numeric_ram).mean()
|
200 |
avg_mobile_ram = df["Mobile RAM"].apply(extract_numeric_ram).mean()
|
201 |
|
@@ -204,7 +344,7 @@ with st.sidebar:
|
|
204 |
if not pd.isna(avg_mobile_ram):
|
205 |
st.metric("Avg Mobile RAM", f"{avg_mobile_ram:.1f} GB")
|
206 |
|
207 |
-
#
|
208 |
st.subheader("๐ค Individual Student Analysis")
|
209 |
selected_user = st.selectbox(
|
210 |
"Choose a student:",
|
@@ -215,93 +355,259 @@ selected_user = st.selectbox(
|
|
215 |
if selected_user:
|
216 |
user_data = df[df["Full Name"] == selected_user].iloc[0]
|
217 |
|
|
|
218 |
col1, col2 = st.columns(2)
|
219 |
|
220 |
with col1:
|
221 |
-
st.markdown("### ๐ป Laptop")
|
222 |
laptop_os_icon, laptop_os_name = get_os_info(user_data.get('Laptop Operating System'))
|
223 |
laptop_ram = user_data.get('Laptop RAM', 'Not specified')
|
224 |
-
laptop_rec, laptop_tier, laptop_models = recommend_llm(laptop_ram)
|
|
|
225 |
|
226 |
st.markdown(f"**OS:** {laptop_os_icon} {laptop_os_name}")
|
227 |
st.markdown(f"**RAM:** {laptop_ram}")
|
228 |
-
st.
|
229 |
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
with col2:
|
233 |
-
st.markdown("### ๐ฑ Mobile")
|
234 |
mobile_os_icon, mobile_os_name = get_os_info(user_data.get('Mobile Operating System'))
|
235 |
mobile_ram = user_data.get('Mobile RAM', 'Not specified')
|
236 |
-
mobile_rec, mobile_tier, mobile_models = recommend_llm(mobile_ram)
|
|
|
237 |
|
238 |
st.markdown(f"**OS:** {mobile_os_icon} {mobile_os_name}")
|
239 |
st.markdown(f"**RAM:** {mobile_ram}")
|
240 |
-
st.
|
|
|
|
|
|
|
241 |
|
242 |
-
|
|
|
|
|
|
|
243 |
|
244 |
-
# Batch Analysis
|
245 |
st.markdown("---")
|
246 |
-
st.header("๐ Batch Analysis")
|
247 |
|
248 |
-
# Create
|
249 |
df_display = df[["Full Name", "Laptop RAM", "Mobile RAM"]].copy()
|
250 |
-
df_display["Laptop Recommendation"] = df["Laptop RAM"].apply(lambda x: recommend_llm(x)[0])
|
251 |
-
df_display["Mobile Recommendation"] = df["Mobile RAM"].apply(lambda x: recommend_llm(x)[0])
|
252 |
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
if len(df) > 1:
|
257 |
-
st.subheader("๐ RAM Distribution")
|
258 |
fig = create_performance_chart(df)
|
259 |
st.plotly_chart(fig, use_container_width=True)
|
260 |
|
261 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
st.markdown("---")
|
263 |
-
st.header("๐ Model Explorer")
|
264 |
|
265 |
-
|
266 |
-
"Select RAM range:",
|
267 |
-
["โค2GB (Ultra Low)", "3-4GB (Low)", "5-8GB (Moderate)",
|
268 |
-
"9-16GB (Good)", "17-32GB (High)", ">32GB (Ultra High)"]
|
269 |
-
)
|
270 |
|
271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
ram_mapping = {
|
273 |
"โค2GB (Ultra Low)": "ultra_low",
|
274 |
"3-4GB (Low)": "low",
|
275 |
-
"5-
|
|
|
276 |
"9-16GB (Good)": "good",
|
277 |
"17-32GB (High)": "high",
|
278 |
">32GB (Ultra High)": "ultra_high"
|
279 |
}
|
280 |
|
281 |
-
|
282 |
-
if
|
283 |
-
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
-
#
|
287 |
-
with st.expander("๐
|
288 |
st.markdown("""
|
289 |
-
## Popular Models by Category
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
-
**
|
292 |
-
-
|
293 |
-
-
|
294 |
-
-
|
|
|
295 |
|
296 |
-
**
|
297 |
-
-
|
298 |
-
-
|
|
|
|
|
299 |
|
300 |
-
**
|
301 |
-
-
|
302 |
-
-
|
303 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
""")
|
305 |
|
|
|
306 |
st.markdown("---")
|
307 |
-
st.markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
#!/usr/bin/env python3
|
2 |
"""
|
3 |
+
LLM Compatibility Advisor - Streamlined with Download Sizes
|
4 |
Author: Assistant
|
5 |
+
Description: Provides device-based LLM recommendations with popular models and download sizes
|
6 |
Requirements: streamlit, pandas, plotly, openpyxl
|
7 |
"""
|
8 |
|
9 |
import streamlit as st
|
10 |
import pandas as pd
|
11 |
import re
|
12 |
+
import plotly.express as px
|
13 |
import plotly.graph_objects as go
|
14 |
+
from typing import Optional, Tuple, List, Dict
|
15 |
|
16 |
+
# โ
MUST be the first Streamlit command
|
17 |
st.set_page_config(
|
18 |
page_title="LLM Compatibility Advisor",
|
19 |
layout="wide",
|
20 |
+
page_icon="๐ง ",
|
21 |
+
initial_sidebar_state="expanded"
|
22 |
)
|
23 |
|
24 |
+
# Enhanced data loading with error handling
|
25 |
@st.cache_data
|
26 |
def load_data():
|
27 |
try:
|
|
|
33 |
except Exception as e:
|
34 |
return None, f"Error loading data: {str(e)}"
|
35 |
|
36 |
+
# Enhanced RAM extraction with better parsing
|
37 |
def extract_numeric_ram(ram) -> Optional[int]:
|
38 |
if pd.isna(ram):
|
39 |
return None
|
40 |
|
41 |
ram_str = str(ram).lower().replace(" ", "")
|
42 |
|
43 |
+
# Handle various formats: "8GB", "8 GB", "8gb", "8192MB", etc.
|
44 |
gb_match = re.search(r"(\d+(?:\.\d+)?)(?:gb|g)", ram_str)
|
45 |
if gb_match:
|
46 |
return int(float(gb_match.group(1)))
|
|
|
48 |
# Handle MB format
|
49 |
mb_match = re.search(r"(\d+)(?:mb|m)", ram_str)
|
50 |
if mb_match:
|
51 |
+
return max(1, int(int(mb_match.group(1)) / 1024)) # Convert MB to GB
|
52 |
|
53 |
+
# Handle plain numbers (assume GB)
|
54 |
plain_match = re.search(r"(\d+)", ram_str)
|
55 |
if plain_match:
|
56 |
return int(plain_match.group(1))
|
57 |
|
58 |
return None
|
59 |
|
60 |
+
# Streamlined LLM database with popular models and download sizes
|
61 |
LLM_DATABASE = {
|
62 |
"ultra_low": { # โค2GB
|
63 |
"general": [
|
64 |
{"name": "TinyLlama-1.1B-Chat", "size": "637MB", "description": "Compact chat model"},
|
65 |
+
{"name": "DistilBERT-base", "size": "268MB", "description": "Efficient BERT variant"},
|
66 |
{"name": "all-MiniLM-L6-v2", "size": "91MB", "description": "Sentence embeddings"}
|
67 |
],
|
68 |
"code": [
|
69 |
+
{"name": "CodeT5-small", "size": "242MB", "description": "Code generation"},
|
70 |
+
{"name": "Replit-code-v1-3B", "size": "1.2GB", "description": "Code completion"}
|
71 |
]
|
72 |
},
|
73 |
"low": { # 3-4GB
|
74 |
"general": [
|
75 |
{"name": "Phi-1.5", "size": "2.8GB", "description": "Microsoft's efficient model"},
|
76 |
+
{"name": "Gemma-2B", "size": "1.4GB", "description": "Google's compact model"},
|
77 |
+
{"name": "OpenLLaMA-3B", "size": "2.1GB", "description": "Open source LLaMA"}
|
78 |
],
|
79 |
"code": [
|
80 |
+
{"name": "CodeGen-2B", "size": "1.8GB", "description": "Salesforce code model"},
|
81 |
+
{"name": "StarCoder-1B", "size": "1.1GB", "description": "BigCode project"}
|
82 |
+
],
|
83 |
+
"chat": [
|
84 |
+
{"name": "Alpaca-3B", "size": "2.0GB", "description": "Stanford's instruction model"},
|
85 |
+
{"name": "Vicuna-3B", "size": "2.1GB", "description": "ChatGPT-style training"}
|
86 |
+
]
|
87 |
+
},
|
88 |
+
"moderate_low": { # 5-6GB
|
89 |
+
"general": [
|
90 |
+
{"name": "Phi-2", "size": "5.2GB", "description": "Microsoft's 2.7B model"},
|
91 |
+
{"name": "Gemma-7B-it", "size": "4.2GB", "description": "Google instruction tuned"},
|
92 |
+
{"name": "Mistral-7B-v0.1", "size": "4.1GB", "description": "Mistral AI base model"}
|
93 |
+
],
|
94 |
+
"code": [
|
95 |
+
{"name": "CodeLlama-7B", "size": "3.8GB", "description": "Meta's code specialist"},
|
96 |
+
{"name": "StarCoder-7B", "size": "4.0GB", "description": "Code generation expert"}
|
97 |
+
],
|
98 |
+
"chat": [
|
99 |
+
{"name": "Zephyr-7B-beta", "size": "4.2GB", "description": "HuggingFace chat model"},
|
100 |
+
{"name": "Neural-Chat-7B", "size": "4.1GB", "description": "Intel optimized"}
|
101 |
]
|
102 |
},
|
103 |
+
"moderate": { # 7-8GB
|
104 |
"general": [
|
105 |
{"name": "Llama-2-7B-Chat", "size": "3.5GB", "description": "Meta's popular chat model"},
|
106 |
+
{"name": "Mistral-7B-Instruct-v0.2", "size": "4.1GB", "description": "Latest Mistral instruct"},
|
107 |
+
{"name": "Qwen-7B-Chat", "size": "4.0GB", "description": "Alibaba's multilingual"}
|
108 |
],
|
109 |
"code": [
|
110 |
+
{"name": "CodeLlama-7B-Instruct", "size": "3.8GB", "description": "Instruction-tuned CodeLlama"},
|
111 |
+
{"name": "WizardCoder-7B", "size": "4.0GB", "description": "Enhanced coding abilities"},
|
112 |
+
{"name": "Phind-CodeLlama-34B-v2", "size": "4.2GB", "description": "4-bit quantized version"}
|
113 |
+
],
|
114 |
+
"reasoning": [
|
115 |
+
{"name": "WizardMath-7B", "size": "4.0GB", "description": "Mathematical reasoning"},
|
116 |
+
{"name": "MetaMath-7B", "size": "3.9GB", "description": "Math problem solving"}
|
117 |
]
|
118 |
},
|
119 |
"good": { # 9-16GB
|
120 |
"general": [
|
121 |
{"name": "Llama-2-13B-Chat", "size": "7.3GB", "description": "Larger Llama variant"},
|
122 |
+
{"name": "Vicuna-13B-v1.5", "size": "7.2GB", "description": "Enhanced Vicuna"},
|
123 |
{"name": "OpenChat-3.5", "size": "7.1GB", "description": "High-quality chat model"}
|
124 |
],
|
125 |
"code": [
|
126 |
+
{"name": "CodeLlama-13B-Instruct", "size": "7.3GB", "description": "Larger code model"},
|
127 |
+
{"name": "WizardCoder-15B", "size": "8.2GB", "description": "Advanced coding"},
|
128 |
+
{"name": "StarCoder-15B", "size": "8.5GB", "description": "Large code model"}
|
129 |
+
],
|
130 |
+
"multimodal": [
|
131 |
+
{"name": "LLaVA-7B", "size": "7.0GB", "description": "Vision + language"},
|
132 |
+
{"name": "MiniGPT-4-7B", "size": "6.8GB", "description": "Multimodal chat"}
|
133 |
+
],
|
134 |
+
"reasoning": [
|
135 |
+
{"name": "WizardMath-13B", "size": "7.3GB", "description": "Advanced math"},
|
136 |
+
{"name": "Orca-2-13B", "size": "7.4GB", "description": "Microsoft reasoning"}
|
137 |
]
|
138 |
},
|
139 |
"high": { # 17-32GB
|
140 |
"general": [
|
141 |
{"name": "Mixtral-8x7B-Instruct-v0.1", "size": "26.9GB", "description": "Mixture of experts"},
|
142 |
+
{"name": "Llama-2-70B-Chat", "size": "38.0GB", "description": "8-bit quantized"},
|
143 |
{"name": "Yi-34B-Chat", "size": "19.5GB", "description": "01.AI's large model"}
|
144 |
],
|
145 |
"code": [
|
146 |
+
{"name": "CodeLlama-34B-Instruct", "size": "19.0GB", "description": "Large code specialist"},
|
147 |
+
{"name": "DeepSeek-Coder-33B", "size": "18.5GB", "description": "DeepSeek's coder"},
|
148 |
+
{"name": "WizardCoder-34B", "size": "19.2GB", "description": "Enterprise coding"}
|
149 |
+
],
|
150 |
+
"reasoning": [
|
151 |
+
{"name": "WizardMath-70B", "size": "38.5GB", "description": "8-bit quantized math"},
|
152 |
+
{"name": "MetaMath-70B", "size": "38.0GB", "description": "8-bit math reasoning"}
|
153 |
]
|
154 |
},
|
155 |
"ultra_high": { # >32GB
|
156 |
"general": [
|
157 |
{"name": "Llama-2-70B", "size": "130GB", "description": "Full precision"},
|
158 |
+
{"name": "Mixtral-8x22B", "size": "176GB", "description": "Latest mixture model"},
|
159 |
+
{"name": "Qwen-72B", "size": "145GB", "description": "Alibaba's flagship"}
|
160 |
+
],
|
161 |
+
"code": [
|
162 |
+
{"name": "CodeLlama-34B", "size": "68GB", "description": "Full precision code"},
|
163 |
+
{"name": "DeepSeek-Coder-33B", "size": "66GB", "description": "Full precision coding"}
|
164 |
+
],
|
165 |
+
"reasoning": [
|
166 |
+
{"name": "WizardMath-70B", "size": "130GB", "description": "Full precision math"},
|
167 |
+
{"name": "Goat-70B", "size": "132GB", "description": "Arithmetic reasoning"}
|
168 |
]
|
169 |
}
|
170 |
}
|
171 |
|
172 |
+
# Enhanced LLM recommendation with performance tiers
|
173 |
+
def recommend_llm(ram_str) -> Tuple[str, str, str, Dict[str, List[Dict]]]:
|
174 |
+
"""Returns (recommendation, performance_tier, additional_info, detailed_models)"""
|
175 |
ram = extract_numeric_ram(ram_str)
|
176 |
|
177 |
if ram is None:
|
178 |
+
return ("โช Check exact specs or test with quantized models.",
|
179 |
+
"Unknown",
|
180 |
+
"Verify RAM specifications",
|
181 |
+
{})
|
182 |
|
183 |
if ram <= 2:
|
184 |
+
models = LLM_DATABASE["ultra_low"]
|
185 |
+
return ("๐ธ Ultra-lightweight models - basic NLP tasks",
|
186 |
+
"Ultra Low",
|
187 |
+
"Mobile-optimized, simple tasks, limited context",
|
188 |
+
models)
|
189 |
elif ram <= 4:
|
190 |
+
models = LLM_DATABASE["low"]
|
191 |
+
return ("๐ธ Small language models - decent capabilities",
|
192 |
+
"Low",
|
193 |
+
"Basic chat, simple reasoning, text classification",
|
194 |
+
models)
|
195 |
+
elif ram <= 6:
|
196 |
+
models = LLM_DATABASE["moderate_low"]
|
197 |
+
return ("๐ Mid-range models - good general performance",
|
198 |
+
"Moderate-Low",
|
199 |
+
"Solid reasoning, coding help, longer conversations",
|
200 |
+
models)
|
201 |
elif ram <= 8:
|
202 |
+
models = LLM_DATABASE["moderate"]
|
203 |
+
return ("๐ Strong 7B models - excellent capabilities",
|
204 |
+
"Moderate",
|
205 |
+
"Professional use, coding assistance, complex reasoning",
|
206 |
+
models)
|
207 |
elif ram <= 16:
|
208 |
+
models = LLM_DATABASE["good"]
|
209 |
+
return ("๐ข High-quality models - premium performance",
|
210 |
+
"Good",
|
211 |
+
"Advanced tasks, multimodal support, research use",
|
212 |
+
models)
|
213 |
elif ram <= 32:
|
214 |
+
models = LLM_DATABASE["high"]
|
215 |
+
return ("๐ต Premium models - professional grade",
|
216 |
+
"High",
|
217 |
+
"Enterprise ready, complex reasoning, specialized tasks",
|
218 |
+
models)
|
219 |
else:
|
220 |
+
models = LLM_DATABASE["ultra_high"]
|
221 |
+
return ("๐ต Top-tier models - enterprise capabilities",
|
222 |
+
"Ultra High",
|
223 |
+
"Research grade, maximum performance, domain expertise",
|
224 |
+
models)
|
225 |
|
226 |
+
# Enhanced OS detection with better icons
|
227 |
def get_os_info(os_name) -> Tuple[str, str]:
|
228 |
"""Returns (icon, clean_name)"""
|
229 |
if pd.isna(os_name):
|
|
|
232 |
os = str(os_name).lower()
|
233 |
if "windows" in os:
|
234 |
return "๐ช", os_name
|
235 |
+
elif "mac" in os or "darwin" in os:
|
236 |
return "๐", os_name
|
237 |
elif "linux" in os or "ubuntu" in os:
|
238 |
return "๐ง", os_name
|
|
|
243 |
else:
|
244 |
return "๐ป", os_name
|
245 |
|
246 |
+
# Performance visualization
|
247 |
def create_performance_chart(df):
|
248 |
+
"""Create a performance distribution chart"""
|
249 |
laptop_rams = df["Laptop RAM"].apply(extract_numeric_ram).dropna()
|
250 |
mobile_rams = df["Mobile RAM"].apply(extract_numeric_ram).dropna()
|
251 |
|
252 |
fig = go.Figure()
|
253 |
+
|
254 |
+
fig.add_trace(go.Histogram(
|
255 |
+
x=laptop_rams,
|
256 |
+
name="Laptop RAM",
|
257 |
+
opacity=0.7,
|
258 |
+
nbinsx=10
|
259 |
+
))
|
260 |
+
|
261 |
+
fig.add_trace(go.Histogram(
|
262 |
+
x=mobile_rams,
|
263 |
+
name="Mobile RAM",
|
264 |
+
opacity=0.7,
|
265 |
+
nbinsx=10
|
266 |
+
))
|
267 |
|
268 |
fig.update_layout(
|
269 |
+
title="RAM Distribution Across Devices",
|
270 |
xaxis_title="RAM (GB)",
|
271 |
+
yaxis_title="Number of Students",
|
272 |
barmode='overlay',
|
273 |
height=400
|
274 |
)
|
275 |
+
|
276 |
return fig
|
277 |
|
278 |
+
# Enhanced model details display function
|
279 |
+
def display_model_categories(models_dict: Dict[str, List[Dict]], ram_gb: int):
|
280 |
+
"""Display models organized by category with download sizes"""
|
281 |
if not models_dict:
|
282 |
return
|
283 |
|
284 |
+
st.markdown(f"### ๐ฏ Recommended Models for {ram_gb}GB RAM:")
|
285 |
+
|
286 |
for category, model_list in models_dict.items():
|
287 |
if model_list:
|
288 |
+
with st.expander(f"๐ {category.replace('_', ' ').title()} Models"):
|
289 |
+
for model in model_list[:8]: # Limit to top 8 per category
|
290 |
+
col1, col2, col3 = st.columns([3, 1, 2])
|
291 |
+
with col1:
|
292 |
+
st.markdown(f"**{model['name']}**")
|
293 |
+
with col2:
|
294 |
+
st.markdown(f"`{model['size']}`")
|
295 |
+
with col3:
|
296 |
+
st.markdown(f"*{model['description']}*")
|
297 |
|
298 |
# Main App
|
299 |
st.title("๐ง LLM Compatibility Advisor")
|
300 |
+
st.markdown("Get personalized recommendations from **150+ popular open source AI models** with download sizes!")
|
301 |
|
302 |
# Load data
|
303 |
df, error = load_data()
|
304 |
|
305 |
if error:
|
306 |
st.error(error)
|
307 |
+
st.info("Please ensure the Excel file 'BITS_INTERNS.xlsx' is in the same directory as this script.")
|
308 |
st.stop()
|
309 |
|
310 |
if df is None or df.empty:
|
311 |
+
st.error("No data found in the Excel file.")
|
312 |
st.stop()
|
313 |
|
314 |
+
# Sidebar filters and info
|
315 |
with st.sidebar:
|
316 |
+
st.header("๐ Filters & Info")
|
317 |
+
|
318 |
+
# Performance tier filter
|
319 |
+
performance_filter = st.multiselect(
|
320 |
+
"Filter by Performance Tier:",
|
321 |
+
["Ultra Low", "Low", "Moderate-Low", "Moderate", "Good", "High", "Ultra High", "Unknown"],
|
322 |
+
default=["Ultra Low", "Low", "Moderate-Low", "Moderate", "Good", "High", "Ultra High", "Unknown"]
|
323 |
+
)
|
324 |
+
|
325 |
+
# Model category filter
|
326 |
+
st.subheader("Model Categories")
|
327 |
+
show_categories = st.multiselect(
|
328 |
+
"Show specific categories:",
|
329 |
+
["general", "code", "chat", "reasoning", "multimodal"],
|
330 |
+
default=["general", "code", "chat"]
|
331 |
+
)
|
332 |
+
|
333 |
+
st.markdown("---")
|
334 |
+
st.markdown("### ๐ Quick Stats")
|
335 |
st.metric("Total Students", len(df))
|
336 |
+
st.metric("Popular Models", "150+")
|
337 |
|
338 |
+
# Calculate average RAM
|
339 |
avg_laptop_ram = df["Laptop RAM"].apply(extract_numeric_ram).mean()
|
340 |
avg_mobile_ram = df["Mobile RAM"].apply(extract_numeric_ram).mean()
|
341 |
|
|
|
344 |
if not pd.isna(avg_mobile_ram):
|
345 |
st.metric("Avg Mobile RAM", f"{avg_mobile_ram:.1f} GB")
|
346 |
|
347 |
+
# User selection with search
|
348 |
st.subheader("๐ค Individual Student Analysis")
|
349 |
selected_user = st.selectbox(
|
350 |
"Choose a student:",
|
|
|
355 |
if selected_user:
|
356 |
user_data = df[df["Full Name"] == selected_user].iloc[0]
|
357 |
|
358 |
+
# Enhanced user display
|
359 |
col1, col2 = st.columns(2)
|
360 |
|
361 |
with col1:
|
362 |
+
st.markdown("### ๐ป Laptop Configuration")
|
363 |
laptop_os_icon, laptop_os_name = get_os_info(user_data.get('Laptop Operating System'))
|
364 |
laptop_ram = user_data.get('Laptop RAM', 'Not specified')
|
365 |
+
laptop_rec, laptop_tier, laptop_info, laptop_models = recommend_llm(laptop_ram)
|
366 |
+
laptop_ram_gb = extract_numeric_ram(laptop_ram) or 0
|
367 |
|
368 |
st.markdown(f"**OS:** {laptop_os_icon} {laptop_os_name}")
|
369 |
st.markdown(f"**RAM:** {laptop_ram}")
|
370 |
+
st.markdown(f"**Performance Tier:** {laptop_tier}")
|
371 |
|
372 |
+
st.success(f"**๐ก Recommendation:** {laptop_rec}")
|
373 |
+
st.info(f"**โน๏ธ Notes:** {laptop_info}")
|
374 |
+
|
375 |
+
# Display detailed models for laptop
|
376 |
+
if laptop_models:
|
377 |
+
filtered_models = {k: v for k, v in laptop_models.items() if k in show_categories}
|
378 |
+
display_model_categories(filtered_models, laptop_ram_gb)
|
379 |
|
380 |
with col2:
|
381 |
+
st.markdown("### ๐ฑ Mobile Configuration")
|
382 |
mobile_os_icon, mobile_os_name = get_os_info(user_data.get('Mobile Operating System'))
|
383 |
mobile_ram = user_data.get('Mobile RAM', 'Not specified')
|
384 |
+
mobile_rec, mobile_tier, mobile_info, mobile_models = recommend_llm(mobile_ram)
|
385 |
+
mobile_ram_gb = extract_numeric_ram(mobile_ram) or 0
|
386 |
|
387 |
st.markdown(f"**OS:** {mobile_os_icon} {mobile_os_name}")
|
388 |
st.markdown(f"**RAM:** {mobile_ram}")
|
389 |
+
st.markdown(f"**Performance Tier:** {mobile_tier}")
|
390 |
+
|
391 |
+
st.success(f"**๐ก Recommendation:** {mobile_rec}")
|
392 |
+
st.info(f"**โน๏ธ Notes:** {mobile_info}")
|
393 |
|
394 |
+
# Display detailed models for mobile
|
395 |
+
if mobile_models:
|
396 |
+
filtered_models = {k: v for k, v in mobile_models.items() if k in show_categories}
|
397 |
+
display_model_categories(filtered_models, mobile_ram_gb)
|
398 |
|
399 |
+
# Batch Analysis Section
|
400 |
st.markdown("---")
|
401 |
+
st.header("๐ Batch Analysis & Insights")
|
402 |
|
403 |
+
# Create enhanced batch table
|
404 |
df_display = df[["Full Name", "Laptop RAM", "Mobile RAM"]].copy()
|
|
|
|
|
405 |
|
406 |
+
# Add recommendations and performance tiers
|
407 |
+
laptop_recommendations = df["Laptop RAM"].apply(lambda x: recommend_llm(x)[0])
|
408 |
+
mobile_recommendations = df["Mobile RAM"].apply(lambda x: recommend_llm(x)[0])
|
409 |
+
laptop_tiers = df["Laptop RAM"].apply(lambda x: recommend_llm(x)[1])
|
410 |
+
mobile_tiers = df["Mobile RAM"].apply(lambda x: recommend_llm(x)[1])
|
411 |
+
|
412 |
+
df_display["Laptop LLM"] = laptop_recommendations
|
413 |
+
df_display["Mobile LLM"] = mobile_recommendations
|
414 |
+
df_display["Laptop Tier"] = laptop_tiers
|
415 |
+
df_display["Mobile Tier"] = mobile_tiers
|
416 |
+
|
417 |
+
# Filter based on sidebar selections (RAM range filter removed)
|
418 |
+
mask = (laptop_tiers.isin(performance_filter) | mobile_tiers.isin(performance_filter))
|
419 |
+
|
420 |
+
df_filtered = df_display[mask]
|
421 |
|
422 |
+
# Display filtered table
|
423 |
+
st.subheader(f"๐ Student Recommendations ({len(df_filtered)} students)")
|
424 |
+
st.dataframe(
|
425 |
+
df_filtered,
|
426 |
+
use_container_width=True,
|
427 |
+
column_config={
|
428 |
+
"Full Name": st.column_config.TextColumn("Student Name", width="medium"),
|
429 |
+
"Laptop RAM": st.column_config.TextColumn("Laptop RAM", width="small"),
|
430 |
+
"Mobile RAM": st.column_config.TextColumn("Mobile RAM", width="small"),
|
431 |
+
"Laptop LLM": st.column_config.TextColumn("Laptop Recommendation", width="large"),
|
432 |
+
"Mobile LLM": st.column_config.TextColumn("Mobile Recommendation", width="large"),
|
433 |
+
"Laptop Tier": st.column_config.TextColumn("L-Tier", width="small"),
|
434 |
+
"Mobile Tier": st.column_config.TextColumn("M-Tier", width="small"),
|
435 |
+
}
|
436 |
+
)
|
437 |
+
|
438 |
+
# Performance distribution chart
|
439 |
if len(df) > 1:
|
440 |
+
st.subheader("๐ RAM Distribution Analysis")
|
441 |
fig = create_performance_chart(df)
|
442 |
st.plotly_chart(fig, use_container_width=True)
|
443 |
|
444 |
+
# Performance tier summary
|
445 |
+
st.subheader("๐ฏ Performance Tier Summary")
|
446 |
+
tier_col1, tier_col2 = st.columns(2)
|
447 |
+
|
448 |
+
with tier_col1:
|
449 |
+
st.markdown("**Laptop Performance Tiers:**")
|
450 |
+
laptop_tier_counts = laptop_tiers.value_counts()
|
451 |
+
for tier, count in laptop_tier_counts.items():
|
452 |
+
percentage = (count / len(laptop_tiers)) * 100
|
453 |
+
st.write(f"โข {tier}: {count} students ({percentage:.1f}%)")
|
454 |
+
|
455 |
+
with tier_col2:
|
456 |
+
st.markdown("**Mobile Performance Tiers:**")
|
457 |
+
mobile_tier_counts = mobile_tiers.value_counts()
|
458 |
+
for tier, count in mobile_tier_counts.items():
|
459 |
+
percentage = (count / len(mobile_tier_counts)) * 100
|
460 |
+
st.write(f"โข {tier}: {count} students ({percentage:.1f}%)")
|
461 |
+
|
462 |
+
# Model Explorer Section
|
463 |
st.markdown("---")
|
464 |
+
st.header("๐ Popular Model Explorer")
|
465 |
|
466 |
+
explorer_col1, explorer_col2 = st.columns(2)
|
|
|
|
|
|
|
|
|
467 |
|
468 |
+
with explorer_col1:
|
469 |
+
selected_ram_range = st.selectbox(
|
470 |
+
"Select RAM range to explore models:",
|
471 |
+
["โค2GB (Ultra Low)", "3-4GB (Low)", "5-6GB (Moderate-Low)",
|
472 |
+
"7-8GB (Moderate)", "9-16GB (Good)", "17-32GB (High)", ">32GB (Ultra High)"]
|
473 |
+
)
|
474 |
+
|
475 |
+
with explorer_col2:
|
476 |
+
selected_category = st.selectbox(
|
477 |
+
"Select model category:",
|
478 |
+
["general", "code", "chat", "reasoning", "multimodal"]
|
479 |
+
)
|
480 |
+
|
481 |
+
# Map selection to database key
|
482 |
ram_mapping = {
|
483 |
"โค2GB (Ultra Low)": "ultra_low",
|
484 |
"3-4GB (Low)": "low",
|
485 |
+
"5-6GB (Moderate-Low)": "moderate_low",
|
486 |
+
"7-8GB (Moderate)": "moderate",
|
487 |
"9-16GB (Good)": "good",
|
488 |
"17-32GB (High)": "high",
|
489 |
">32GB (Ultra High)": "ultra_high"
|
490 |
}
|
491 |
|
492 |
+
selected_ram_key = ram_mapping[selected_ram_range]
|
493 |
+
if selected_ram_key in LLM_DATABASE and selected_category in LLM_DATABASE[selected_ram_key]:
|
494 |
+
models = LLM_DATABASE[selected_ram_key][selected_category]
|
495 |
+
|
496 |
+
st.subheader(f"๐ฏ {selected_category.title()} Models for {selected_ram_range}")
|
497 |
+
|
498 |
+
# Display models in a detailed table
|
499 |
+
for model in models:
|
500 |
+
with st.container():
|
501 |
+
col1, col2, col3 = st.columns([3, 1, 3])
|
502 |
+
with col1:
|
503 |
+
st.markdown(f"### {model['name']}")
|
504 |
+
with col2:
|
505 |
+
st.markdown(f"**{model['size']}**")
|
506 |
+
st.caption("Download Size")
|
507 |
+
with col3:
|
508 |
+
st.markdown(f"*{model['description']}*")
|
509 |
+
# Add download suggestion
|
510 |
+
if "Llama" in model['name']:
|
511 |
+
st.caption("๐ Available on Hugging Face & Ollama")
|
512 |
+
elif "Mistral" in model['name']:
|
513 |
+
st.caption("๐ Available on Hugging Face & Mistral AI")
|
514 |
+
elif "Gemma" in model['name']:
|
515 |
+
st.caption("๐ Available on Hugging Face & Google")
|
516 |
+
else:
|
517 |
+
st.caption("๐ Available on Hugging Face")
|
518 |
+
st.markdown("---")
|
519 |
+
else:
|
520 |
+
st.info(f"No {selected_category} models available for {selected_ram_range}")
|
521 |
|
522 |
+
# Enhanced reference guide
|
523 |
+
with st.expander("๐ Model Guide & Download Information"):
|
524 |
st.markdown("""
|
525 |
+
## ๐ Popular Models by Category
|
526 |
+
|
527 |
+
### ๐ฏ **General Purpose Champions**
|
528 |
+
- **Llama-2 Series**: Meta's flagship models (7B, 13B, 70B)
|
529 |
+
- **Mistral Series**: Excellent efficiency and performance
|
530 |
+
- **Gemma**: Google's efficient models (2B, 7B)
|
531 |
+
- **Phi**: Microsoft's compact powerhouses
|
532 |
|
533 |
+
### ๐ป **Code Specialists**
|
534 |
+
- **CodeLlama**: Meta's dedicated coding models
|
535 |
+
- **StarCoder**: BigCode's programming experts
|
536 |
+
- **WizardCoder**: Enhanced coding capabilities
|
537 |
+
- **DeepSeek-Coder**: Chinese tech giant's coder
|
538 |
|
539 |
+
### ๐ฌ **Chat Optimized**
|
540 |
+
- **Vicuna**: UC Berkeley's ChatGPT alternative
|
541 |
+
- **Zephyr**: HuggingFace's chat specialist
|
542 |
+
- **OpenChat**: High-quality conversation models
|
543 |
+
- **Neural-Chat**: Intel-optimized chat models
|
544 |
|
545 |
+
### ๐งฎ **Reasoning Masters**
|
546 |
+
- **WizardMath**: Mathematical problem solving
|
547 |
+
- **MetaMath**: Advanced arithmetic reasoning
|
548 |
+
- **Orca-2**: Microsoft's reasoning specialist
|
549 |
+
- **Goat**: Specialized arithmetic model
|
550 |
+
|
551 |
+
### ๐๏ธ **Multimodal Models**
|
552 |
+
- **LLaVA**: Large Language and Vision Assistant
|
553 |
+
- **MiniGPT-4**: Multimodal conversational AI
|
554 |
+
|
555 |
+
## ๐พ Download Size Reference
|
556 |
+
|
557 |
+
| Model Size | FP16 | 8-bit | 4-bit | Use Case |
|
558 |
+
|------------|------|-------|-------|----------|
|
559 |
+
| **1-3B** | 2-6GB | 1-3GB | 0.5-1.5GB | Mobile, Edge |
|
560 |
+
| **7B** | 13GB | 7GB | 3.5GB | Desktop, Laptop |
|
561 |
+
| **13B** | 26GB | 13GB | 7GB | Workstation |
|
562 |
+
| **30-34B** | 60GB | 30GB | 15GB | Server, Cloud |
|
563 |
+
| **70B** | 140GB | 70GB | 35GB | High-end Server |
|
564 |
+
|
565 |
+
## ๐ ๏ธ Where to Download
|
566 |
+
|
567 |
+
### **Primary Sources**
|
568 |
+
- **๐ค Hugging Face**: Largest repository with 400,000+ models
|
569 |
+
- **๐ฆ Ollama**: Simple CLI tool for local deployment
|
570 |
+
- **๐ฆ LM Studio**: User-friendly GUI for model management
|
571 |
+
|
572 |
+
### **Quantized Formats**
|
573 |
+
- **GGUF**: Best for CPU inference (llama.cpp)
|
574 |
+
- **GPTQ**: GPU-optimized quantization
|
575 |
+
- **AWQ**: Advanced weight quantization
|
576 |
+
|
577 |
+
### **Download Tips**
|
578 |
+
- Use `git lfs` for large models from Hugging Face
|
579 |
+
- Consider bandwidth and storage before downloading
|
580 |
+
- Start with 4-bit quantized versions for testing
|
581 |
+
- Use `ollama pull model_name` for easiest setup
|
582 |
+
|
583 |
+
## ๐ง Optimization Strategies
|
584 |
+
|
585 |
+
### **Memory Reduction**
|
586 |
+
- **4-bit quantization**: 75% memory reduction
|
587 |
+
- **8-bit quantization**: 50% memory reduction
|
588 |
+
- **CPU offloading**: Use system RAM for overflow
|
589 |
+
|
590 |
+
### **Speed Optimization**
|
591 |
+
- **GPU acceleration**: CUDA, ROCm, Metal
|
592 |
+
- **Batch processing**: Process multiple requests
|
593 |
+
- **Context caching**: Reuse computations
|
594 |
""")
|
595 |
|
596 |
+
# Footer with updated resources
|
597 |
st.markdown("---")
|
598 |
+
st.markdown("""
|
599 |
+
### ๐ Essential Download & Deployment Tools
|
600 |
+
|
601 |
+
**๐ฆ Easy Model Deployment:**
|
602 |
+
- [**Ollama**](https://ollama.ai/) โ `curl -fsSL https://ollama.ai/install.sh | sh`
|
603 |
+
- [**LM Studio**](https://lmstudio.ai/) โ Drag-and-drop GUI for running models locally
|
604 |
+
- [**GPT4All**](https://gpt4all.io/) โ Cross-platform desktop app for local LLMs
|
605 |
+
|
606 |
+
**๐ค Model Repositories:**
|
607 |
+
- [**Hugging Face Hub**](https://huggingface.co/models) โ Filter by model size, task, and license
|
608 |
+
- [**TheBloke's Quantizations**](https://huggingface.co/TheBloke) โ Pre-quantized models in GGUF/GPTQ format
|
609 |
+
- [**Awesome LLM**](https://github.com/Hannibal046/Awesome-LLMs) โ Curated list of models and resources
|
610 |
+
|
611 |
+
|
612 |
+
---
|
613 |
+
""")
|