Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
4 |
from transformers import StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
5 |
from threading import Thread
|
6 |
|
|
|
|
|
7 |
# Loading the tokenizer and model from Hugging Face's model hub.
|
8 |
tokenizer = AutoTokenizer.from_pretrained(
|
9 |
"mlabonne/phixtral-2x2_8",
|
@@ -16,11 +18,6 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
16 |
trust_remote_code=True
|
17 |
)
|
18 |
|
19 |
-
# using CUDA for an optimal experience
|
20 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
21 |
-
model = model.to(device)
|
22 |
-
|
23 |
-
|
24 |
# Defining a custom stopping criteria class for the model's text generation.
|
25 |
class StopOnTokens(StoppingCriteria):
|
26 |
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
|
|
|
4 |
from transformers import StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
5 |
from threading import Thread
|
6 |
|
7 |
+
torch.set_default_device("cuda")
|
8 |
+
|
9 |
# Loading the tokenizer and model from Hugging Face's model hub.
|
10 |
tokenizer = AutoTokenizer.from_pretrained(
|
11 |
"mlabonne/phixtral-2x2_8",
|
|
|
18 |
trust_remote_code=True
|
19 |
)
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
# Defining a custom stopping criteria class for the model's text generation.
|
22 |
class StopOnTokens(StoppingCriteria):
|
23 |
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
|