Commit
·
1f4e50c
1
Parent(s):
3786c93
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,8 +21,7 @@ model_name = "Pclanglais/Bellay"
|
|
| 21 |
|
| 22 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
|
| 23 |
model = transformers.AutoModelForCausalLM.from_pretrained(model_name,
|
| 24 |
-
device_map="auto"
|
| 25 |
-
torch_dtype=torch.bfloat16
|
| 26 |
)
|
| 27 |
|
| 28 |
|
|
@@ -72,7 +71,7 @@ class MistralChatBot:
|
|
| 72 |
# Combine the user and assistant messages into a conversation
|
| 73 |
conversation = "<|im_start|>system\n" + system_prompt + "<|im_end|>\n<|im_start|>user\n" + user_message + "<|im_end|>\n<|im_start|>assistant\n"
|
| 74 |
# Encode the conversation using the tokenizer
|
| 75 |
-
input_ids = tokenizer.encode(conversation, return_tensors="pt", add_special_tokens=
|
| 76 |
input_ids = input_ids.to(device)
|
| 77 |
# Generate a response using the Falcon model
|
| 78 |
response = model.generate(
|
|
|
|
| 21 |
|
| 22 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
|
| 23 |
model = transformers.AutoModelForCausalLM.from_pretrained(model_name,
|
| 24 |
+
device_map="auto"
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
|
|
|
|
| 71 |
# Combine the user and assistant messages into a conversation
|
| 72 |
conversation = "<|im_start|>system\n" + system_prompt + "<|im_end|>\n<|im_start|>user\n" + user_message + "<|im_end|>\n<|im_start|>assistant\n"
|
| 73 |
# Encode the conversation using the tokenizer
|
| 74 |
+
input_ids = tokenizer.encode(conversation, return_tensors="pt", add_special_tokens=True)
|
| 75 |
input_ids = input_ids.to(device)
|
| 76 |
# Generate a response using the Falcon model
|
| 77 |
response = model.generate(
|