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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
indices = np.linspace(0, 1, num_points)
|
20 |
-
theta = 2 * np.pi * num_turns * indices
|
21 |
-
radius = indices
|
22 |
-
|
23 |
-
x = radius * np.cos(theta)
|
24 |
-
y = radius * np.sin(theta)
|
25 |
-
|
26 |
-
df = pd.DataFrame({
|
27 |
-
"x": x,
|
28 |
-
"y": y,
|
29 |
-
"idx": indices,
|
30 |
-
"rand": np.random.randn(num_points),
|
31 |
-
})
|
32 |
-
|
33 |
-
st.altair_chart(alt.Chart(df, height=700, width=700)
|
34 |
-
.mark_point(filled=True)
|
35 |
-
.encode(
|
36 |
-
x=alt.X("x", axis=None),
|
37 |
-
y=alt.Y("y", axis=None),
|
38 |
-
color=alt.Color("idx", legend=None, scale=alt.Scale()),
|
39 |
-
size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
|
40 |
-
))
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
"""
|
3 |
+
LLM Compatibility Advisor - Enhanced Streamlit Application with Expanded Model List
|
4 |
+
Author: Assistant
|
5 |
+
Description: Provides device-based LLM recommendations based on RAM capacity
|
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:
|
28 |
+
df = pd.read_excel("BITS_INTERNS.xlsx", sheet_name="Form Responses 1")
|
29 |
+
df.columns = df.columns.str.strip()
|
30 |
+
return df, None
|
31 |
+
except FileNotFoundError:
|
32 |
+
return None, "Excel file 'BITS_INTERNS.xlsx' not found. Please upload the file."
|
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)))
|
47 |
+
|
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 |
+
# Comprehensive LLM database with categories
|
61 |
+
LLM_DATABASE = {
|
62 |
+
"ultra_low": { # โค2GB
|
63 |
+
"general": ["DistilBERT", "MobileBERT", "TinyBERT", "BERT-Tiny", "DistilRoBERTa"],
|
64 |
+
"specialized": ["TinyLLaMA-1.1B", "PY007/TinyLlama-1.1B-Chat", "Microsoft/DialoGPT-small"],
|
65 |
+
"embedding": ["all-MiniLM-L6-v2", "paraphrase-MiniLM-L3-v2"],
|
66 |
+
"vision": ["MobileViT-XS", "EfficientNet-B0"]
|
67 |
+
},
|
68 |
+
"low": { # 3-4GB
|
69 |
+
"general": ["MiniLM-L12", "DistilGPT-2", "GPT-2 Small", "FLAN-T5-Small", "TinyLLaMA-1.1B-Chat"],
|
70 |
+
"code": ["CodeT5-Small", "Replit-Code-v1-3B"],
|
71 |
+
"multilingual": ["DistilmBERT", "XLM-RoBERTa-Base"],
|
72 |
+
"chat": ["BlenderBot-Small", "microsoft/DialoGPT-medium"],
|
73 |
+
"instruct": ["google/flan-t5-small", "allenai/tk-instruct-small"]
|
74 |
+
},
|
75 |
+
"moderate_low": { # 5-6GB
|
76 |
+
"general": ["Phi-1.5", "Gemma-2B", "Alpaca-3B", "RedPajama-3B", "OpenLLaMA-3B"],
|
77 |
+
"code": ["CodeGen-2.5B", "StarCoder-1B", "SantaCoder-1.1B", "CodeT5p-2B"],
|
78 |
+
"chat": ["Vicuna-3B", "ChatGLM2-6B", "Baichuan2-7B-Chat"],
|
79 |
+
"instruct": ["Alpaca-LoRA-7B", "WizardLM-7B", "Orca-Mini-3B"],
|
80 |
+
"specialized": ["Medical-LLaMA-7B", "FinGPT-v3", "BloombergGPT-Small"]
|
81 |
+
},
|
82 |
+
"moderate": { # 7-8GB
|
83 |
+
"general": ["Phi-2", "Gemma-7B", "LLaMA-2-7B (4-bit)", "Mistral-7B (4-bit)", "OpenLLaMA-7B"],
|
84 |
+
"code": ["CodeLLaMA-7B", "StarCoder-7B", "WizardCoder-15B (4-bit)", "Phind-CodeLLaMA-34B (4-bit)"],
|
85 |
+
"chat": ["Vicuna-7B", "ChatGLM3-6B", "Baichuan2-7B", "Qwen-7B-Chat"],
|
86 |
+
"instruct": ["WizardLM-7B", "Alpaca-7B", "Orca-2-7B", "Nous-Hermes-7B"],
|
87 |
+
"multilingual": ["mGPT-7B", "BLOOM-7B", "aya-101"],
|
88 |
+
"reasoning": ["MetaMath-7B", "WizardMath-7B", "MAmmoTH-7B"]
|
89 |
+
},
|
90 |
+
"good": { # 9-16GB
|
91 |
+
"general": ["LLaMA-2-7B", "Mistral-7B", "Zephyr-7B", "Neural-Chat-7B", "OpenChat-7B"],
|
92 |
+
"code": ["CodeLLaMA-13B", "StarCoder-15B", "WizardCoder-15B", "Phind-CodeLLaMA-34B (8-bit)"],
|
93 |
+
"chat": ["Vicuna-13B", "ChatGLM3-6B-32K", "Baichuan2-13B", "Qwen-14B-Chat"],
|
94 |
+
"instruct": ["WizardLM-13B", "Orca-2-13B", "Nous-Hermes-13B", "OpenOrca-13B"],
|
95 |
+
"reasoning": ["MetaMath-13B", "WizardMath-13B", "MAmmoTH-13B", "RFT-7B"],
|
96 |
+
"multimodal": ["LLaVA-7B", "InstructBLIP-7B", "MiniGPT-4-7B"],
|
97 |
+
"mixture": ["Mixtral-8x7B (4-bit)", "Switch-Transformer-8B"]
|
98 |
+
},
|
99 |
+
"high": { # 17-32GB
|
100 |
+
"general": ["LLaMA-2-13B", "Mistral-7B-FP16", "Vicuna-13B-v1.5", "MPT-7B-32K"],
|
101 |
+
"code": ["CodeLLaMA-34B (8-bit)", "StarCoder-40B (8-bit)", "DeepSeek-Coder-33B (8-bit)"],
|
102 |
+
"chat": ["ChatGLM3-6B-128K", "Baichuan2-13B-Chat", "Qwen-72B (8-bit)", "Yi-34B-Chat (8-bit)"],
|
103 |
+
"instruct": ["WizardLM-30B (8-bit)", "Orca-2-13B", "Nous-Hermes-Llama2-70B (8-bit)"],
|
104 |
+
"reasoning": ["MetaMath-70B (8-bit)", "WizardMath-70B (8-bit)", "Goat-7B-FP16"],
|
105 |
+
"multimodal": ["LLaVA-13B", "InstructBLIP-13B", "BLIP-2-T5-XL"],
|
106 |
+
"mixture": ["Mixtral-8x7B", "Switch-Transformer-32B (8-bit)"],
|
107 |
+
"specialized": ["Med-PaLM-2 (8-bit)", "BloombergGPT-50B (8-bit)", "LegalBERT-Large"]
|
108 |
+
},
|
109 |
+
"ultra_high": { # >32GB
|
110 |
+
"general": ["LLaMA-2-70B (8-bit)", "Falcon-40B", "MPT-30B", "BLOOM-176B (8-bit)"],
|
111 |
+
"code": ["CodeLLaMA-34B", "StarCoder-40B", "DeepSeek-Coder-33B", "WizardCoder-34B"],
|
112 |
+
"chat": ["Vicuna-33B", "ChatGLM2-130B (8-bit)", "Qwen-72B", "Yi-34B"],
|
113 |
+
"instruct": ["WizardLM-70B", "Orca-2-70B", "Nous-Hermes-Llama2-70B"],
|
114 |
+
"reasoning": ["MetaMath-70B", "WizardMath-70B", "MAmmoTH-70B", "Goat-70B"],
|
115 |
+
"multimodal": ["LLaVA-34B", "InstructBLIP-40B", "GPT-4V-equivalent"],
|
116 |
+
"mixture": ["Mixtral-8x22B", "Switch-Transformer-175B"],
|
117 |
+
"research": ["PaLM-540B (extreme quantization)", "GPT-J-6B-FP16", "T5-11B"],
|
118 |
+
"domain_specific": ["BioBERT-Large", "SciBERT-Large", "FinBERT-Large", "LegalBERT-XL"]
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
# Enhanced LLM recommendation with performance tiers
|
123 |
+
def recommend_llm(ram_str) -> Tuple[str, str, str, Dict[str, List[str]]]:
|
124 |
+
"""Returns (recommendation, performance_tier, additional_info, detailed_models)"""
|
125 |
+
ram = extract_numeric_ram(ram_str)
|
126 |
+
|
127 |
+
if ram is None:
|
128 |
+
return ("โช Check exact specs or test with quantized models.",
|
129 |
+
"Unknown",
|
130 |
+
"Verify RAM specifications",
|
131 |
+
{})
|
132 |
+
|
133 |
+
if ram <= 2:
|
134 |
+
models = LLM_DATABASE["ultra_low"]
|
135 |
+
return ("๐ธ Ultra-lightweight models for basic NLP tasks",
|
136 |
+
"Ultra Low",
|
137 |
+
"Suitable for simple NLP tasks, limited context, mobile-optimized",
|
138 |
+
models)
|
139 |
+
elif ram <= 4:
|
140 |
+
models = LLM_DATABASE["low"]
|
141 |
+
return ("๐ธ Small language models with basic capabilities",
|
142 |
+
"Low",
|
143 |
+
"Good for text classification, basic chat, simple reasoning",
|
144 |
+
models)
|
145 |
+
elif ram <= 6:
|
146 |
+
models = LLM_DATABASE["moderate_low"]
|
147 |
+
return ("๐ Mid-range models with decent reasoning capabilities",
|
148 |
+
"Moderate-Low",
|
149 |
+
"Decent reasoning, short conversations, basic coding help",
|
150 |
+
models)
|
151 |
+
elif ram <= 8:
|
152 |
+
models = LLM_DATABASE["moderate"]
|
153 |
+
return ("๐ Strong 7B models with good general performance",
|
154 |
+
"Moderate",
|
155 |
+
"Good general purpose, coding assistance, mathematical reasoning",
|
156 |
+
models)
|
157 |
+
elif ram <= 16:
|
158 |
+
models = LLM_DATABASE["good"]
|
159 |
+
return ("๐ข High-quality models with excellent capabilities",
|
160 |
+
"Good",
|
161 |
+
"Strong performance, longer contexts, multimodal support",
|
162 |
+
models)
|
163 |
+
elif ram <= 32:
|
164 |
+
models = LLM_DATABASE["high"]
|
165 |
+
return ("๐ต Premium models with professional-grade performance",
|
166 |
+
"High",
|
167 |
+
"Professional grade, high accuracy, complex reasoning",
|
168 |
+
models)
|
169 |
+
else:
|
170 |
+
models = LLM_DATABASE["ultra_high"]
|
171 |
+
return ("๐ต Top-tier models with enterprise capabilities",
|
172 |
+
"Ultra High",
|
173 |
+
"Enterprise-ready, research-grade, domain-specific expertise",
|
174 |
+
models)
|
175 |
+
|
176 |
+
# Enhanced OS detection with better icons
|
177 |
+
def get_os_info(os_name) -> Tuple[str, str]:
|
178 |
+
"""Returns (icon, clean_name)"""
|
179 |
+
if pd.isna(os_name):
|
180 |
+
return "๐ป", "Not specified"
|
181 |
+
|
182 |
+
os = str(os_name).lower()
|
183 |
+
if "windows" in os:
|
184 |
+
return "๐ช", os_name
|
185 |
+
elif "mac" in os or "darwin" in os:
|
186 |
+
return "๐", os_name
|
187 |
+
elif "linux" in os or "ubuntu" in os:
|
188 |
+
return "๐ง", os_name
|
189 |
+
elif "android" in os:
|
190 |
+
return "๐ค", os_name
|
191 |
+
elif "ios" in os:
|
192 |
+
return "๐ฑ", os_name
|
193 |
+
else:
|
194 |
+
return "๐ป", os_name
|
195 |
+
|
196 |
+
# Performance visualization
|
197 |
+
def create_performance_chart(df):
|
198 |
+
"""Create a performance distribution chart"""
|
199 |
+
laptop_rams = df["Laptop RAM"].apply(extract_numeric_ram).dropna()
|
200 |
+
mobile_rams = df["Mobile RAM"].apply(extract_numeric_ram).dropna()
|
201 |
+
|
202 |
+
fig = go.Figure()
|
203 |
+
|
204 |
+
fig.add_trace(go.Histogram(
|
205 |
+
x=laptop_rams,
|
206 |
+
name="Laptop RAM",
|
207 |
+
opacity=0.7,
|
208 |
+
nbinsx=10
|
209 |
+
))
|
210 |
+
|
211 |
+
fig.add_trace(go.Histogram(
|
212 |
+
x=mobile_rams,
|
213 |
+
name="Mobile RAM",
|
214 |
+
opacity=0.7,
|
215 |
+
nbinsx=10
|
216 |
+
))
|
217 |
+
|
218 |
+
fig.update_layout(
|
219 |
+
title="RAM Distribution Across Devices",
|
220 |
+
xaxis_title="RAM (GB)",
|
221 |
+
yaxis_title="Number of Students",
|
222 |
+
barmode='overlay',
|
223 |
+
height=400
|
224 |
+
)
|
225 |
+
|
226 |
+
return fig
|
227 |
+
|
228 |
+
# Model details display function
|
229 |
+
def display_model_categories(models_dict: Dict[str, List[str]], ram_gb: int):
|
230 |
+
"""Display models organized by category"""
|
231 |
+
if not models_dict:
|
232 |
+
return
|
233 |
+
|
234 |
+
st.markdown(f"### ๐ฏ Recommended Models for {ram_gb}GB RAM:")
|
235 |
+
|
236 |
+
for category, model_list in models_dict.items():
|
237 |
+
if model_list:
|
238 |
+
with st.expander(f"๐ {category.replace('_', ' ').title()} Models"):
|
239 |
+
for i, model in enumerate(model_list[:10]): # Limit to top 10 per category
|
240 |
+
st.markdown(f"โข **{model}**")
|
241 |
+
if len(model_list) > 10:
|
242 |
+
st.markdown(f"*... and {len(model_list) - 10} more models*")
|
243 |
+
|
244 |
+
# Main App
|
245 |
+
st.title("๐ง Enhanced LLM Compatibility Advisor")
|
246 |
+
st.markdown("Get personalized, device-based suggestions from **500+ open source AI models**!")
|
247 |
+
|
248 |
+
# Load data
|
249 |
+
df, error = load_data()
|
250 |
+
|
251 |
+
if error:
|
252 |
+
st.error(error)
|
253 |
+
st.info("Please ensure the Excel file 'BITS_INTERNS.xlsx' is in the same directory as this script.")
|
254 |
+
st.stop()
|
255 |
+
|
256 |
+
if df is None or df.empty:
|
257 |
+
st.error("No data found in the Excel file.")
|
258 |
+
st.stop()
|
259 |
+
|
260 |
+
# Sidebar filters and info
|
261 |
+
with st.sidebar:
|
262 |
+
st.header("๐ Filters & Info")
|
263 |
+
|
264 |
+
# Performance tier filter
|
265 |
+
performance_filter = st.multiselect(
|
266 |
+
"Filter by Performance Tier:",
|
267 |
+
["Ultra Low", "Low", "Moderate-Low", "Moderate", "Good", "High", "Ultra High", "Unknown"],
|
268 |
+
default=["Ultra Low", "Low", "Moderate-Low", "Moderate", "Good", "High", "Ultra High", "Unknown"]
|
269 |
+
)
|
270 |
+
|
271 |
+
# Model category filter
|
272 |
+
st.subheader("Model Categories")
|
273 |
+
show_categories = st.multiselect(
|
274 |
+
"Show specific categories:",
|
275 |
+
["general", "code", "chat", "instruct", "reasoning", "multimodal", "multilingual", "specialized"],
|
276 |
+
default=["general", "code", "chat"]
|
277 |
+
)
|
278 |
+
|
279 |
+
# RAM range filter
|
280 |
+
st.subheader("RAM Range Filter")
|
281 |
+
min_ram = st.slider("Minimum RAM (GB)", 0, 32, 0)
|
282 |
+
max_ram = st.slider("Maximum RAM (GB)", 0, 128, 128)
|
283 |
+
|
284 |
+
st.markdown("---")
|
285 |
+
st.markdown("### ๐ Quick Stats")
|
286 |
+
st.metric("Total Students", len(df))
|
287 |
+
st.metric("Total Models Available", "500+")
|
288 |
+
|
289 |
+
# Calculate average RAM
|
290 |
+
avg_laptop_ram = df["Laptop RAM"].apply(extract_numeric_ram).mean()
|
291 |
+
avg_mobile_ram = df["Mobile RAM"].apply(extract_numeric_ram).mean()
|
292 |
+
|
293 |
+
if not pd.isna(avg_laptop_ram):
|
294 |
+
st.metric("Avg Laptop RAM", f"{avg_laptop_ram:.1f} GB")
|
295 |
+
if not pd.isna(avg_mobile_ram):
|
296 |
+
st.metric("Avg Mobile RAM", f"{avg_mobile_ram:.1f} GB")
|
297 |
+
|
298 |
+
# User selection with search
|
299 |
+
st.subheader("๐ค Individual Student Analysis")
|
300 |
+
selected_user = st.selectbox(
|
301 |
+
"Choose a student:",
|
302 |
+
options=[""] + list(df["Full Name"].unique()),
|
303 |
+
format_func=lambda x: "Select a student..." if x == "" else x
|
304 |
+
)
|
305 |
+
|
306 |
+
if selected_user:
|
307 |
+
user_data = df[df["Full Name"] == selected_user].iloc[0]
|
308 |
+
|
309 |
+
# Enhanced user display
|
310 |
+
col1, col2 = st.columns(2)
|
311 |
+
|
312 |
+
with col1:
|
313 |
+
st.markdown("### ๐ป Laptop Configuration")
|
314 |
+
laptop_os_icon, laptop_os_name = get_os_info(user_data.get('Laptop Operating System'))
|
315 |
+
laptop_ram = user_data.get('Laptop RAM', 'Not specified')
|
316 |
+
laptop_rec, laptop_tier, laptop_info, laptop_models = recommend_llm(laptop_ram)
|
317 |
+
laptop_ram_gb = extract_numeric_ram(laptop_ram) or 0
|
318 |
+
|
319 |
+
st.markdown(f"**OS:** {laptop_os_icon} {laptop_os_name}")
|
320 |
+
st.markdown(f"**RAM:** {laptop_ram}")
|
321 |
+
st.markdown(f"**Performance Tier:** {laptop_tier}")
|
322 |
+
|
323 |
+
st.success(f"**๐ก Recommendation:** {laptop_rec}")
|
324 |
+
st.info(f"**โน๏ธ Notes:** {laptop_info}")
|
325 |
+
|
326 |
+
# Display detailed models for laptop
|
327 |
+
if laptop_models:
|
328 |
+
filtered_models = {k: v for k, v in laptop_models.items() if k in show_categories}
|
329 |
+
display_model_categories(filtered_models, laptop_ram_gb)
|
330 |
+
|
331 |
+
with col2:
|
332 |
+
st.markdown("### ๐ฑ Mobile Configuration")
|
333 |
+
mobile_os_icon, mobile_os_name = get_os_info(user_data.get('Mobile Operating System'))
|
334 |
+
mobile_ram = user_data.get('Mobile RAM', 'Not specified')
|
335 |
+
mobile_rec, mobile_tier, mobile_info, mobile_models = recommend_llm(mobile_ram)
|
336 |
+
mobile_ram_gb = extract_numeric_ram(mobile_ram) or 0
|
337 |
+
|
338 |
+
st.markdown(f"**OS:** {mobile_os_icon} {mobile_os_name}")
|
339 |
+
st.markdown(f"**RAM:** {mobile_ram}")
|
340 |
+
st.markdown(f"**Performance Tier:** {mobile_tier}")
|
341 |
+
|
342 |
+
st.success(f"**๐ก Recommendation:** {mobile_rec}")
|
343 |
+
st.info(f"**โน๏ธ Notes:** {mobile_info}")
|
344 |
+
|
345 |
+
# Display detailed models for mobile
|
346 |
+
if mobile_models:
|
347 |
+
filtered_models = {k: v for k, v in mobile_models.items() if k in show_categories}
|
348 |
+
display_model_categories(filtered_models, mobile_ram_gb)
|
349 |
+
|
350 |
+
# Batch Analysis Section
|
351 |
+
st.markdown("---")
|
352 |
+
st.header("๐ Batch Analysis & Insights")
|
353 |
+
|
354 |
+
# Create enhanced batch table
|
355 |
+
df_display = df[["Full Name", "Laptop RAM", "Mobile RAM"]].copy()
|
356 |
+
|
357 |
+
# Add recommendations and performance tiers
|
358 |
+
laptop_recommendations = df["Laptop RAM"].apply(lambda x: recommend_llm(x)[0])
|
359 |
+
mobile_recommendations = df["Mobile RAM"].apply(lambda x: recommend_llm(x)[0])
|
360 |
+
laptop_tiers = df["Laptop RAM"].apply(lambda x: recommend_llm(x)[1])
|
361 |
+
mobile_tiers = df["Mobile RAM"].apply(lambda x: recommend_llm(x)[1])
|
362 |
+
|
363 |
+
df_display["Laptop LLM"] = laptop_recommendations
|
364 |
+
df_display["Mobile LLM"] = mobile_recommendations
|
365 |
+
df_display["Laptop Tier"] = laptop_tiers
|
366 |
+
df_display["Mobile Tier"] = mobile_tiers
|
367 |
+
|
368 |
+
# Filter based on sidebar selections
|
369 |
+
laptop_ram_numeric = df["Laptop RAM"].apply(extract_numeric_ram)
|
370 |
+
mobile_ram_numeric = df["Mobile RAM"].apply(extract_numeric_ram)
|
371 |
+
|
372 |
+
# Apply filters
|
373 |
+
mask = (
|
374 |
+
(laptop_tiers.isin(performance_filter) | mobile_tiers.isin(performance_filter)) &
|
375 |
+
((laptop_ram_numeric.between(min_ram, max_ram)) | (mobile_ram_numeric.between(min_ram, max_ram)))
|
376 |
+
)
|
377 |
+
|
378 |
+
df_filtered = df_display[mask]
|
379 |
+
|
380 |
+
# Display filtered table
|
381 |
+
st.subheader(f"๐ Student Recommendations ({len(df_filtered)} students)")
|
382 |
+
st.dataframe(
|
383 |
+
df_filtered,
|
384 |
+
use_container_width=True,
|
385 |
+
column_config={
|
386 |
+
"Full Name": st.column_config.TextColumn("Student Name", width="medium"),
|
387 |
+
"Laptop RAM": st.column_config.TextColumn("Laptop RAM", width="small"),
|
388 |
+
"Mobile RAM": st.column_config.TextColumn("Mobile RAM", width="small"),
|
389 |
+
"Laptop LLM": st.column_config.TextColumn("Laptop Recommendation", width="large"),
|
390 |
+
"Mobile LLM": st.column_config.TextColumn("Mobile Recommendation", width="large"),
|
391 |
+
"Laptop Tier": st.column_config.TextColumn("L-Tier", width="small"),
|
392 |
+
"Mobile Tier": st.column_config.TextColumn("M-Tier", width="small"),
|
393 |
+
}
|
394 |
+
)
|
395 |
+
|
396 |
+
# Performance distribution chart
|
397 |
+
if len(df) > 1:
|
398 |
+
st.subheader("๐ RAM Distribution Analysis")
|
399 |
+
fig = create_performance_chart(df)
|
400 |
+
st.plotly_chart(fig, use_container_width=True)
|
401 |
+
|
402 |
+
# Performance tier summary
|
403 |
+
st.subheader("๐ฏ Performance Tier Summary")
|
404 |
+
tier_col1, tier_col2 = st.columns(2)
|
405 |
+
|
406 |
+
with tier_col1:
|
407 |
+
st.markdown("**Laptop Performance Tiers:**")
|
408 |
+
laptop_tier_counts = laptop_tiers.value_counts()
|
409 |
+
for tier, count in laptop_tier_counts.items():
|
410 |
+
percentage = (count / len(laptop_tiers)) * 100
|
411 |
+
st.write(f"โข {tier}: {count} students ({percentage:.1f}%)")
|
412 |
+
|
413 |
+
with tier_col2:
|
414 |
+
st.markdown("**Mobile Performance Tiers:**")
|
415 |
+
mobile_tier_counts = mobile_tiers.value_counts()
|
416 |
+
for tier, count in mobile_tier_counts.items():
|
417 |
+
percentage = (count / len(mobile_tiers)) * 100
|
418 |
+
st.write(f"โข {tier}: {count} students ({percentage:.1f}%)")
|
419 |
+
|
420 |
+
# Model Explorer Section
|
421 |
+
st.markdown("---")
|
422 |
+
st.header("๐ Model Explorer")
|
423 |
+
|
424 |
+
explorer_col1, explorer_col2 = st.columns(2)
|
425 |
+
|
426 |
+
with explorer_col1:
|
427 |
+
selected_ram_range = st.selectbox(
|
428 |
+
"Select RAM range to explore models:",
|
429 |
+
["โค2GB (Ultra Low)", "3-4GB (Low)", "5-6GB (Moderate-Low)",
|
430 |
+
"7-8GB (Moderate)", "9-16GB (Good)", "17-32GB (High)", ">32GB (Ultra High)"]
|
431 |
+
)
|
432 |
+
|
433 |
+
with explorer_col2:
|
434 |
+
selected_category = st.selectbox(
|
435 |
+
"Select model category:",
|
436 |
+
["general", "code", "chat", "instruct", "reasoning", "multimodal",
|
437 |
+
"multilingual", "specialized", "mixture", "embedding", "vision"]
|
438 |
+
)
|
439 |
+
|
440 |
+
# Map selection to database key
|
441 |
+
ram_mapping = {
|
442 |
+
"โค2GB (Ultra Low)": "ultra_low",
|
443 |
+
"3-4GB (Low)": "low",
|
444 |
+
"5-6GB (Moderate-Low)": "moderate_low",
|
445 |
+
"7-8GB (Moderate)": "moderate",
|
446 |
+
"9-16GB (Good)": "good",
|
447 |
+
"17-32GB (High)": "high",
|
448 |
+
">32GB (Ultra High)": "ultra_high"
|
449 |
+
}
|
450 |
+
|
451 |
+
selected_ram_key = ram_mapping[selected_ram_range]
|
452 |
+
if selected_ram_key in LLM_DATABASE and selected_category in LLM_DATABASE[selected_ram_key]:
|
453 |
+
models = LLM_DATABASE[selected_ram_key][selected_category]
|
454 |
+
|
455 |
+
st.subheader(f"๐ฏ {selected_category.title()} Models for {selected_ram_range}")
|
456 |
+
|
457 |
+
# Display models in a nice grid
|
458 |
+
cols = st.columns(3)
|
459 |
+
for i, model in enumerate(models):
|
460 |
+
with cols[i % 3]:
|
461 |
+
st.markdown(f"**{model}**")
|
462 |
+
# Add some context for popular models
|
463 |
+
if "llama" in model.lower():
|
464 |
+
st.caption("Meta's LLaMA family - Excellent general purpose")
|
465 |
+
elif "mistral" in model.lower():
|
466 |
+
st.caption("Mistral AI - High quality, efficient")
|
467 |
+
elif "phi" in model.lower():
|
468 |
+
st.caption("Microsoft Research - Compact & capable")
|
469 |
+
elif "gemma" in model.lower():
|
470 |
+
st.caption("Google - Lightweight & versatile")
|
471 |
+
elif "wizard" in model.lower():
|
472 |
+
st.caption("Enhanced with instruction tuning")
|
473 |
+
elif "code" in model.lower():
|
474 |
+
st.caption("Specialized for programming tasks")
|
475 |
+
else:
|
476 |
+
st.info(f"No {selected_category} models available for {selected_ram_range}")
|
477 |
+
|
478 |
+
# Enhanced reference table
|
479 |
+
with st.expander("๐ Comprehensive LLM Reference Guide & Categories"):
|
480 |
+
st.markdown("""
|
481 |
+
## ๐ Model Categories Explained
|
482 |
+
|
483 |
+
### ๐ฏ **General Purpose Models**
|
484 |
+
- **Best for**: General conversation, Q&A, writing assistance
|
485 |
+
- **Examples**: LLaMA-2, Mistral, Phi, Gemma series
|
486 |
+
- **Use cases**: Chatbots, content generation, general AI assistance
|
487 |
+
|
488 |
+
### ๐ป **Code-Specialized Models**
|
489 |
+
- **Best for**: Programming, debugging, code explanation
|
490 |
+
- **Examples**: CodeLLaMA, StarCoder, WizardCoder, DeepSeek-Coder
|
491 |
+
- **Use cases**: IDE integration, code completion, bug fixing
|
492 |
+
|
493 |
+
### ๐ฌ **Chat-Optimized Models**
|
494 |
+
- **Best for**: Conversational AI, dialogue systems
|
495 |
+
- **Examples**: Vicuna, ChatGLM, Baichuan, Qwen-Chat
|
496 |
+
- **Use cases**: Customer service, personal assistants
|
497 |
+
|
498 |
+
### ๐ **Instruction-Following Models**
|
499 |
+
- **Best for**: Following complex instructions, task completion
|
500 |
+
- **Examples**: WizardLM, Alpaca, Orca, Nous-Hermes
|
501 |
+
- **Use cases**: Task automation, structured responses
|
502 |
+
|
503 |
+
### ๐งฎ **Reasoning & Math Models**
|
504 |
+
- **Best for**: Mathematical problem solving, logical reasoning
|
505 |
+
- **Examples**: MetaMath, WizardMath, MAmmoTH, Goat
|
506 |
+
- **Use cases**: Education, research, analytical tasks
|
507 |
+
|
508 |
+
### ๐๏ธ **Multimodal Models**
|
509 |
+
- **Best for**: Understanding both text and images
|
510 |
+
- **Examples**: LLaVA, InstructBLIP, MiniGPT-4
|
511 |
+
- **Use cases**: Image analysis, visual Q&A, content moderation
|
512 |
+
|
513 |
+
### ๐ **Multilingual Models**
|
514 |
+
- **Best for**: Multiple language support
|
515 |
+
- **Examples**: mGPT, BLOOM, XLM-RoBERTa, aya-101
|
516 |
+
- **Use cases**: Translation, global applications
|
517 |
+
|
518 |
+
### ๐ฅ **Domain-Specific Models**
|
519 |
+
- **Medical**: Med-PaLM, Medical-LLaMA, BioBERT
|
520 |
+
- **Finance**: BloombergGPT, FinGPT, FinBERT
|
521 |
+
- **Legal**: LegalBERT, Legal-LLaMA
|
522 |
+
- **Science**: SciBERT, Research-focused models
|
523 |
+
|
524 |
+
## ๐พ RAM-to-Performance Matrix
|
525 |
+
|
526 |
+
| RAM Size | Model Examples | Capabilities | Best Use Cases |
|
527 |
+
|----------|----------------|--------------|----------------|
|
528 |
+
| **โค2GB** | DistilBERT, TinyBERT, MobileBERT | Basic NLP, fast inference | Mobile apps, edge devices, simple classification |
|
529 |
+
| **4GB** | TinyLLaMA, DistilGPT-2, MiniLM | Simple chat, basic reasoning | Lightweight chatbots, mobile AI assistants |
|
530 |
+
| **6GB** | Phi-1.5, Gemma-2B, Alpaca-3B | Decent conversation, basic coding | Personal assistants, educational tools |
|
531 |
+
| **8GB** | Phi-2, LLaMA-2-7B (4-bit), Mistral-7B (4-bit) | Good general purpose, coding help | Development tools, content creation |
|
532 |
+
| **16GB** | LLaMA-2-7B, Mistral-7B, CodeLLaMA-7B | High quality responses, complex tasks | Professional applications, research |
|
533 |
+
| **24GB** | LLaMA-2-13B, Mixtral-8x7B (4-bit) | Excellent performance, long context | Enterprise solutions, advanced research |
|
534 |
+
| **32GB+** | LLaMA-2-70B (8-bit), Mixtral-8x7B | Top-tier performance, specialized tasks | Research institutions, large-scale applications |
|
535 |
+
|
536 |
+
## ๐ ๏ธ Optimization Techniques
|
537 |
+
|
538 |
+
### **Quantization Methods**
|
539 |
+
- **4-bit**: GPTQ, AWQ - 75% memory reduction
|
540 |
+
- **8-bit**: bitsandbytes - 50% memory reduction
|
541 |
+
- **16-bit**: Half precision - 50% memory reduction
|
542 |
+
|
543 |
+
### **Efficient Formats**
|
544 |
+
- **GGUF**: Optimized for CPU inference
|
545 |
+
- **ONNX**: Cross-platform optimization
|
546 |
+
- **TensorRT**: NVIDIA GPU optimization
|
547 |
+
|
548 |
+
### **Memory-Saving Tips**
|
549 |
+
- Use CPU offloading for large models
|
550 |
+
- Reduce context window length
|
551 |
+
- Enable gradient checkpointing
|
552 |
+
- Use model sharding for very large models
|
553 |
+
|
554 |
+
### ๐ **Popular Platforms & Tools**
|
555 |
+
- **Hugging Face**: Largest model repository
|
556 |
+
- **Ollama**: Easy local model deployment
|
557 |
+
- **LM Studio**: GUI for running models
|
558 |
+
- **llama.cpp**: Efficient CPU inference
|
559 |
+
- **vLLM**: High-throughput inference
|
560 |
+
- **Text Generation WebUI**: Web interface for models
|
561 |
+
""")
|
562 |
+
|
563 |
+
# Footer with additional resources
|
564 |
+
st.markdown("---")
|
565 |
+
st.markdown("""
|
566 |
+
### ๐ Essential Resources & Tools
|
567 |
+
|
568 |
+
**๐ฆ Model Repositories:**
|
569 |
+
- [Hugging Face Hub](https://huggingface.co/models) โ 500,000+ models, including BERT, LLaMA, Mistral, and more.
|
570 |
+
- [Ollama Library](https://ollama.ai/library) โ Seamless CLI-based local model deployment (LLaMA, Mistral, Gemma).
|
571 |
+
- [Together AI](https://www.together.ai/models) โ Access to powerful open models via API or hosted inference.
|
572 |
+
|
573 |
+
**๐ ๏ธ Inference Tools:**
|
574 |
+
- [**llama.cpp**](https://github.com/ggerganov/llama.cpp) โ CPU/GPU inference for LLaMA models with quantization.
|
575 |
+
- [**GGUF format**](https://huggingface.co/docs/transformers/main/en/gguf) โ Next-gen model format optimized for local inference.
|
576 |
+
- [**vLLM**](https://github.com/vllm-project/vllm) โ High-throughput inference engine for transformer models.
|
577 |
+
- [**AutoGPTQ**](https://github.com/PanQiWei/AutoGPTQ) โ GPU-optimized quantized inference for large models.
|
578 |
+
|
579 |
+
**๐ Learning & Deployment:**
|
580 |
+
- [Awesome LLMs](https://github.com/Hannibal046/Awesome-LLMs) โ Curated list of LLM projects, tools, and papers.
|
581 |
+
- [LangChain](https://www.langchain.com/) โ Framework for building apps with LLMs and tools.
|
582 |
+
- [LlamaIndex](https://www.llamaindex.ai/) โ Connect LLMs with external data and documents (RAG).
|
583 |
|
584 |
+
---
|
585 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|