OpenAI의 GPT 모범 사례: 전략2. 참고 문헌 제공하기 (Provide reference text)

시작하기 전에 - GPT 모범 사례 문서 개요

image

OpenAI의 GPT 모범 사례 문서는 GPT 모델로부터 더 나은 답변을 얻기 위한 6가지 전략(starategy)들과 함께 각 전략별 세부 전술들을 소개하고 있습니다.

이 게시글은 그 중 두번째 전략인 참고 문헌 제공하기 (Provide reference text) 를 소개하겠습니다. :smiley:

전체 GPT 모범 사례에 대한 설명이 궁금하신 분들께서는 아래 목차를 참고해주세요!

https://platform.openai.com/docs/guides/gpt-best-practices/gpt-best-practices


GPT 프롬프트 작성 전략2: 참고 문헌 제공하기 / Strategy: Provide reference text

세부 전술: 모델이 (제공한) 문헌을 참고하여 답하도록 지시하기 / Tactic: Instruct the model to answer using a reference text

사용자의 질의와 관련된 신뢰할 수 있는 정보를 모델에 제공할 수 있는 경우, GPT 모델이 추가로 제공한 정보를 사용하여 답변을 작성하도록 할 수 있습니다.

If we can provide a model with trusted information that is relevant to the current query, then we can instruct the model to use the provided information to compose its answer.

시스템 메시지(SYSTEM)
따옴표 3개로 구분하여 제공된 문서를 참고하여 질문에 답변하세요. 제공된 문서에서 답을 찾을 수 없는 경우에는 "답을 찾을 수 없음"이라고 답변해주세요.
> Use the provided articles delimited by triple quotes to answer questions. If the answer cannot be found in the articles, write "I could not find an answer."

사용자 메시지(USER)
<따옴표 3개로 구분된 문서들을 입력하세요>
질문: <여기에 질문 적어주세요>
> <insert articles, each delimited by triple quotes>
> Question: <insert question here>

위 대화를 실행해보기 / Open in Playground

GPT 모델의 문맥 윈도우(context window) 크기가 제한적이기 때문에, 이 전략을 적용하려면 질문과 관련된 정보를 동적으로 조회할 수 있는 방법이 필요합니다. 임베딩을 사용하여 효율적인 지식 검색을 구현할 수 있습니다. 이를 구현하는 방법에 대한 자세한 내용은 "임베딩 기반 검색을 사용하여 효율적인 지식 검색 구현하기" 전술을 참조하세요. (더 읽어보기 :point_right: 머신러닝 분야의 임베딩에 대한 상세한 가이드 (The Full Guide to Embeddings in Machine Learning))

Given that GPTs have limited context windows, in order to apply this tactic we need some way to dynamically lookup information that is relevant to the question being asked. Embeddings can be used to implement efficient knowledge retrieval. See the tactic "Use embeddings-based search to implement efficient knowledge retrieval" for more details on how to implement this.

세부 전술: 모델이 (제공한) 문헌를 인용하여 답하도록 지시하기/ Tactic: Instruct the model to answer with citations from a reference text

관련된 추가 정보가 입력으로 주어지는 경우, GPT 모델이 제공된 문서의 구절을 참조하여 답변에 인용문을 추가하도록 요청할 수 있습니다. 답변의 인용 문구가 제공된 문서의 문장과 동일한지는 문자열 비교와 같은 프로그래밍을 통해 검증할 수 있습니다.

If the input has been supplemented with relevant knowledge, it's straightforward to request that the model add citations to its answers by referencing passages from provided documents. Note that citations in the output can then be verified programmatically by string matching within the provided documents.

시스템 메시지(SYSTEM)
따옴표 3개로 구분된 문서 함께 질문을 받게 될 것입니다. 이 때, 제공된 문서만을 사용하여 질문에 답해야 하며, 질문에 답하는데 사용한 문서의 구절을 인용해야 합니다. 만약 문서에 질문에 답하는데 필요한 정보가 포함되어 있지 않은 경우에는 "정보 불충분"이라고만 답변해주세요. 질문에 대해 답변이 가능한 경우에는 반드시 인용 주석을 달아야 합니다. 인용 시에는 관련 구절을 다음과 같이 작성해주세요, ({"인용": ...})
> You will be provided with a document delimited by triple quotes and a question. Your task is to answer the question using only the provided document and to cite the passage(s) of the document used to answer the question. If the document does not contain the information needed to answer this question then simply write: "Insufficient information." If an answer to the question is provided, it must be annotated with a citation. Use the following format for to cite relevant passages ({"citation": …}).

사용자 메시지(USER)
"""<여기에 문서를 입력해주세요>"""
질문: <여기에 질문을 적어주세요>
> """<insert document here>"""
> Question: <insert question here>

위 대화를 실행해보기 / Open in Playground