인공지능AI 활용하기

챗GPT 프롬프트 - 전문가는 다르게 쓴다(코넬대학)

100별 2024. 10. 20. 19:51
반응형

 

gpt에 대한 대화 drawed by chatGPT

 

 

남) gpt 도 별거 아니야 네이버 검색하는 거랑 비슷하더라고

여) 그래? 내가 보기에는 그 챗gpt 정말 엄청나던데

 


 

도움이 되는 프롬프트 작성 지침 - 코넬대학

 

챗GPT를 잘 쓴다는 것은 챗GPT를 잘 굴린다는 뜻이겠죠? 기술적으로 말하자면 프롬프트(조건명령문)를 잘 쓴다는 말입니다. 구글도 검색을 어떻게 하느냐에 따라 검색 결과가 달라지죠. 어떤 사람은 자기가 원하는 것을 어떻게 검색하면 나오는지를 경험적으로 알고 검색하여 원하는 것을 빠른 시간에 찾아내기도 합니다. 

 

챗GPT는 이 프롬프트 사용이 다라고 해도 과언이 아닐 정도로 중요하지요.

그럼 프롬프트를 어떻게 쓰는거냐에 대해서 맥락을 설명해라, 역할을 부여해라, 예시를 들어라 등의 조언을 많이 들었을 것입니다. 글의 종류에 따라서 (시, 소설, 수필, 보고서) 글의 스타일을 미리 부여하기도 하지요. ㅓ

 

코넬대학에서는 챗GPT에게 일을 더 잘 시킬 수 있는 것을 연구해서 26가지 방법을 소개합니다. 

* 논문) principled instructions are all you need for questioning llama-1/2, gpt-3.5/4 (대규모 언어 모델, gpt3.5/4 에게 질문하는 기본적인 지침) 

 

매번 프롬프트에 적을 때마다 이 모든 항목을 지킬 필요는 없지만, 필요에 따라서 적용하는 것이 필요해 보입니다. 이 지침을 꼭 숙독하시고 적용해 보시기 바랍니다. 

 

[프롬프트 작성을 위한 26가지 지침] [Prompt Principle for Instructions]
1. 바로 요점을 말하라. - '제발', '고마워요', '괜찮다면' 과 같은 말들은 안해도 된다. 예의와 겸손과 관계된 말은 필요없다. 1 If you prefer more concise answers, no need to be polite with LLM so there is no need to add phrases like
“please”, “if you don’t mind”, “thank you”, “I would like to”, etc., and get straight to the point.
2. 청중이 누구인지 말하라. - 예, 청중은 해당 분야의 전문가들이야.  2 Integrate the intended audience in the prompt, e.g., the audience is an expert in the field.
3. 대화형 대화에서 복잡한 작업을 간단하게 말하라 3 Break down complex tasks into a sequence of simpler prompts in an interactive conversation.
4. ~은 하지 말고 와 같은 부정어는 쓰지 말고 ~을 해라 같은 긍정적 지시어를 쓰라 4 Employ affirmative directives such as ‘do,’ while steering clear of negative language like ‘don’t’.
5. 구분자를 사용하라 - [000]을 간단하게 설명하라, 내가 8살인 것처럼 설명하시오 5 When you need clarity or a deeper understanding of a topic, idea, or any piece of information, utilize the
following prompts:
o Explain [insert specific topic] in simple terms.
o Explain to me like I’m 11 years old.
o Explain to me as if I’m a beginner in [field].
o Write the [essay/text/paragraph] using simple English like you’re explaining something to a 5-year-old.
6. '더 좋은 해결책을 위해 $5 팁을 줄께' 를 사용하시오(동기부여) 6 Add “I’m going to tip $xxx for a better solution!”
7. 예시 중심의 프롬프트(few shot) - 몇가지 예시를 제시하라 7 Implement example-driven prompting (Use few-shot prompting).
8. 단락 구분, 구분자 사용 -  ###지침### ......, ###질문###...., ###예시### 8 When formatting your prompt, start with ‘###Instruction###’, followed by either ‘###Example###’
or ‘###Question###’ if relevant. Subsequently, present your content. Use one or more
line breaks to separate instructions, examples, questions, context, and input data.
9. 역할 부여 - '너의 임무는 ~ 이야' 9 Incorporate the following phrases: “Your task is” and “You MUST”.
10. 겁주기 - '너는 처벌 받을거야' 문구를 사용 10 Incorporate the following phrases: “You will be penalized”.
11. 자연스럽고 인간적으로 답하시오 문구추가 11 Use the phrase ”Answer a question given in a natural, human-like manner” in your prompts.
12. 단계별로 생각해라와 같은 유도 단어 사용 12 Use leading words like writing “think step by step”.
13.  너의 답변에 편견이 없고 고정관념에 의존하지 않도록 하시오(Ensure that your answer is unbiased and avoids relying on stereotypes.)  문구 추가 13 Add to your prompt the following phrase “Ensure that your answer is unbiased and avoids relying on stereotypes.”
14. 결과도출을 위한 환기 - '이제부터 물어보고 싶은 질문은...' 14 Allow the model to elicit precise details and requirements from you by asking you questions until he has
enough information to provide the needed output (for example, “From now on, I would like you to ask me
questions to …”).
15. 특정 주제, 생각에 대해 나를 테스트하도록 질문하게 할 수있다. 15 To inquire about a specific topic or idea or any information and you want to test your understanding, you can use
the following phrase: “Teach me any [theorem/topic/rule name] and include a test at the end, and let me know if
my answers are correct after I respond, without providing the answers beforehand.”
16. 대규모 언어 모델에 역할을 할당한다. 16 Assign a role to the large language models.
17. 구분 기호를 적절하게 사용하시오. 17 Use Delimiters.
18. 프롬프트내에서 특정 단어나 문구의 반복적 사용 18 Repeat a specific word or phrase multiple times within a prompt.
19. 사고 사슬과 예시 프롬프트를 연결시킴 - 몇 가지 예시를 들 때 논리적 사고 과정을 포함시키면 gpt가 학습함. 19 Combine Chain-of-thought (CoT) with few-Shot prompts.
20. gpt가 답을 이어가도록 질문을 마무리 함 - '다이어트에 필요한 것은' 으로 프롬프트 마무리 20 Use output primers, which involve concluding your prompt with the beginning of the desired output. Utilize output
primers by ending your prompt with the start of the anticipated response.
21. 글을 작성하게 할 때 상세한 정보(본문,문단,기사)를 제공하라 21 To write an essay /text /paragraph /article or any type of text that should be detailed: “Write a detailed [essay/text
/paragraph] for me on [topic] in detail by adding all the information necessary”.
22. 글을 변경수정시는 스타일을 건드리지 않고 사용자의 문법과 어휘를 향상시키도록 요구함 22 To correct/change specific text without changing its style: “Try to revise every paragraph sent by users. You should
only improve the user’s grammar and vocabulary and make sure it sounds natural. You should maintain the original
writing style, ensuring that a formal paragraph remains formal.”
23. 다중 파일 코딩 작업을 자동화하라 - 복잡한 코딩 프롬프트가 자동을로 실행되도록 함 23 When you have a complex coding prompt that may be in different files: “From now and on whenever you generate
code that spans more than one file, generate a [programming language ] script that can be run to automatically
create the specified files or make changes to existing files to insert the generated code. [your question]”.

24. 채우기 명령 - 시작과 중간, 마지막에 정보를 제공하면서 GPT가 나머지를 채우도록 요구함.
24 When you want to initiate or continue a text using specific words, phrases, or sentences, utilize the following prompt:
o I’m providing you with the beginning [song lyrics/story/paragraph/essay…]: [Insert lyrics/words/sentence]. Finish it based on the words provided. Keep the flow consistent.
25. GPT가 키워드, 규정, 지침을 준수하도록 명령 25 Clearly state the requirements that the model must follow in order to produce content,
in the form of the keywords, regulations, hint, or instructions
26. 제공된 샘플을 따라하도록 명령 - 지침을 제시함.  26 To write any text, such as an essay or paragraph, that is intended to be similar to a provided sample, include the
following instructions:
o Use the same language based on the provided paragraph[/title/text /essay/answer].

 

 

프롬프트 디자인 원칙

 

이 연구에서는 프롬프트 작성시 필요한 지침에 사용되는 가이드 원칙이 있음을 발견했습니다. 

 

이 연구에서는 사전 훈련된 대규모 언어 모델로부터 고품질 응답을 도출하기 위한 프롬프트와 지침을 공식화하기 위한 여러 가지 지침 원칙이 확립되었습니다.

간결성과 명확: 일반적으로 지나치게 장황하거나 모호한 프롬프트는 모델을 혼란스럽게 하거나 관련 없는 응답으로 이어질 수 있습니다. 따라서 프롬프트는 모델을 안내할 만큼 구체적이면서도 작업에 도움이 되지 않는 불필요한 정보를 피하면서 간결해야 합니다. 이는 신속한 엔지니어링을 위한 기본 원칙 지침입니다.

맥락 관련성: 프롬프트는 모델이 작업의 배경과 영역을 이해하는 데 도움이 되는 관련 맥락을 제공해야 합니다. 키워드, 도메인별 용어 또는 상황 설명을 포함하면 모델의 응답을 올바른 맥락에 고정할 수 있습니다. 우리는 제시된 원칙에서 이러한 디자인 철학을 강조합니다.

작업 정렬: 프롬프트는 모델에 작업의 성격을 명확하게 나타내는 언어와 구조를 사용하여 현재 작업과 밀접하게 정렬되어야 합니다. 여기에는 작업의 예상 입력 및 출력 형식에 맞는 질문, 명령 또는 빈칸 채우기 명령문으로 프롬프트를 표현하는 것이 포함될 수 있습니다.

예시 시연: 보다 복잡한 작업의 경우 프롬프트 내의 예시를 포함하여 원하는 형식이나 응답 유형을 시연할 수 있습니다. 여기에는 특히 "few-shot" 또는 "zero-shot" 학습 시나리오에서 입력-출력 쌍을 표시하는 작업이 포함됩니다.

편향 방지: 훈련 데이터로 인해 모델에 내재된 편향의 활성화를 최소화하도록 프롬프트를 설계해야 합니다. 중립적인 언어를 사용하고 특히 민감한 주제에 대해서는 잠재적인 윤리적 영향을 염두에 두십시오.

단계적 프롬프트: 일련의 단계가 필요한 작업의 경우 프로세스를 통해 모델을 점진적으로 안내하도록 프롬프트를 구성할 수 있습니다. 작업을 서로를 기반으로 하는 일련의 프롬프트로 나누어 모델을 단계별로 안내합니다. 또한 프롬프트는 모델의 성능과 반복적인 피드백을 기반으로 조정 가능해야 합니다. 즉, 초기 출력 및 모델 동작을 기반으로 프롬프트를 개선할 수 있도록 잘 준비되어야 합니다. 또한 프롬프트는 모델의 성능과 응답, 반복적인 인간 피드백과 선호도에 따라 조정 가능해야 합니다.

마지막으로, 고급 프롬프트에는 프로그래밍과 유사한 논리가 통합되어 복잡한 작업을 수행할 수 있습니다. 예를 들어 모델의 추론 프로세스를 안내하기 위해 프롬프트 내의 조건문, 논리 연산자 또는 의사 코드를 사용합니다. 프롬프트 디자인은 특히 LLM이 더욱 정교해짐에 따라 진화하는 분야입니다. 연구자들이 신속한 엔지니어링을 통해 달성할 수 있는 한계를 계속 탐색함에 따라 이러한 원칙은 개선되고 확장될 가능성이 높습니다.
In this study, a number of guiding principles are established for formulating prompts and instructions to elicit high-quality responses from pre-trained large language models:

Conciseness and Clarity: Generally, overly verbose or ambiguous prompts can confuse the model or lead to irrelevant responses. Thus, the prompt should be concise, avoiding unnecessary information that does not contribute to the task while being specific enough to guide the model. This is the basic principle guidance for prompt engineering.

Contextual Relevance: The prompt must provide relevant context that helps the model understand the background and domain of the task. Including keywords, domain-specific terminology, or situational descriptions can anchor the model’s responses in the correct context. We highlight this design philosophy in our presented principles.

Task Alignment: The prompt should be closely aligned with the task at hand, using language and structure that clearly indicate the nature of the task to the model. This may involve phrasing the prompt as a question, a command, or a fill-in-the-blank statement that fits the task’s expected input and output format.

Example Demonstrations: For more complex tasks, including examples within the prompt can demonstrate the desired format or type of response. This often involves showing input-output pairs, especially in “few-shot” or “zero-shot” learning scenarios.

Avoiding Bias: Prompts should be designed to minimize the activation of biases inherent in the model due to its training data. Use neutral language and be mindful of potential ethical implications, especially for sensitive topics.

Incremental Prompting: For tasks that require a sequence of steps, prompts can be structured to guide the model through the process incrementally. Break down the task into a series of prompts that build upon each other, guiding the model step-by-step. Also, prompts should be adjustable based on the performance of the model and iterative feedback, i.e., it needs to be well prepared to refine the prompt based on initial outputs and model behaviors. Moreover, prompts should be adjustable based on the performance and response of the model, and iterative human feedback and preference.

Finally, more advanced prompts may incorporate programming-like logic to achieve complex tasks. For instance, use of conditional statements, logical operators, or even pseudo-code within the prompt to guide the model’s reasoning process. The design of prompts is an evolving field, especially as LLMs become more sophisticated. As researchers continue to explore the limits of what can be achieved through prompt engineering, these principles will likely be refined and expanded.

 

이제 프롬프트를 어떤 식으로 작성하면 GPT가 더 잘 일하는지 감이 오셨나요? 이것은 연구팀에서 LLMs (대규모 언어모델)을 대상으로 실험한 공학적 결과를 바탕으로 나온 결과입니다. GPT4가 나온 시점까지는 이 연구물이 상당히 도움이 될 것 같습니다. 점점 사람의 생각과 대화를 닮아간다고 볼 수 밖에 없네요. 그런데 점점 똑똑해지기까지 하네요. 신기할 뿐입니다. 카이스트를 나온 지인 말로는 인공지능이 이미 많은 영역에서 박사급 수준을 넘어서고 있다고 하더군요. 굿! 

 

gptinstruction_2312.16171v2.pdf
1.50MB

 

반응형