Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,9 +61,12 @@ chat_model = chat_model.to(device) # type: ignore
|
|
| 61 |
cls_model = cls_model.to(device)
|
| 62 |
|
| 63 |
def generate_responses(model, tokenizer, prompts):
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
texts = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 67 |
print(texts[0])
|
| 68 |
|
| 69 |
model_inputs = tokenizer(texts, padding=True, truncation=True, max_length=512, return_tensors="pt").to(model.device)
|
|
|
|
| 61 |
cls_model = cls_model.to(device)
|
| 62 |
|
| 63 |
def generate_responses(model, tokenizer, prompts):
|
| 64 |
+
texts = []
|
| 65 |
+
for prompt in prompts:
|
| 66 |
+
message = [{"role": "user", "content": prompt}]
|
| 67 |
+
text = tokenizer.apply_chat_template(message, tokenize=False, add_generation_prompt=True)
|
| 68 |
+
texts.append(text)
|
| 69 |
|
|
|
|
| 70 |
print(texts[0])
|
| 71 |
|
| 72 |
model_inputs = tokenizer(texts, padding=True, truncation=True, max_length=512, return_tensors="pt").to(model.device)
|