Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,15 @@ import os
|
|
6 |
from time import time
|
7 |
import pandas as pd
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
|
|
10 |
# ==============================
|
11 |
# Helper: Human-readable bytes
|
12 |
def sizeof_fmt(num, suffix="B"):
|
@@ -87,13 +95,14 @@ def load_model_and_tokenizer(doc_text_count):
|
|
87 |
model_name,
|
88 |
device_map="auto", # Automatically allocate model to devices
|
89 |
quantization_config=quantization_config,
|
90 |
-
model_max_length=1.3*round(doc_text_count * 0.3 + 1)
|
|
|
91 |
)
|
92 |
|
93 |
# Load the tokenizer
|
94 |
tokenizer = AutoTokenizer.from_pretrained(
|
95 |
model_name
|
96 |
-
|
97 |
)
|
98 |
return tokenizer, model
|
99 |
|
|
|
6 |
from time import time
|
7 |
import pandas as pd
|
8 |
|
9 |
+
import os
|
10 |
+
from huggingface_hub import login
|
11 |
+
|
12 |
+
HF_TOKEN = os.getenv("nex_model") # Updated key name for clarity
|
13 |
+
|
14 |
+
if not HF_TOKEN:
|
15 |
+
raise ValueError("Hugging Face token not found. Please set the 'NEX_MODEL' environment variable.")
|
16 |
|
17 |
+
login(token=HF_TOKEN)
|
18 |
# ==============================
|
19 |
# Helper: Human-readable bytes
|
20 |
def sizeof_fmt(num, suffix="B"):
|
|
|
95 |
model_name,
|
96 |
device_map="auto", # Automatically allocate model to devices
|
97 |
quantization_config=quantization_config,
|
98 |
+
model_max_length=1.3*round(doc_text_count * 0.3 + 1),
|
99 |
+
token=HF_TOKEN
|
100 |
)
|
101 |
|
102 |
# Load the tokenizer
|
103 |
tokenizer = AutoTokenizer.from_pretrained(
|
104 |
model_name
|
105 |
+
,token=HF_TOKEN
|
106 |
)
|
107 |
return tokenizer, model
|
108 |
|