Spaces:
Running
Running
fix ZeroGPU: literal @spaces.GPU decorator (startup detection)
Browse files
app.py
CHANGED
|
@@ -15,16 +15,7 @@ from fastapi.staticfiles import StaticFiles
|
|
| 15 |
from transformers import AutoModel, AutoTokenizer
|
| 16 |
from huggingface_hub import snapshot_download
|
| 17 |
|
| 18 |
-
|
| 19 |
-
import spaces
|
| 20 |
-
GPU = spaces.GPU
|
| 21 |
-
except Exception:
|
| 22 |
-
def GPU(*a, **k):
|
| 23 |
-
if a and callable(a[0]):
|
| 24 |
-
return a[0]
|
| 25 |
-
def deco(f):
|
| 26 |
-
return f
|
| 27 |
-
return deco
|
| 28 |
|
| 29 |
KEY = os.environ.get("ANTHROPIC_API_KEY", "")
|
| 30 |
LLM_MODEL = os.environ.get("KNOU_MODEL", "claude-haiku-4-5-20251001")
|
|
@@ -51,7 +42,7 @@ def _zmodel():
|
|
| 51 |
attn_implementation="sdpa").eval().to("cuda")
|
| 52 |
return _ZMODEL
|
| 53 |
|
| 54 |
-
@GPU(duration=120)
|
| 55 |
def ztc_score(question, answer):
|
| 56 |
text = _ZCFG["template"] % ((question or "").strip(), (answer or "").strip())
|
| 57 |
b = _ZTOK([text], return_tensors="pt", truncation=True, max_length=_ZCFG["max_length"])
|
|
|
|
| 15 |
from transformers import AutoModel, AutoTokenizer
|
| 16 |
from huggingface_hub import snapshot_download
|
| 17 |
|
| 18 |
+
import spaces # ZeroGPU: must decorate with literal @spaces.GPU so startup scanner detects it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
KEY = os.environ.get("ANTHROPIC_API_KEY", "")
|
| 21 |
LLM_MODEL = os.environ.get("KNOU_MODEL", "claude-haiku-4-5-20251001")
|
|
|
|
| 42 |
attn_implementation="sdpa").eval().to("cuda")
|
| 43 |
return _ZMODEL
|
| 44 |
|
| 45 |
+
@spaces.GPU(duration=120)
|
| 46 |
def ztc_score(question, answer):
|
| 47 |
text = _ZCFG["template"] % ((question or "").strip(), (answer or "").strip())
|
| 48 |
b = _ZTOK([text], return_tensors="pt", truncation=True, max_length=_ZCFG["max_length"])
|