Spaces:
Runtime error
Runtime error
Update app.py
Browse fileschange keep model
app.py
CHANGED
|
@@ -39,12 +39,13 @@ tokenizer = AutoTokenizer.from_pretrained(model_id, token=huggingface_token)
|
|
| 39 |
#print(model_id,device,dtype)
|
| 40 |
histories = []
|
| 41 |
|
| 42 |
-
|
| 43 |
-
def generate_text(messages):
|
| 44 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 45 |
model_id, token=huggingface_token ,torch_dtype=dtype,device_map=device
|
| 46 |
)
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
question = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 49 |
question = tokenizer(question, return_tensors="pt").to(device)
|
| 50 |
|
|
|
|
| 39 |
#print(model_id,device,dtype)
|
| 40 |
histories = []
|
| 41 |
|
| 42 |
+
model = AutoModelForCausalLM.from_pretrained(
|
|
|
|
|
|
|
| 43 |
model_id, token=huggingface_token ,torch_dtype=dtype,device_map=device
|
| 44 |
)
|
| 45 |
+
model.to(device)
|
| 46 |
+
|
| 47 |
+
def generate_text(messages):
|
| 48 |
+
|
| 49 |
question = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 50 |
question = tokenizer(question, return_tensors="pt").to(device)
|
| 51 |
|