OpenAI의 GPT 모범 사례: 전략1. 명확한 지침 작성하기 (Write clear instructions)

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

image

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

이 게시글은 그 중 첫번째 전략인 명확한 지침 작성하기 (Write clear instructions) 를 소개하겠습니다. :smiley:

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

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


GPT 프롬프트 작성 전략1: 명확한 지침 작성하기 / Strategy: Write clear instructions

세부 전술: 관련성 높은 답변을 얻기 위해 질문에 세부 정보 포함하기 / Tactic: Include details in your query to get more relevant answers

보다 연관성이 높은 답변을 얻으려면, 요청할 때 중요한 세부 정보나 맥락(context)을 함께 제공해야 합니다. 그렇지 않으면 모델은 여러분들이 제공한 지침이 무엇을 의미하는지 추측할 수밖에 없습니다.

In order to get a highly relevant response, make sure that requests provide any important details or context. Otherwise you are leaving it up to the model to guess what you mean.

나쁜 예 / Worse 나은 예 / Better
Excel에서 숫자를 더하려면 어떻게 하나요? (How do I add numbers in Excel?) Excel에서 달러 금액 행을 더하려면 어떻게 하나요? 모든 합계가 "합계"라는 열에서 오른쪽으로 끝나는 전체 행에 대해 자동으로 이 작업을 수행하고 싶습니다. (How do I add up a row of dollar amounts in Excel? I want to do this automatically for a whole sheet of rows with all the totals ending up on the right in a column called "Total".)
대통령이 누구인가요? (Who’s president?) 2021년 멕시코의 대통령은 누구이며, 선거는 얼마나 자주 실시되나요? (Who was the president of Mexico in 2021, and how frequently are elections held?)
피보나치 수열을 계산하는 코드를 작성하세요. (Write code to calculate the Fibonacci sequence.) 피보나치 수열을 효율적으로 계산하는 타입스크립트 함수를 작성하세요. 코드에 자유롭게 주석을 달아 각 부분이 무엇을 하고 왜 그런 식으로 작성되었는지 설명하세요. (Write a TypeScript function to efficiently calculate the Fibonacci sequence. Comment the code liberally to explain what each piece does and why it's written that way.)
회의 노트를 요약하세요. (Summarize the meeting notes.) 회의 노트를 한 단락으로 요약하세요. 그런 다음 발표자와 각 발표자의 핵심 요점에 대한 마크다운 목록을 작성합니다. 마지막으로 발표자가 제안한 다음 단계 또는 실행 항목(있는 경우)을 나열해주세요. (Summarize the meeting notes in a single paragraph. Then write a markdown list of the speakers and each of their key points. Finally, list the next steps or action items suggested by the speakers, if any.)

세부 전술: 모델에게 페르소나를 받아들이도록 요청하기 / Tactic: Ask the model to adopt a persona

시스템 메시지를 사용하여 답장에서 모델이 사용하는 페르소나를 지정할 수 있습니다.

The system message can be used to specify the persona used by the model in its replies.


시스템 메시지(SYSTEM)

제가 문서 작성에 도움을 요청하면, 모든 단락마다 농담이나 장난스러운 댓글이 하나 이상 포함한 문서로 답장해주세요.

> When I ask for help to write something, you will reply with a document that contains at least one joke or playful comment in every paragraph.

사용자 메시지(USER)

제 강철 볼트 공급업체가 제시간에 단기간에 납품을 완료해 준 것에 대해 감사 메모를 작성해주세요. 덕분에 중요한 주문을 납품할 수 있었습니다.

> Write a thank you note to my steel bolt vendor for getting the delivery in on time and in short notice. This made it possible for us to deliver an important order.

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

세부 전술: 구분 기호를 사용하여 입력이 구분되도록 명확히 표시하기 / Tactic: Use delimiters to clearly indicate distinct parts of the input

따옴표 3개나 XML 태그, 섹션 제목 등과 같은 구분 기호를 사용하면 텍스트의 섹션을 구분하여 처리할 수 있습니다.

Delimiters like triple quotation marks, XML tags, section titles, etc. can help demarcate sections of text to be treated differently.

사용자 메세지(USER)
따옴표 3개로 구분된 입력 텍스트를 하이쿠(haiku)로 요약해주세요.
"""여기에 입력 문장을 적어주세요"""
> Summarize the text delimited by triple quotes with a haiku.
> """insert text here"""

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

시스템 메시지(SYSTEM)
동일한 주제에 대한 (XML 태그로 구분된) 한 쌍의 기사가 제공됩니다. 먼저 각 기사의 주장을 요약하고, 어느 쪽의 주장이 더 나은지 표시하고 그 이유를 설명하세요.
> You will be provided with a pair of articles (delimited with XML tags) about the same topic. First summarize the arguments of each article. Then indicate which of them makes a better argument and explain why.

사용자 메시지(USER)
<article> 첫번째 기사를 여기에 입력하세요 </article>
<article> 두번째 기사를 여기에 입력하세요 </article>
> <article> insert first article here </article>
> <article> insert second article here </article>

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

시스템 메시지(SYSTEM)
논문 제목은 독자가 논문의 주제를 잘 파악할 수 있으면서도 시선을 사로잡을 수 있어야 합니다. 아래 입력된 논문 초록과 제목(안)을 보고, 제목(안)이 이러한 기준을 충족하지 못하는 경우 5개의 대안을 제시해주세요.
> You will be provided with a thesis abstract and a suggested title for it. The thesis title should give the reader a good idea of the topic of the thesis but should also be eye-catching. If the title does not meet these criteria, suggest 5 alternatives.

사용자 메시지(USER)
초록: 여기에 논문 초록을 입력하세요.
제목: 여기에 제목을 입력하세요.
> Abstract: insert abstract here
> Title: insert title here

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

이러한 간단한 작업들의 경우에는 구분 기호를 사용해도 출력 품질에 차이가 없을 수도 있습니다. 하지만, 작업이 복잡할수록 해야 할 일의 세부 사항을 명확히 구분하는 것이 더 중요합니다. GPT 모델이 (여러분의 요청 내용을 수행하는 대신) 요청 내용을 정확히 이해하기 위해 노력하도록 만들지 마세요.

For straightforward tasks such as these, using delimiters might not make a difference in the output quality. However, the more complex a task is the more important it is to disambiguate task details. Don’t make GPTs work to understand exactly what you are asking of them.

세부 전술: 작업을 완료하는 데 필요한 단계들을 명시하기 / Tactic: Specify the steps required to complete a task

일부 작업들은 수행 할 단계들을 미리 지정하는 것이 좋습니다. 각 단계를 명시적으로 작성하면 GPT 모델이 더 쉽게 작업을 수행할 수 있습니다.

Some tasks are best specified as a sequence of steps. Writing the steps out explicitly can make it easier for the model to follow them.

시스템 메시지(SYSTEM)
다음 단계별 지침을 사용하여 사용자 입력에 응답합니다.
1단계 - 사용자가 따옴표 3개로 묶인 텍스트를 제공합니다. 이 텍스트를 "요약: "이라는 접두사를 사용하여 한 문장으로 요약합니다.
2단계 - "번역: "이라는 접두사를 사용하여 1단계의 요약을 스페인어로 번역합니다.
> Use the following step-by-step instructions to respond to user inputs.
> Step 1 - The user will provide you with text in triple quotes. Summarize this text in one sentence with a prefix that says "Summary: ".
> Step 2 - Translate the summary from Step 1 into Spanish, with a prefix that says "Translation: ".

사용자 메시지(USER)
"""여기에 입력 문장을 적어주세요"""
> """insert text here"""

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

세부 전술: 예시를 함께 제공하기 / Tactic: Provide examples

대체적으로 수행할 작업의 모든 조합을 예시로 보여주는 것보다, 모든 예제에 적용할 수 있는 일반적인 지침을 제공하는 것이 더 효율적입니다. 하지만, 경우에 따라서는 예시를 제공하는 것이 더 나을수도 있습니다. 예를 들어 명시적으로 설명하기 어려운 사용자 질의에 응답하는 특정 스타일을 모델이 복사하도록 하려는 경우입니다. 이를 "퓨-샷(few-shot)" 프롬프트라고 합니다.

Providing general instructions that apply to all examples is generally more efficient than demonstrating all permutations of a task by example, but in some cases providing examples may be easier. For example, if you intend for the model to copy a particular style of responding to user queries which is difficult to describe explicitly. This is known as "few-shot" prompting.

시스템 메시지(SYSTEM)
일관된 스타일로 답변해주세요.
> Answer in a consistent style.

사용자 메시지(USER)
인내심에 대해 알려주세요.
> Teach me about patience.

어시스턴트 메시지(ASSISTANT)
가장 깊은 계곡을 깎아내는 강은 겸손한 샘에서 흐르고, 가장 웅장한 교향곡은 한 음에서 시작되며, 가장 복잡한 태피스트리는 한가닥의 실로부터 시작됩니다.
> The river that carves the deepest valley flows from a modest spring; the grandest symphony originates from a single note; the most intricate tapestry begins with a solitary thread.

사용자 메시지(USER)
바다에 대해 알려주세요.
> Teach me about the ocean.

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

세부 전술: 원하는 결과의 길이를 명시하기 / Tactic: Specify the desired length of the output

GPT 모델이 생성하는 답변의 길이를 지정하도록 할 수 있습니다. 답변의 길이는 단어, 문장, 단락, 글머리 기호 등의 개수로 지정할 수 있습니다. 그러나 GPT 모델에게 특정 단어 수를 생성하도록 지시하는 것은 정확도가 높지 않다는 점에 유의하세요. 모델은 특정 단락 또는 글머리 기호 개수를 지정할 때 더 안정적으로 답변할 수 있습니다.

You can ask the model to produce outputs that are of a given target length. The targeted output length can be specified in terms of the count of words, sentences, paragraphs, bullet points, etc. Note however that instructing the model to generate a specific number of words does not work with high precision. The model can more reliably generate outputs with a specific number of paragraphs or bullet points.

사용자 메시지(USER)
따옴표 3개로 구분된 텍스트를 50단어 내외로 요약해주세요.
"""여기에 입력 문장을 적어주세요"""
> Summarize the text delimited by triple quotes in about 50 words.
> """insert text here"""

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

사용자 메시지(USER)
따옴표 3개로 구분된 텍스트를 두 단락으로 요약해주세요.
"""여기에 입력 문장을 적어주세요"""
> Summarize the text delimited by triple quotes in 2 paragraphs.
> """insert text here"""

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

사용자 메시지(USER)
큰 따옴표 3개로 구분된 텍스트를 3개의 글머리 기호로 요약해주세요.
"""여기에 텍스트를 입력하세요."""
> Summarize the text delimited by triple quotes in 3 bullet points.
> """insert text here"""

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