Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,17 +8,7 @@ from threading import Thread
|
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
-
|
| 12 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 13 |
-
"macadeliccc/SOLAR-math-2x10.7b",
|
| 14 |
-
trust_remote_code=True
|
| 15 |
-
)
|
| 16 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 17 |
-
"macadeliccc/SOLAR-math-2x10.7b",
|
| 18 |
-
torch_dtype="auto",
|
| 19 |
-
load_in_8bit=True,
|
| 20 |
-
trust_remote_code=True
|
| 21 |
-
)
|
| 22 |
|
| 23 |
# Defining a custom stopping criteria class for the model's text generation.
|
| 24 |
class StopOnTokens(StoppingCriteria):
|
|
@@ -34,7 +24,18 @@ class StopOnTokens(StoppingCriteria):
|
|
| 34 |
@spaces.GPU
|
| 35 |
def predict(message, history):
|
| 36 |
torch.set_default_device("cuda")
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
history_transformer_format = history + [[message, ""]]
|
| 39 |
stop = StopOnTokens()
|
| 40 |
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Defining a custom stopping criteria class for the model's text generation.
|
| 14 |
class StopOnTokens(StoppingCriteria):
|
|
|
|
| 24 |
@spaces.GPU
|
| 25 |
def predict(message, history):
|
| 26 |
torch.set_default_device("cuda")
|
| 27 |
+
|
| 28 |
+
# Loading the tokenizer and model from Hugging Face's model hub.
|
| 29 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 30 |
+
"macadeliccc/SOLAR-math-2x10.7b",
|
| 31 |
+
trust_remote_code=True
|
| 32 |
+
)
|
| 33 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 34 |
+
"macadeliccc/SOLAR-math-2x10.7b",
|
| 35 |
+
torch_dtype="auto",
|
| 36 |
+
load_in_8bit=True,
|
| 37 |
+
trust_remote_code=True
|
| 38 |
+
)
|
| 39 |
history_transformer_format = history + [[message, ""]]
|
| 40 |
stop = StopOnTokens()
|
| 41 |
|