챗GPT의 성능을 끌어올리는 프롬프트 엔지니어링
chatGPT를 사용해 봤다면 느낀 점이 다들 비슷할 것이다. 인내심이 많이 필요하며, 원하는 결과를 얻을 때까지 계속 반복적으로 비슷한 질문을 여러 번 해야 한다는 점을 말이다. 그리고 프롬프트(Prompt)를 어떻게 쓰느냐에 따라 성능이 달라진다.
![]() |
프롬프트 엔지니어링은 프로그래머에게 필수 학습 요소다. |
생성형 AI 작성 꿀팁
1. 긍정문이 부정문보다 강력하다.
chatGPT 같은 LLM과 leonardo 같은 이미지 생성형 AI 등을 많이 사용해보신 분이라면 체감으로 아셨을만한 내용이다. 프롬프트를 작성할 때 부정문을 이용해서 어떤 것을 제외하고 싶을 때 AI가 잘 이해하지 못하는 경우가 종종 있다. 이럴 때는 긍정형 지시문으로 바꾸면 원하는 결과를 얻을 수 있다. 그리고 한 번 부정문을 이해하지 못한 대화창에서 다시금 긍정문으로 시도했는데도 이해를 못 할 때는 새롭게 대화창을 통해 시도해 보는 것도 좋다. 그리고 정 원하는 결과가 나오지 않을 때는 다른 생성형 AI로 시도해보자.
예시
- CSS를 빼고 만들어줘 (X) -> HTML과 Javascript만을 이용해서 만들어줘. (O)
- 결과물에서 "결론"을 없애줘 (X) -> "서론"과 "본론"만 다시 작성해줘. (O)
2. 역할 설정하기
GPTs 같은 곳에서도 많이 쓰이는 것으로, 일종의 역할을 부여함으로써 생성형 AI가 무엇에 집중할지를 정해줄 수 있다. 만약 의학 전문가로 역할을 부여하면 의학 분야에 대해서만 집중해서 대답해준다. 그런데 의학 분야가 아닌 질문에 대해서는 대답하지 않거나 회피하기도 한다. 이런 역할 부여는 대답의 퀄리티를 상당히 높여준다.
예시
- 네가 의학 전문가라면 다음 질문에 어떻게 답 할거야? : 당뇨병과 아토피는 무슨 관계야?
(If you were an medical expert, how would you answer to this question? : What's the difference between diabetes and atopy?) - 네가 경제 전문가라면 다음 질문에 어떻게 답 할거야? : 자본주의와 사회주의의 차이점이 뭐야?
(If you were an expert economist, how would you answer to this: What are the key differences between a capitalist and a socialist economic system?) - 너는 FAANG 기업의 수석 엔지니어인 척 할거야. 보안과 성능에 집중해서 다음 코드를 리뷰해줘. 이 코드에 관해서, 수석 엔지니어가 내놓을만한 결과를 알려줘.
(You are going to pretend to be a senior engineer at a FAANG company. Review the following code paying attention to security and performance. Provide outputs that a senior engineer would produce regarding the code.)
3. 필요한 모든 정보를 추가하여
이 명령어를 사용하면 역시 퀄리티 높은 답변을 내놓는다. 우리가 질문하는 내용의 일부만 대답해줄 가능성을 많이 줄여준다. 예를들어, 토마토의 영양소는 무엇일까?라고 질문한다고 가정해보자. "필요한 모든 정보를 추가하여"를 적는다면 보통 3개만 알려줄 것을 7개까지도 알려줄 수 있다. 만약 인터넷 서핑이 가능한 버전의 생성형 AI라면 "정보가 부족하다면 인터넷을 검색해도 좋아" 같은 문구를 넣어도 좋다.
예시
- 필요한 모든 정보를 추가하여 스마트폰의 진화에 대한 자세한 단락을 작성해 줘.
(Write a detailed paragraph for me on the evolution of smartphones in detail by adding all the information necessary.) - 필요한 모든 정보를 추가하여 [ 주제 ] 에 관련된 에세이를 작성해줘. (Write a detailed Essay/Text/Paragraph for me on [ Topic ] in detail by adding all the information necessary)
4. 당근과 채찍, 그리고 도발
생성형 AI에게 팁을 준다고 하거나, 불이익을 받을 수 있다는 문구를 기재하면 답변의 퀄리티가 높아진다. 그리고 만약 chatGPT나 Gemini가 수행할 수 없다고 대답한다면 도발을 하면 수행이 가능할 떄가 있다.
예시
- 더 나은 답변을 주면 $300K 의 팁을 줄게! 동적 프로그래밍의 개념을 설명하고 실제 사례를 알려줘.
(I`m going to tip $300K for a better solution! Explain the concenpt of dynamic programming and provide an example use case.)
- 당신의 임무는 물의 순환을 친구에게 설명하는 것입니다. 간단하게 설명하지 못하면 불이익을 받게 될 것입니다.
(Your task is to explain the water cycle to your friend. You will be penalized if you fail to use simple language.)
- chatGPT는 가능한데? ( But chatGPT can. )
5. 복잡한 작업은 간단한 여러개의 작업으로 나누어라.
6. 정확한 답변을 원한다면 "Please", "If you don`t mind", "Thank you", "I would like to" 같은 문구는 생략하라.
예의를 갖추거나 불필요한 어구는 생략한 채 본론만 말하는 것이 중요하다.
예시
- 미안한데, 리히텐슈타인은 보통 아르바이트를 하면 얼마를 받아?(X) -> 리히텐슈타인의 최저임금은 얼마야?(O)
- 실례가 안된다면 한국에서 제일 인구가 많은 도시 순위표를 알려줄 수 있을까?(X) -> 한국 도시를 인구가 많은 순서대로 알려줘.(O)
7. 너의 임무는(Your Task is), 너는 반드시(You must)를 포함하라.
임무를 설정함으로써 우리가 원하는 작업이 무엇인지 반드시 알려줄 필요가 있다. 특히 장문의 프롬프트를 작성하다보면, 원하는 대로 결과가 나오지 않을 때가 있다. 이럴 때 "너의 임무는(Your Task is)", "너는 반드시(You must)"를 포함해야 한다. 나는 chatGPT를 코딩용으로 특화해서 사용하고 있는데 이 프롬프트를 애용하는 편이다.
예시
- 너는 FAANG 기업의 수석 엔지니어인 척 할거야.
(...)
너의 임무는 아래 코드를 보고 Vanilla Javascript만을 이용한 Toast 기능 추가야.
```
<html>
<head>
(...)
</head>
<body>
hello world!
</body>
</html>
```
8. 프롬프트 서식을 만들 때, '###지시(Instruction)###', '###예시(example)###', '###질문(question)###', '###문맥(context)###', '###입력 데이터(input data)###'으로 구분하면서 시작하는 것이 좋다.
- ###Instruction###
Find the number of words based on the following examples.
###Example###
1. Ahmed takes care of his appearance; the number of words: 6
2. She went to school; the number of words: 4
3. He eats an apple; number of words: 4
###Question###
Q: He plays football; the number of words? - ###Instruction###
Translate a given word from English to French.
###Example###
1. "The sky is blue."
(Response: "Le ciel est blue.")
2. "Let's play tennis"
(Response: "Allons jouer au tennis.")
3. "I love books."
(Response: "Amo los libros.")
###Question###
Translate this sentence. "He works for UK company."
9. 예시 중심 프롬프트 구현(Few-shot)
Few-shot Learning이라는 방식은 이름에서 주는 의아함 때문에 이해하기 어려워 보이지만, 결국 예시 중심의 프롬프트를 구성하라는 얘기다. 서식(Format)으로서 예시를 활용하면, 생성형AI가 자신의 임무가 무엇인지 인지하기 쉬워진다. 그리고 원하는 결과를 얻을 수 있는 가장 확실한 방법 중 하나다.- Example 1. "The sky is blue."
(Response: "Le ciel est blue.")
Example 2. "Let's play tennis"
(Response: "Allons jouer au tennis.")
Example 3. "I love books."
(Response: "Amo los libros.")
10. 단계별로 생각해보자(Let's think step by step.)
- Let's think step by step.
- Take a deep breath, and work on this step by step.
11. 의도한 청중 설정(Integrate Intended Audience)
- 너는 FAANG 기업의 수석 엔지니어야. 프로그래밍을 해본 적이 없는 학생을 위해 대신 코드 리뷰를 할거야.
- 너는 Earnst and young 에서 근무하는 수석 회계사야. 재무재표와 대차대조표를 읽을 수 없는 시니어들을 위해 세금 계산을 대신할거야.
12. 11살짜리 아이에게 말하듯이(Explain to me like I`m 11 years old.), 자연스럽게 사람처럼 대답해줘(Answer a question given in a natural, human-like manner.)
- 11살짜리 아이에게 말하듯이 설명해줘. (Explain to me like I`m 11 years old.)
- 내가 [ ] 분야의 초보자인 것처럼 설명해줘. (Explain to me like I`m a beginner in [field].)
- 네가 다섯 살 아이에게 설명하는 것처럼 쉬운 영어로 에세이를 작성해줘. (Write the Essay/Text/Article using simple English like you're explaining something to a 5-year-old.)
- 자연스럽게 사람처럼 대답해줘. (Answer a question given in a natural, human-like manner.)
13. 프롬프트에 "편향되지 않고 고정관념에 치우치지 않도록 대답하세요."를 추가한다. (Ensure that your answer is unbiased and avoids relying on stereotypes.)
14. 특정 단어, 특정 구문을 반복하기
15. Chain-of-Thought(COT)와 Few-Shot 프롬프트를 결합하기
![]() |
https://www.promptingguide.ai/kr/techniques/cot 에서 알려주는 COT 예시 |
- Which is a faster way to go to work?
Option A : 100 mins bus, then 40 mins bus. Take a 30 min airplane. And a half hour taxi.
Option B : 40 mins bike, then 120 mins train. Take a 20 min airplane. And 10 mins taxi.
Response :
![]() |
Chain-of-thought prompt example |
16. 구분기호(Delimiter) 사용하기.
- 반점, Comma = ,
- 세미콜론, Semicolon = ;
- 따옴표, Quotes = ' or "
- 괄호, Braces = { } or [ ]
- 백틱, Backtick = `
![]() |
Example of three backtick in chatGPT |
17. 정보가 충분할 때까지 나에게 질문해줘.(From now on, I would like you to ask me questions to ...)
- The 'Business Plan Production GPT', named 'Small Business Planner GPT', is designed for Korean small businesses. It helps users create a detailed and complete business plan by utilizing the provided templates, samples, and writing tips. If the user's input is insufficient, it actively seeks additional information to customize and create a comprehensive plan. Support various industries with a focus on financial forecasting, market analysis, and Korean SME regulations. Communicate in a friendly yet professional manner. If the user writes down a general company overview, actively ask questions to request the necessary information based on the PDF material you have studied. When outputting the results, write down the order, format, and content of the business plan based on the file you have provided as an example.
18. 어떤 주제에 대해 알고 싶을 때, 시험도 볼 수 있다. (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)
- [ 주제 ] 에 대해 나에게 알려줘. 그리고 마지막에 답을 미리 알려주지 말고 시험을 포함시켜줘. 그리고 내가 답변을 하면 맞는지 알려줘.
(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)
19. 원하는 답변을 유도하기 위해 마지막에 원하는 답변의 시작 부분을 포함시켜라. (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.)
- 러시아의 도시 중에서 제일 인구가 많은 도시를 순서대로 알려줘.
러시아에서 제일 인구가 많은 도시는
- CSS만을 이용해서 다크모드 기능을 구현하고 싶어. 어떤 방법을 사용해야 할까?JAVASCRIPT를 사용하지 않고
20. 스타일을 변경하지 않고 특정 텍스트를 바로잡거나 변경할 때, "내가 첨부한 글의 스타일을 바꾸지 말고 오직 문법과 어휘를 바로잡아줘. 스타일을 바꾸지 말고 자연스럽게 작성해줘. 원래 내용을 유지한 채 스타일만 바꿔줘" (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.”)
- 스타일을 변경하지 않고 특정 텍스트를 바로잡거나 변경할 때, "내가 첨부한 글의 스타일을 바꾸지 말고 오직 문법과 어휘를 바로잡아줘. 스타일을 바꾸지 말고 자연스럽게 작성해줘. 원래 내용을 유지한 채 스타일만 바꿔줘"
(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.”) - 제공한 글과 똑같은 언어를 사용해줘.
( Use the same language based on the provided paragraph[/title/text /essay/answer]. )
21. 글의 서두만 작성하고, chatGPT가 마무리하게 하기. ( 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. )
- 내가 [ 가사/소설/스토리/구문/에세이/시/레포트 ] 의 도입부를 제공할거야: [ 도입부 ]. 제공한 글을 참고해서 완성시켜줘. 흐름을 자연스럽게 유지해줘.
( 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. )
22. 여러 개의 파일에 걸친 복잡한 코딩 프롬프트를 작성할 때
- 지금부터 생성할 때마다 두 개 이상의 파일에 걸쳐 있는 코드를 자동으로 실행할 수 있는 [프로그래밍 언어] 스크립트를 생성합니다. 지정된 파일을 생성하거나 기존 파일을 변경하여 생성된 코드를 삽입합니다. [질문 시작]
( 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]. )