Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -4,11 +4,11 @@ import torch
|
|
4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
5 |
from threading import Thread
|
6 |
|
7 |
-
torch.set_default_device("cuda")
|
8 |
tokenizer = AutoTokenizer.from_pretrained(
|
9 |
"cognitivecomputations/dolphin-2.9.1-mixtral-1x22b",
|
10 |
trust_remote_code=True
|
11 |
)
|
|
|
12 |
model = AutoModelForCausalLM.from_pretrained(
|
13 |
"cognitivecomputations/dolphin-2.9.1-mixtral-1x22b",
|
14 |
torch_dtype="auto",
|
@@ -23,7 +23,7 @@ system_prompt = "<|im_start|>system\nYou are Dolphin, a helpful AI assistant.<|i
|
|
23 |
def predict(message, history):
|
24 |
history_transformer_format = history + [[message, ""]]
|
25 |
messages = system_prompt + "".join(["".join(["\n<|im_start|>user\n" + item[0], "<|im_end|>\n<|im_start|>assistant\n" + item[1]]) for item in history_transformer_format])
|
26 |
-
input_ids = tokenizer([messages], return_tensors="pt")
|
27 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
28 |
generate_kwargs = dict(
|
29 |
input_ids,
|
|
|
4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
5 |
from threading import Thread
|
6 |
|
|
|
7 |
tokenizer = AutoTokenizer.from_pretrained(
|
8 |
"cognitivecomputations/dolphin-2.9.1-mixtral-1x22b",
|
9 |
trust_remote_code=True
|
10 |
)
|
11 |
+
|
12 |
model = AutoModelForCausalLM.from_pretrained(
|
13 |
"cognitivecomputations/dolphin-2.9.1-mixtral-1x22b",
|
14 |
torch_dtype="auto",
|
|
|
23 |
def predict(message, history):
|
24 |
history_transformer_format = history + [[message, ""]]
|
25 |
messages = system_prompt + "".join(["".join(["\n<|im_start|>user\n" + item[0], "<|im_end|>\n<|im_start|>assistant\n" + item[1]]) for item in history_transformer_format])
|
26 |
+
input_ids = tokenizer([messages], return_tensors="pt")
|
27 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
28 |
generate_kwargs = dict(
|
29 |
input_ids,
|