Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True,)
|
|
15 |
def respond(prompt, history):
|
16 |
# 構建聊天模板
|
17 |
messages = [
|
18 |
-
{"role": "system", "content": "
|
19 |
{"role": "user", "content": prompt}
|
20 |
]
|
21 |
text = tokenizer.apply_chat_template(
|
@@ -32,7 +32,7 @@ def respond(prompt, history):
|
|
32 |
# 生成回應
|
33 |
generated_ids = model.generate(
|
34 |
**model_inputs,
|
35 |
-
max_new_tokens=
|
36 |
temperature=0.7, # 降低隨機性
|
37 |
top_p=0.9, # 限制生成的多樣性
|
38 |
do_sample=True # 啟用採樣
|
|
|
15 |
def respond(prompt, history):
|
16 |
# 構建聊天模板
|
17 |
messages = [
|
18 |
+
{"role": "system", "content": "使用中文。"},
|
19 |
{"role": "user", "content": prompt}
|
20 |
]
|
21 |
text = tokenizer.apply_chat_template(
|
|
|
32 |
# 生成回應
|
33 |
generated_ids = model.generate(
|
34 |
**model_inputs,
|
35 |
+
max_new_tokens=4096,
|
36 |
temperature=0.7, # 降低隨機性
|
37 |
top_p=0.9, # 限制生成的多樣性
|
38 |
do_sample=True # 啟用採樣
|