对超长文本进行总结的例子中,请问怎样添加提示词,输出中文的总结
clgwlg opened this issue · 3 comments
clgwlg commented
提供中文文档,但输出的总结为英文summary,请问怎样提示输出中文?
JuneDan commented
+1
clgwlg commented
试了下,可以这样写
prompt_template = """Write a concise summary of the following:
{text}
CONCISE SUMMARY IN CHINESE:"""
PROMPT = PromptTemplate(template=prompt_template, input_variables=["text"])
refine_template = (
"Your job is to produce a final summary\n"
"We have provided an existing summary up to a certain point: {existing_answer}\n"
"We have the opportunity to refine the existing summary"
"(only if needed) with some more context below.\n"
"------------\n"
"{text}\n"
"------------\n"
"Given the new context, refine the original summary in CHINESE"
"If the context isn't useful, return the original summary."
)
refine_prompt = PromptTemplate(
input_variables=["existing_answer", "text"],
template=refine_template,
)
chain = load_summarize_chain(llm, chain_type="refine", return_intermediate_steps=True,
question_prompt=PROMPT, refine_prompt=refine_prompt)
response = chain({"input_documents": split_documents})
# print output_text in response
print(response)
print(f"中文概要:{response['output_text']}")
liaokongVFX commented
对的,需要在prompt中明确指出需要他用中文进行总结回答