braindeck
commited on
Commit
·
a23e411
1
Parent(s):
679a158
Update app.py to match _infer.py behavior
Browse files
app.py
CHANGED
|
@@ -12,8 +12,9 @@ def generate_response(prompt):
|
|
| 12 |
"""
|
| 13 |
Generates a response from the model.
|
| 14 |
"""
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
# Decode the generated text
|
| 19 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
@@ -41,4 +42,4 @@ with gr.Blocks() as demo:
|
|
| 41 |
)
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|
| 44 |
-
demo.launch()
|
|
|
|
| 12 |
"""
|
| 13 |
Generates a response from the model.
|
| 14 |
"""
|
| 15 |
+
chat = [{"role": "user", "content": prompt}]
|
| 16 |
+
inputs = tokenizer.apply_chat_template(chat, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
| 17 |
+
outputs = model.generate(inputs, max_new_tokens=512, temperature=0.0)
|
| 18 |
|
| 19 |
# Decode the generated text
|
| 20 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
|
| 42 |
)
|
| 43 |
|
| 44 |
if __name__ == "__main__":
|
| 45 |
+
demo.launch()
|