法律硕士提示
有了搜索结果,就可以生成发送给 LLM 的提示。提示必须包括用户发送的原始问题、在检索阶段获得的相关段落,以及对 LLM 的说明,即答案应来自所包含的段落。
为了显示提示,应用程序使用了 Flask 的render_template() 函数:
qa_prompt = render_template('rag_prompt.txt', question=question, docs=docs)该调用引用的模板文件位于api/templates/rag_prompt.txt 中。
Use the following passages to answer the user's question.
Each passage has a NAME which is the title of the document.
When answering, give the source name of the passages you are answering from at the end.
Put them in a comma separated list, prefixed with SOURCES:.
Example:
Question: What is the meaning of life?
Response:
The meaning of life is 42.
SOURCES: Hitchhiker's Guide to the Galaxy
If you don't know the answer, just say that you don't know, don't try to make up an answer.
----
{% for doc in docs -%}
---
NAME: {{ doc.metadata.name }}
PASSAGE:
{{ doc.page_content }}
---
{% endfor -%}
----
Question: {{ question }}
Response:如果您想了解该模板对聊天机器人回复质量的影响,可以对其进行更改。但一定要确保保留渲染检索段落的 for 循环。