Spaces:
Sleeping
Sleeping
Commit
·
4c3d05b
1
Parent(s):
4706b45
Update app.py and requirements.txt for CourseGPT-Pro router models
Browse files- app.py +40 -293
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -26,291 +26,15 @@ access_token=os.environ['HF_TOKEN']
|
|
| 26 |
# Torch-Compatible Model Definitions with Adjusted Descriptions
|
| 27 |
# ------------------------------
|
| 28 |
MODELS = {
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
# },
|
| 34 |
-
# "Qwen/Qwen3-Next-80B-A3B-Thinking-FP8": {
|
| 35 |
-
# "repo_id": "Qwen/Qwen3-Next-80B-A3B-Thinking-FP8",
|
| 36 |
-
# "description": "Sparse Mixture-of-Experts (MoE) causal language model with 80B total parameters and approximately 3B activated per inference step. Features include native 32,768-token context (extendable to 131,072 via YaRN), 16 query heads and 2 KV heads, head dimension of 256, and FP8 quantization. Specialized for complex reasoning, math, and coding tasks, this model outputs structured 'thinking' traces by default and is designed to be used with a reasoning parser [[10]][[11]][[14]][[18]].",
|
| 37 |
-
# "params_b": 80.0
|
| 38 |
-
# },
|
| 39 |
-
"Qwen3-32B-FP8": {
|
| 40 |
-
"repo_id": "Qwen/Qwen3-32B-FP8",
|
| 41 |
-
"description": "Dense causal language model with 32.8B total parameters (31.2B non-embedding), 64 layers, 64 query heads & 8 KV heads, native 32,768-token context (extendable to 131,072 via YaRN). Features seamless switching between thinking mode (for complex reasoning, math, coding) and non-thinking mode (for efficient dialogue), strong multilingual support (100+ languages), and leading open-source agent capabilities.",
|
| 42 |
-
"params_b": 32.8
|
| 43 |
},
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
# "params_b": 30.5
|
| 49 |
-
# },
|
| 50 |
-
# "Qwen3-30B-A3B-Thinking-2507": {
|
| 51 |
-
# "repo_id": "Qwen/Qwen3-30B-A3B-Thinking-2507",
|
| 52 |
-
# "description": "thinking-mode MoE model based on Qwen3-30B-A3B-Thinking-2507. Contains 30.5B total parameters (3.3B activated), 128 experts (8 activated), 48 layers, and 262,144-token native context. Optimized for deep reasoning in mathematics, science, coding, and agent tasks. Outputs include automatic reasoning delimiters (<think>...</think>). Quantized with AWQ (W4A16), preserving lm_head and expert gating layers.",
|
| 53 |
-
# "params_b": 30.5
|
| 54 |
-
# },
|
| 55 |
-
"gpt-oss-20b-BF16": {
|
| 56 |
-
"repo_id": "unsloth/gpt-oss-20b-BF16",
|
| 57 |
-
"description": "A 20B-parameter open-source GPT-style language model quantized to INT4 using AutoRound, with FP8 key-value cache for efficient inference. Optimized for performance and memory efficiency on Intel hardware while maintaining strong language generation capabilities.",
|
| 58 |
-
"params_b": 20.0
|
| 59 |
-
},
|
| 60 |
-
"Qwen3-4B-Instruct-2507": {
|
| 61 |
-
"repo_id": "Qwen/Qwen3-4B-Instruct-2507",
|
| 62 |
-
"description": "Updated non-thinking instruct variant of Qwen3-4B with 4.0B parameters, featuring significant improvements in instruction following, logical reasoning, multilingualism, and 256K long-context understanding. Strong performance across knowledge, coding, alignment, and agent benchmarks.",
|
| 63 |
-
"params_b": 4.0
|
| 64 |
-
},
|
| 65 |
-
"Apriel-1.5-15b-Thinker": {
|
| 66 |
-
"repo_id": "ServiceNow-AI/Apriel-1.5-15b-Thinker",
|
| 67 |
-
"description": "Multimodal reasoning model with 15B parameters, trained via extensive mid-training on text and image data, and fine-tuned only on text (no image SFT). Achieves competitive performance on reasoning benchmarks like Artificial Analysis (score: 52), Tau2 Bench Telecom (68), and IFBench (62). Supports both text and image understanding, fits on a single GPU, and includes structured reasoning output with tool and function calling capabilities.",
|
| 68 |
-
"params_b": 15.0
|
| 69 |
-
},
|
| 70 |
-
|
| 71 |
-
# 14.8B total parameters
|
| 72 |
-
"Qwen3-14B": {
|
| 73 |
-
"repo_id": "Qwen/Qwen3-14B",
|
| 74 |
-
"description": "Dense causal language model with 14.8 B total parameters (13.2 B non-embedding), 40 layers, 40 query heads & 8 KV heads, 32 768-token context (131 072 via YaRN), enhanced human preference alignment & advanced agent integration.",
|
| 75 |
-
"params_b": 14.8
|
| 76 |
-
},
|
| 77 |
-
"Qwen/Qwen3-14B-FP8": {
|
| 78 |
-
"repo_id": "Qwen/Qwen3-14B-FP8",
|
| 79 |
-
"description": "FP8-quantized version of Qwen3-14B for efficient inference.",
|
| 80 |
-
"params_b": 14.8
|
| 81 |
-
},
|
| 82 |
-
|
| 83 |
-
# ~15B (commented out in original, but larger than 14B)
|
| 84 |
-
# "Apriel-1.5-15b-Thinker": { ... },
|
| 85 |
-
|
| 86 |
-
# 5B
|
| 87 |
-
# "Apriel-5B-Instruct": {
|
| 88 |
-
# "repo_id": "ServiceNow-AI/Apriel-5B-Instruct",
|
| 89 |
-
# "description": "A 5B-parameter instruction-tuned model from ServiceNow’s Apriel series, optimized for enterprise tasks and general-purpose instruction following."
|
| 90 |
-
# },
|
| 91 |
-
|
| 92 |
-
# 4.3B
|
| 93 |
-
"Phi-4-mini-Reasoning": {
|
| 94 |
-
"repo_id": "microsoft/Phi-4-mini-reasoning",
|
| 95 |
-
"description": "Phi-4-mini-Reasoning (4.3B parameters)",
|
| 96 |
-
"params_b": 4.3
|
| 97 |
-
},
|
| 98 |
-
"Phi-4-mini-Instruct": {
|
| 99 |
-
"repo_id": "microsoft/Phi-4-mini-instruct",
|
| 100 |
-
"description": "Phi-4-mini-Instruct (4.3B parameters)",
|
| 101 |
-
"params_b": 4.3
|
| 102 |
-
},
|
| 103 |
-
|
| 104 |
-
# 4.0B
|
| 105 |
-
"Qwen3-4B": {
|
| 106 |
-
"repo_id": "Qwen/Qwen3-4B",
|
| 107 |
-
"description": "Dense causal language model with 4.0 B total parameters (3.6 B non-embedding), 36 layers, 32 query heads & 8 KV heads, native 32 768-token context (extendable to 131 072 via YaRN), balanced mid-range capacity & long-context reasoning.",
|
| 108 |
-
"params_b": 4.0
|
| 109 |
-
},
|
| 110 |
-
|
| 111 |
-
"Gemma-3-4B-IT": {
|
| 112 |
-
"repo_id": "unsloth/gemma-3-4b-it",
|
| 113 |
-
"description": "Gemma-3-4B-IT",
|
| 114 |
-
"params_b": 4.0
|
| 115 |
-
},
|
| 116 |
-
"MiniCPM3-4B": {
|
| 117 |
-
"repo_id": "openbmb/MiniCPM3-4B",
|
| 118 |
-
"description": "MiniCPM3-4B",
|
| 119 |
-
"params_b": 4.0
|
| 120 |
-
},
|
| 121 |
-
"Gemma-3n-E4B": {
|
| 122 |
-
"repo_id": "google/gemma-3n-E4B",
|
| 123 |
-
"description": "Gemma 3n base model with effective 4 B parameters (≈3 GB VRAM)",
|
| 124 |
-
"params_b": 4.0
|
| 125 |
-
},
|
| 126 |
-
"SmallThinker-4BA0.6B-Instruct": {
|
| 127 |
-
"repo_id": "PowerInfer/SmallThinker-4BA0.6B-Instruct",
|
| 128 |
-
"description": "SmallThinker 4 B backbone with 0.6 B activated parameters, instruction‑tuned",
|
| 129 |
-
"params_b": 4.0
|
| 130 |
-
},
|
| 131 |
-
|
| 132 |
-
# ~3B
|
| 133 |
-
# "AI21-Jamba-Reasoning-3B": {
|
| 134 |
-
# "repo_id": "ai21labs/AI21-Jamba-Reasoning-3B",
|
| 135 |
-
# "description": "A compact 3B hybrid Transformer–Mamba reasoning model with 256K context length, strong intelligence benchmark scores (61% MMLU-Pro, 52% IFBench), and efficient inference suitable for edge and datacenter use. Outperforms Gemma-3 4B and Llama-3.2 3B despite smaller size."
|
| 136 |
-
# },
|
| 137 |
-
"Qwen2.5-Taiwan-3B-Reason-GRPO": {
|
| 138 |
-
"repo_id": "benchang1110/Qwen2.5-Taiwan-3B-Reason-GRPO",
|
| 139 |
-
"description": "Qwen2.5-Taiwan model with 3 B parameters, Reason-GRPO fine-tuned",
|
| 140 |
-
"params_b": 3.0
|
| 141 |
-
},
|
| 142 |
-
"Llama-3.2-Taiwan-3B-Instruct": {
|
| 143 |
-
"repo_id": "lianghsun/Llama-3.2-Taiwan-3B-Instruct",
|
| 144 |
-
"description": "Llama-3.2-Taiwan-3B-Instruct",
|
| 145 |
-
"params_b": 3.0
|
| 146 |
-
},
|
| 147 |
-
"Qwen2.5-3B-Instruct": {
|
| 148 |
-
"repo_id": "Qwen/Qwen2.5-3B-Instruct",
|
| 149 |
-
"description": "Qwen2.5-3B-Instruct",
|
| 150 |
-
"params_b": 3.0
|
| 151 |
-
},
|
| 152 |
-
"Qwen2.5-Omni-3B": {
|
| 153 |
-
"repo_id": "Qwen/Qwen2.5-Omni-3B",
|
| 154 |
-
"description": "Qwen2.5-Omni-3B",
|
| 155 |
-
"params_b": 3.0
|
| 156 |
-
},
|
| 157 |
-
"Granite-4.0-Micro": {
|
| 158 |
-
"repo_id": "ibm-granite/granite-4.0-micro",
|
| 159 |
-
"description": "A 3B-parameter long-context instruct model from IBM, finetuned for enhanced instruction following and tool-calling. Supports 12 languages including English, Chinese, Arabic, and Japanese. Built on a dense Transformer with GQA, RoPE, SwiGLU, and 128K context length. Trained using SFT, RL alignment, and model merging techniques for enterprise applications.",
|
| 160 |
-
"params_b": 3.0
|
| 161 |
-
},
|
| 162 |
-
|
| 163 |
-
# 2.6B
|
| 164 |
-
"LFM2-2.6B": {
|
| 165 |
-
"repo_id": "LiquidAI/LFM2-2.6B",
|
| 166 |
-
"description": "The 2.6B parameter model in the LFM2 series, it outperforms models in the 3B+ class and features a hybrid architecture for faster inference.",
|
| 167 |
-
"params_b": 2.6
|
| 168 |
-
},
|
| 169 |
-
|
| 170 |
-
# 1.7B
|
| 171 |
-
"Qwen3-1.7B": {
|
| 172 |
-
"repo_id": "Qwen/Qwen3-1.7B",
|
| 173 |
-
"description": "Dense causal language model with 1.7 B total parameters (1.4 B non-embedding), 28 layers, 16 query heads & 8 KV heads, 32 768-token context, stronger reasoning vs. 0.6 B variant, dual-mode inference, instruction following across 100+ languages.",
|
| 174 |
-
"params_b": 1.7
|
| 175 |
-
},
|
| 176 |
-
|
| 177 |
-
# ~2B (effective)
|
| 178 |
-
"Gemma-3n-E2B": {
|
| 179 |
-
"repo_id": "google/gemma-3n-E2B",
|
| 180 |
-
"description": "Gemma 3n base model with effective 2 B parameters (≈2 GB VRAM)",
|
| 181 |
-
"params_b": 2.0
|
| 182 |
-
},
|
| 183 |
-
|
| 184 |
-
# 1.5B
|
| 185 |
-
"Nemotron-Research-Reasoning-Qwen-1.5B": {
|
| 186 |
-
"repo_id": "nvidia/Nemotron-Research-Reasoning-Qwen-1.5B",
|
| 187 |
-
"description": "Nemotron-Research-Reasoning-Qwen-1.5B",
|
| 188 |
-
"params_b": 1.5
|
| 189 |
-
},
|
| 190 |
-
"Falcon-H1-1.5B-Instruct": {
|
| 191 |
-
"repo_id": "tiiuae/Falcon-H1-1.5B-Instruct",
|
| 192 |
-
"description": "Falcon‑H1 model with 1.5 B parameters, instruction‑tuned",
|
| 193 |
-
"params_b": 1.5
|
| 194 |
-
},
|
| 195 |
-
"Qwen2.5-Taiwan-1.5B-Instruct": {
|
| 196 |
-
"repo_id": "benchang1110/Qwen2.5-Taiwan-1.5B-Instruct",
|
| 197 |
-
"description": "Qwen2.5-Taiwan-1.5B-Instruct",
|
| 198 |
-
"params_b": 1.5
|
| 199 |
-
},
|
| 200 |
-
|
| 201 |
-
# 1.2B
|
| 202 |
-
"LFM2-1.2B": {
|
| 203 |
-
"repo_id": "LiquidAI/LFM2-1.2B",
|
| 204 |
-
"description": "A 1.2B parameter hybrid language model from Liquid AI, designed for efficient on-device and edge AI deployment, outperforming larger models like Llama-2-7b-hf in specific tasks.",
|
| 205 |
-
"params_b": 1.2
|
| 206 |
-
},
|
| 207 |
-
|
| 208 |
-
# 1.1B
|
| 209 |
-
"Taiwan-ELM-1_1B-Instruct": {
|
| 210 |
-
"repo_id": "liswei/Taiwan-ELM-1_1B-Instruct",
|
| 211 |
-
"description": "Taiwan-ELM-1_1B-Instruct",
|
| 212 |
-
"params_b": 1.1
|
| 213 |
-
},
|
| 214 |
-
|
| 215 |
-
# 1B
|
| 216 |
-
"Llama-3.2-Taiwan-1B": {
|
| 217 |
-
"repo_id": "lianghsun/Llama-3.2-Taiwan-1B",
|
| 218 |
-
"description": "Llama-3.2-Taiwan base model with 1 B parameters",
|
| 219 |
-
"params_b": 1.0
|
| 220 |
-
},
|
| 221 |
-
|
| 222 |
-
# 700M
|
| 223 |
-
"LFM2-700M": {
|
| 224 |
-
"repo_id": "LiquidAI/LFM2-700M",
|
| 225 |
-
"description": "A 700M parameter model from the LFM2 family, designed for high efficiency on edge devices with a hybrid architecture of multiplicative gates and short convolutions.",
|
| 226 |
-
"params_b": 0.7
|
| 227 |
-
},
|
| 228 |
-
|
| 229 |
-
# 600M
|
| 230 |
-
"Qwen3-0.6B": {
|
| 231 |
-
"repo_id": "Qwen/Qwen3-0.6B",
|
| 232 |
-
"description": "Dense causal language model with 0.6 B total parameters (0.44 B non-embedding), 28 transformer layers, 16 query heads & 8 KV heads, native 32 768-token context window, dual-mode generation, full multilingual & agentic capabilities.",
|
| 233 |
-
"params_b": 0.6
|
| 234 |
-
},
|
| 235 |
-
"Qwen3-0.6B-Taiwan": {
|
| 236 |
-
"repo_id": "ShengweiPeng/Qwen3-0.6B-Taiwan",
|
| 237 |
-
"description": "Qwen3-Taiwan model with 0.6 B parameters",
|
| 238 |
-
"params_b": 0.6
|
| 239 |
-
},
|
| 240 |
-
|
| 241 |
-
# 500M
|
| 242 |
-
"Qwen2.5-0.5B-Taiwan-Instruct": {
|
| 243 |
-
"repo_id": "ShengweiPeng/Qwen2.5-0.5B-Taiwan-Instruct",
|
| 244 |
-
"description": "Qwen2.5-Taiwan model with 0.5 B parameters, instruction-tuned",
|
| 245 |
-
"params_b": 0.5
|
| 246 |
-
},
|
| 247 |
-
|
| 248 |
-
# 360M
|
| 249 |
-
"SmolLM2-360M-Instruct": {
|
| 250 |
-
"repo_id": "HuggingFaceTB/SmolLM2-360M-Instruct",
|
| 251 |
-
"description": "Original SmolLM2‑360M Instruct",
|
| 252 |
-
"params_b": 0.36
|
| 253 |
-
},
|
| 254 |
-
"SmolLM2-360M-Instruct-TaiwanChat": {
|
| 255 |
-
"repo_id": "Luigi/SmolLM2-360M-Instruct-TaiwanChat",
|
| 256 |
-
"description": "SmolLM2‑360M Instruct fine-tuned on TaiwanChat",
|
| 257 |
-
"params_b": 0.36
|
| 258 |
-
},
|
| 259 |
-
|
| 260 |
-
# 350M
|
| 261 |
-
"LFM2-350M": {
|
| 262 |
-
"repo_id": "LiquidAI/LFM2-350M",
|
| 263 |
-
"description": "A compact 350M parameter hybrid model optimized for edge and on-device applications, offering significantly faster training and inference speeds compared to models like Qwen3.",
|
| 264 |
-
"params_b": 0.35
|
| 265 |
-
},
|
| 266 |
-
|
| 267 |
-
# 270M
|
| 268 |
-
"parser_model_ner_gemma_v0.1": {
|
| 269 |
-
"repo_id": "myfi/parser_model_ner_gemma_v0.1",
|
| 270 |
-
"description": "A lightweight named‑entity‑like (NER) parser fine‑tuned from Google’s **Gemma‑3‑270M** model. The base Gemma‑3‑270M is a 270 M‑parameter, hyper‑efficient LLM designed for on‑device inference, supporting >140 languages, a 128 k‑token context window, and instruction‑following capabilities [2][7]. This variant is further trained on standard NER corpora (e.g., CoNLL‑2003, OntoNotes) to extract PERSON, ORG, LOC, and MISC entities with high precision while keeping the memory footprint low (≈240 MB VRAM in BF16 quantized form) [1]. It is released under the Apache‑2.0 license and can be used for fast, cost‑effective entity extraction in low‑resource environments.",
|
| 271 |
-
"params_b": 0.27
|
| 272 |
-
},
|
| 273 |
-
"Gemma-3-Taiwan-270M-it": {
|
| 274 |
-
"repo_id": "lianghsun/Gemma-3-Taiwan-270M-it",
|
| 275 |
-
"description": "google/gemma-3-270m-it fintuned on Taiwan Chinese dataset",
|
| 276 |
-
"params_b": 0.27
|
| 277 |
-
},
|
| 278 |
-
"gemma-3-270m-it": {
|
| 279 |
-
"repo_id": "google/gemma-3-270m-it",
|
| 280 |
-
"description": "Gemma‑3‑270M‑IT is a compact, 270‑million‑parameter language model fine‑tuned for Italian, offering fast and efficient on‑device text generation and comprehension in the Italian language.",
|
| 281 |
-
"params_b": 0.27
|
| 282 |
-
},
|
| 283 |
-
"Taiwan-ELM-270M-Instruct": {
|
| 284 |
-
"repo_id": "liswei/Taiwan-ELM-270M-Instruct",
|
| 285 |
-
"description": "Taiwan-ELM-270M-Instruct",
|
| 286 |
-
"params_b": 0.27
|
| 287 |
-
},
|
| 288 |
-
|
| 289 |
-
# 135M
|
| 290 |
-
"SmolLM2-135M-multilingual-base": {
|
| 291 |
-
"repo_id": "agentlans/SmolLM2-135M-multilingual-base",
|
| 292 |
-
"description": "SmolLM2-135M-multilingual-base",
|
| 293 |
-
"params_b": 0.135
|
| 294 |
-
},
|
| 295 |
-
"SmolLM-135M-Taiwan-Instruct-v1.0": {
|
| 296 |
-
"repo_id": "benchang1110/SmolLM-135M-Taiwan-Instruct-v1.0",
|
| 297 |
-
"description": "135-million-parameter F32 safetensors instruction-finetuned variant of SmolLM-135M-Taiwan, trained on the 416 k-example ChatTaiwan dataset for Traditional Chinese conversational and instruction-following tasks",
|
| 298 |
-
"params_b": 0.135
|
| 299 |
-
},
|
| 300 |
-
"SmolLM2_135M_Grpo_Gsm8k": {
|
| 301 |
-
"repo_id": "prithivMLmods/SmolLM2_135M_Grpo_Gsm8k",
|
| 302 |
-
"description": "SmolLM2_135M_Grpo_Gsm8k",
|
| 303 |
-
"params_b": 0.135
|
| 304 |
-
},
|
| 305 |
-
"SmolLM2-135M-Instruct": {
|
| 306 |
-
"repo_id": "HuggingFaceTB/SmolLM2-135M-Instruct",
|
| 307 |
-
"description": "Original SmolLM2‑135M Instruct",
|
| 308 |
-
"params_b": 0.135
|
| 309 |
-
},
|
| 310 |
-
"SmolLM2-135M-Instruct-TaiwanChat": {
|
| 311 |
-
"repo_id": "Luigi/SmolLM2-135M-Instruct-TaiwanChat",
|
| 312 |
-
"description": "SmolLM2‑135M Instruct fine-tuned on TaiwanChat",
|
| 313 |
-
"params_b": 0.135
|
| 314 |
},
|
| 315 |
}
|
| 316 |
|
|
@@ -320,14 +44,34 @@ PIPELINES = {}
|
|
| 320 |
def load_pipeline(model_name):
|
| 321 |
"""
|
| 322 |
Load and cache a transformers pipeline for text generation.
|
| 323 |
-
|
|
|
|
| 324 |
"""
|
| 325 |
global PIPELINES
|
| 326 |
if model_name in PIPELINES:
|
| 327 |
return PIPELINES[model_name]
|
|
|
|
| 328 |
repo = MODELS[model_name]["repo_id"]
|
| 329 |
-
tokenizer = AutoTokenizer.from_pretrained(repo,
|
| 330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
for dtype in (torch.bfloat16, torch.float16, torch.float32):
|
| 332 |
try:
|
| 333 |
pipe = pipeline(
|
|
@@ -335,22 +79,25 @@ def load_pipeline(model_name):
|
|
| 335 |
model=repo,
|
| 336 |
tokenizer=tokenizer,
|
| 337 |
trust_remote_code=True,
|
| 338 |
-
dtype=dtype,
|
| 339 |
device_map="auto",
|
| 340 |
-
use_cache=True,
|
| 341 |
-
token=access_token
|
|
|
|
| 342 |
PIPELINES[model_name] = pipe
|
| 343 |
return pipe
|
| 344 |
except Exception:
|
| 345 |
continue
|
| 346 |
-
|
|
|
|
| 347 |
pipe = pipeline(
|
| 348 |
task="text-generation",
|
| 349 |
model=repo,
|
| 350 |
tokenizer=tokenizer,
|
| 351 |
trust_remote_code=True,
|
| 352 |
device_map="auto",
|
| 353 |
-
use_cache=True
|
|
|
|
| 354 |
)
|
| 355 |
PIPELINES[model_name] = pipe
|
| 356 |
return pipe
|
|
@@ -869,4 +616,4 @@ with gr.Blocks(
|
|
| 869 |
# Clear chat action
|
| 870 |
clr.click(fn=lambda: ([], "", ""), outputs=[chat, txt, dbg])
|
| 871 |
|
| 872 |
-
demo.launch()
|
|
|
|
| 26 |
# Torch-Compatible Model Definitions with Adjusted Descriptions
|
| 27 |
# ------------------------------
|
| 28 |
MODELS = {
|
| 29 |
+
"Router-Qwen3-32B-8bit": {
|
| 30 |
+
"repo_id": "Alovestocode/router-qwen3-32b-merged",
|
| 31 |
+
"description": "CourseGPT-Pro router checkpoint built on Qwen3 32B and quantized to 8-bit for ZeroGPU deployment. Optimised for orchestrating math, code, and general-search agents while staying within the ZeroGPU memory envelope.",
|
| 32 |
+
"params_b": 32.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
},
|
| 34 |
+
"Router-Gemma3-27B-8bit": {
|
| 35 |
+
"repo_id": "Alovestocode/router-gemma3-merged",
|
| 36 |
+
"description": "CourseGPT-Pro router checkpoint built on Gemma3 27B and quantized to 8-bit. Provides the same JSON routing schema with a Gemma-flavoured inductive bias for math-heavy prompts.",
|
| 37 |
+
"params_b": 27.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
},
|
| 39 |
}
|
| 40 |
|
|
|
|
| 44 |
def load_pipeline(model_name):
|
| 45 |
"""
|
| 46 |
Load and cache a transformers pipeline for text generation.
|
| 47 |
+
Prefers 8-bit loading (bitsandbytes) to stay within ZeroGPU limits,
|
| 48 |
+
falling back to bf16/fp16/fp32 if quantized loading is unavailable.
|
| 49 |
"""
|
| 50 |
global PIPELINES
|
| 51 |
if model_name in PIPELINES:
|
| 52 |
return PIPELINES[model_name]
|
| 53 |
+
|
| 54 |
repo = MODELS[model_name]["repo_id"]
|
| 55 |
+
tokenizer = AutoTokenizer.from_pretrained(repo, token=access_token)
|
| 56 |
+
|
| 57 |
+
# First try to load in 8-bit to minimise VRAM usage.
|
| 58 |
+
try:
|
| 59 |
+
pipe = pipeline(
|
| 60 |
+
task="text-generation",
|
| 61 |
+
model=repo,
|
| 62 |
+
tokenizer=tokenizer,
|
| 63 |
+
trust_remote_code=True,
|
| 64 |
+
device_map="auto",
|
| 65 |
+
model_kwargs={"load_in_8bit": True},
|
| 66 |
+
use_cache=True,
|
| 67 |
+
token=access_token,
|
| 68 |
+
)
|
| 69 |
+
PIPELINES[model_name] = pipe
|
| 70 |
+
return pipe
|
| 71 |
+
except Exception as exc:
|
| 72 |
+
print(f"8-bit load failed for {repo}: {exc}. Falling back to higher precision.")
|
| 73 |
+
|
| 74 |
+
# Fallback ladder when 8-bit is not available.
|
| 75 |
for dtype in (torch.bfloat16, torch.float16, torch.float32):
|
| 76 |
try:
|
| 77 |
pipe = pipeline(
|
|
|
|
| 79 |
model=repo,
|
| 80 |
tokenizer=tokenizer,
|
| 81 |
trust_remote_code=True,
|
| 82 |
+
dtype=dtype,
|
| 83 |
device_map="auto",
|
| 84 |
+
use_cache=True,
|
| 85 |
+
token=access_token,
|
| 86 |
+
)
|
| 87 |
PIPELINES[model_name] = pipe
|
| 88 |
return pipe
|
| 89 |
except Exception:
|
| 90 |
continue
|
| 91 |
+
|
| 92 |
+
# Final fallback with framework defaults.
|
| 93 |
pipe = pipeline(
|
| 94 |
task="text-generation",
|
| 95 |
model=repo,
|
| 96 |
tokenizer=tokenizer,
|
| 97 |
trust_remote_code=True,
|
| 98 |
device_map="auto",
|
| 99 |
+
use_cache=True,
|
| 100 |
+
token=access_token,
|
| 101 |
)
|
| 102 |
PIPELINES[model_name] = pipe
|
| 103 |
return pipe
|
|
|
|
| 616 |
# Clear chat action
|
| 617 |
clr.click(fn=lambda: ([], "", ""), outputs=[chat, txt, dbg])
|
| 618 |
|
| 619 |
+
demo.launch()
|
requirements.txt
CHANGED
|
@@ -9,4 +9,5 @@ sentencepiece
|
|
| 9 |
accelerate
|
| 10 |
autoawq
|
| 11 |
timm
|
| 12 |
-
compressed-tensors
|
|
|
|
|
|
| 9 |
accelerate
|
| 10 |
autoawq
|
| 11 |
timm
|
| 12 |
+
compressed-tensors
|
| 13 |
+
bitsandbytes
|