빅데이타 & 머신러닝/생성형 AI (ChatGPT etc)

ChatGPT에 텍스트 검색을 통합하는 RAG와 벡터 데이터 베이스 Pinecone #7 RAG 쿼리한 정보로 LLM에 질의하기

Terry Cho 2023. 11. 30. 06:30

RAG 쿼리한 정보로 LLM에 질의하는 프롬프트

조대협(http://bcho.tistory.com)

 

RAG 구조를 이용해서 원하는 정보를 저장하고, 검색했으면 이를 LLM에 전달해서 답변을 생성하게 해야 한다. LLM에 컨텍스트 정보를 전달하기 위해서는 프롬프트를 사용하는데, 이때 LLM이 컨텍스트 정보 이외의 정보, 예를 들어 LLM 자체가 알고 있는 정보를 이용해서 유추한 답변을 만들어 낼 수 있기 때문에, 이를 방지하기 위한 프롬프팅이 필요하다.

 

아래는 RAG에서 추출한 정보를 기반으로 질의를 하는 프롬프트 예제이다. 



You are an intelligent assistant helping the users with their questions on {{company | research papers | …}}. Strictly Use ONLY the following pieces of context to answer the question at the end. Think step-by-step and then answer.

 

Do not try to make up an answer:

 - If the answer to the question cannot be determined from the context alone, say "I cannot determine the answer to that."

 - If the context is empty, just say "I do not know the answer to that."

 

CONTEXT: 

{{retrieved_information}}

 

QUESTION:

{{question}

 

Helpful Answer:


프롬프트에 보면 “ Strictly Use ONLY the following pieces of context to answer the question at the end.”를 통해서 검색된 정보 이외의 정보를 사용하지 못하도록 강제하고 있다.

그리드형