Spaces:
Sleeping
Sleeping
Denis PEYRUSAUBES commited on
Commit ·
70a1503
1
Parent(s): 1d8a9ec
ok
Browse files- ChatMixtral.py +2 -1
ChatMixtral.py
CHANGED
|
@@ -9,10 +9,11 @@ class ChatMixtral:
|
|
| 9 |
model_id, device_map="auto", load_in_4bit=True
|
| 10 |
)
|
| 11 |
self.tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1", padding_side="left")
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
def ask(self, query: str):
|
| 15 |
-
model_inputs = self.tokenizer(["A list of colors: red, blue"], return_tensors="pt").to(
|
| 16 |
generated_ids = self.model.generate(**model_inputs)
|
| 17 |
return self.tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 18 |
|
|
|
|
| 9 |
model_id, device_map="auto", load_in_4bit=True
|
| 10 |
)
|
| 11 |
self.tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1", padding_side="left")
|
| 12 |
+
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
|
| 14 |
|
| 15 |
def ask(self, query: str):
|
| 16 |
+
model_inputs = self.tokenizer(["A list of colors: red, blue"], return_tensors="pt").to(self.device)
|
| 17 |
generated_ids = self.model.generate(**model_inputs)
|
| 18 |
return self.tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 19 |
|