Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -125,6 +125,7 @@ def generate_response_non_streaming(instruction, model_name, temperature=0.7, ma
|
|
| 125 |
try:
|
| 126 |
# 直接使用简单的提示格式,不使用模型的聊天模板
|
| 127 |
prompt = f"User:{instruction}\nAssistant:"
|
|
|
|
| 128 |
chat_input = current_tokenizer.encode(prompt, return_tensors="pt").to(current_model.device)
|
| 129 |
|
| 130 |
# 生成响应
|
|
@@ -137,7 +138,8 @@ def generate_response_non_streaming(instruction, model_name, temperature=0.7, ma
|
|
| 137 |
)
|
| 138 |
|
| 139 |
# 解码并返回生成的文本
|
| 140 |
-
generated_text = current_tokenizer.decode(output[0][len(chat_input[0]):]
|
|
|
|
| 141 |
return generated_text
|
| 142 |
except Exception as e:
|
| 143 |
return f"生成响应时出错: {str(e)}"
|
|
|
|
| 125 |
try:
|
| 126 |
# 直接使用简单的提示格式,不使用模型的聊天模板
|
| 127 |
prompt = f"User:{instruction}\nAssistant:"
|
| 128 |
+
print("prompt:",prompt)
|
| 129 |
chat_input = current_tokenizer.encode(prompt, return_tensors="pt").to(current_model.device)
|
| 130 |
|
| 131 |
# 生成响应
|
|
|
|
| 138 |
)
|
| 139 |
|
| 140 |
# 解码并返回生成的文本
|
| 141 |
+
generated_text = current_tokenizer.decode(output[0], skip_special_tokens=True)#[len(chat_input[0]):]
|
| 142 |
+
print("generated_text:",generated_text)
|
| 143 |
return generated_text
|
| 144 |
except Exception as e:
|
| 145 |
return f"生成响应时出错: {str(e)}"
|