LLM 프롬프트
검색 결과가 준비되면 이제 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:챗봇 응답 품질에 미치는 영향을 확인하려는 경우 이 템플릿을 변경할 수 있습니다. 하지만 검색된 구절을 렌더링하는 포루프는 항상 보존해야 합니다.