Spaces:
Runtime error
Runtime error
Commit ·
702a77b
1
Parent(s): 84a9640
push model cash path
Browse files
app.py
CHANGED
|
@@ -29,7 +29,7 @@ model_cache_path = snapshot_download(
|
|
| 29 |
local_dir="/app/model_cache" # <-- direct destination
|
| 30 |
)
|
| 31 |
|
| 32 |
-
print(">>> MODEL CACHE PATH:",
|
| 33 |
|
| 34 |
device = "gpu" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
| 35 |
dtype = torch.float16 if device in ("mps", "gpu") else torch.float32
|
|
@@ -50,18 +50,18 @@ def load_model():
|
|
| 50 |
# model_name, torch_dtype=dtype, trust_remote_code=True
|
| 51 |
# )
|
| 52 |
model = AutoModelForCausalLM.from_pretrained(
|
| 53 |
-
|
| 54 |
local_files_only=True,
|
| 55 |
torch_dtype=dtype,
|
| 56 |
trust_remote_code=True
|
| 57 |
).to(device).eval()
|
| 58 |
# tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 59 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 60 |
-
|
| 61 |
local_files_only=True,
|
| 62 |
trust_remote_code=True
|
| 63 |
)
|
| 64 |
-
print("✅ Model and tokenizer loaded from",
|
| 65 |
|
| 66 |
def predict_NuExtract(texts, template, batch_size=10, max_length=5096, max_new_tokens=1024):
|
| 67 |
print("Starting NuExtract prediction...", flush=True)
|
|
|
|
| 29 |
local_dir="/app/model_cache" # <-- direct destination
|
| 30 |
)
|
| 31 |
|
| 32 |
+
print(">>> MODEL CACHE PATH:", model_cache_path, os.listdir(model_cache_path))
|
| 33 |
|
| 34 |
device = "gpu" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
| 35 |
dtype = torch.float16 if device in ("mps", "gpu") else torch.float32
|
|
|
|
| 50 |
# model_name, torch_dtype=dtype, trust_remote_code=True
|
| 51 |
# )
|
| 52 |
model = AutoModelForCausalLM.from_pretrained(
|
| 53 |
+
model_cache_path,
|
| 54 |
local_files_only=True,
|
| 55 |
torch_dtype=dtype,
|
| 56 |
trust_remote_code=True
|
| 57 |
).to(device).eval()
|
| 58 |
# tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 59 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 60 |
+
model_cache_path,
|
| 61 |
local_files_only=True,
|
| 62 |
trust_remote_code=True
|
| 63 |
)
|
| 64 |
+
print("✅ Model and tokenizer loaded from", model_cache_path)
|
| 65 |
|
| 66 |
def predict_NuExtract(texts, template, batch_size=10, max_length=5096, max_new_tokens=1024):
|
| 67 |
print("Starting NuExtract prediction...", flush=True)
|