Spaces:
Running
Running
Commit ·
540645f
1
Parent(s): 026fe1f
fix(app): use Llama.from_pretrained to auto-download GGUF from hub
Browse files
app.py
CHANGED
|
@@ -38,15 +38,15 @@ try:
|
|
| 38 |
LOCAL_7B_P95 = 37.47
|
| 39 |
|
| 40 |
if LOCAL_7B_P95 <= 14.0:
|
| 41 |
-
|
| 42 |
LOCAL_MAX_TOKENS = 150
|
| 43 |
logger.info(f"Using 7b for local tier since p95 latency ({LOCAL_7B_P95}s) is within 14s budget.")
|
| 44 |
else:
|
| 45 |
-
|
| 46 |
LOCAL_MAX_TOKENS = 250
|
| 47 |
logger.info(f"7b p95 {LOCAL_7B_P95}s exceeds 14s budget, using 3b instead.")
|
| 48 |
|
| 49 |
-
local_model = Llama(
|
| 50 |
except Exception as e:
|
| 51 |
logger.warning(f"Failed to load local model: {e}")
|
| 52 |
local_model = None
|
|
@@ -330,3 +330,4 @@ async def reply(req: Dict[str, Any]):
|
|
| 330 |
if __name__ == "__main__":
|
| 331 |
import uvicorn
|
| 332 |
uvicorn.run(app, host="0.0.0.0", port=8080)
|
|
|
|
|
|
| 38 |
LOCAL_7B_P95 = 37.47
|
| 39 |
|
| 40 |
if LOCAL_7B_P95 <= 14.0:
|
| 41 |
+
local_repo = "bartowski/Qwen2.5-7B-Instruct-GGUF"`r`n local_file = "Qwen2.5-7B-Instruct-Q4_K_M.gguf"
|
| 42 |
LOCAL_MAX_TOKENS = 150
|
| 43 |
logger.info(f"Using 7b for local tier since p95 latency ({LOCAL_7B_P95}s) is within 14s budget.")
|
| 44 |
else:
|
| 45 |
+
local_repo = "Qwen/Qwen2.5-3B-Instruct-GGUF"`r`n local_file = "qwen2.5-3b-instruct-q4_k_m.gguf"
|
| 46 |
LOCAL_MAX_TOKENS = 250
|
| 47 |
logger.info(f"7b p95 {LOCAL_7B_P95}s exceeds 14s budget, using 3b instead.")
|
| 48 |
|
| 49 |
+
local_model = Llama.from_pretrained(repo_id=local_repo, filename=local_file, n_ctx=2048, n_threads=os.cpu_count(), verbose=False)
|
| 50 |
except Exception as e:
|
| 51 |
logger.warning(f"Failed to load local model: {e}")
|
| 52 |
local_model = None
|
|
|
|
| 330 |
if __name__ == "__main__":
|
| 331 |
import uvicorn
|
| 332 |
uvicorn.run(app, host="0.0.0.0", port=8080)
|
| 333 |
+
|