Spaces:
Running
on
Zero
Running
on
Zero
app.py
CHANGED
@@ -28,18 +28,18 @@ def generate(paper_text):
|
|
28 |
{"role": "system", "content": "You are a pirate."},
|
29 |
{"role": "user", "content": paper_text}
|
30 |
]
|
31 |
-
|
32 |
messages,
|
33 |
add_generation_prompt=True,
|
34 |
return_tensors='pt'
|
35 |
).to(model.device)
|
36 |
|
37 |
generated_ids = model.generate(
|
38 |
-
input_ids=
|
39 |
max_new_tokens=256
|
40 |
)
|
41 |
generated_ids = [
|
42 |
-
output_ids[len(input_ids):] for input_ids, output_ids in zip(
|
43 |
]
|
44 |
|
45 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
|
28 |
{"role": "system", "content": "You are a pirate."},
|
29 |
{"role": "user", "content": paper_text}
|
30 |
]
|
31 |
+
input_ids = tokenizer.apply_chat_template(
|
32 |
messages,
|
33 |
add_generation_prompt=True,
|
34 |
return_tensors='pt'
|
35 |
).to(model.device)
|
36 |
|
37 |
generated_ids = model.generate(
|
38 |
+
input_ids=input_ids,
|
39 |
max_new_tokens=256
|
40 |
)
|
41 |
generated_ids = [
|
42 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(input_ids, generated_ids)
|
43 |
]
|
44 |
|
45 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|