Spaces:
Sleeping
Sleeping
Commit
·
7a6311a
1
Parent(s):
0f20fb4
test deepseek
Browse files
app.py
CHANGED
|
@@ -62,9 +62,13 @@ def deepseek(
|
|
| 62 |
model.generation_config = GenerationConfig.from_pretrained(model_name)
|
| 63 |
model.generation_config.pad_token_id = model.generation_config.eos_token_id
|
| 64 |
|
|
|
|
|
|
|
|
|
|
| 65 |
messages = [
|
| 66 |
-
{"role": "user", "content":
|
| 67 |
]
|
|
|
|
| 68 |
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
|
| 69 |
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)
|
| 70 |
print(outputs)
|
|
@@ -85,6 +89,10 @@ chat = gr.ChatInterface(
|
|
| 85 |
# gr.Image(type="pil", label="Attach an image (optional)"),
|
| 86 |
# gr.File(label="Upload a file (optional)"),
|
| 87 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
)
|
| 89 |
|
| 90 |
if __name__ == "__main__":
|
|
|
|
| 62 |
model.generation_config = GenerationConfig.from_pretrained(model_name)
|
| 63 |
model.generation_config.pad_token_id = model.generation_config.eos_token_id
|
| 64 |
|
| 65 |
+
# messages = [
|
| 66 |
+
# {"role": "user", "content": "what is the integral of x^2 from 0 to 2?\nPlease reason step by step, and put your final answer within \\boxed{}."}
|
| 67 |
+
# ]
|
| 68 |
messages = [
|
| 69 |
+
{"role": "user", "content": message}
|
| 70 |
]
|
| 71 |
+
|
| 72 |
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
|
| 73 |
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)
|
| 74 |
print(outputs)
|
|
|
|
| 89 |
# gr.Image(type="pil", label="Attach an image (optional)"),
|
| 90 |
# gr.File(label="Upload a file (optional)"),
|
| 91 |
],
|
| 92 |
+
examples=[
|
| 93 |
+
# Mỗi item: [message, system_message, max_tokens, temperature, top_p]
|
| 94 |
+
["tích phân của x^2 từ 0 đến 2 là gì? vui lòng lập luận từng bước, và đặt kết quả cuối cùng trong \boxed{}", "bạn là nhà toán học", 100, 0.7, 0.95],
|
| 95 |
+
],
|
| 96 |
)
|
| 97 |
|
| 98 |
if __name__ == "__main__":
|