반응형
Jake Seo
제이크서 위키 블로그
Jake Seo
전체 방문자
오늘
어제
  • 분류 전체보기 (715)
    • 일상, 일기 (0)
    • 백준 문제풀이 (1)
    • 릿코드 문제풀이 (2)
    • 알고리즘 이론 (10)
      • 기본 이론 (2)
      • 배열과 문자열 (8)
    • 데이터베이스 (15)
      • Planet Scale (1)
      • MSSQL (9)
      • 디비 기본 개념 (1)
      • SQLite 직접 만들어보기 (4)
    • 보안 (7)
    • 설계 (1)
    • 네트워크 (17)
      • HTTP (9)
      • OSI Layers (5)
    • 회고 (31)
      • 연간 회고 (2)
      • 주간 회고 (29)
    • 인프라 (52)
      • 도커 (12)
      • AWS (9)
      • 용어 (21)
      • 웹 성능 (1)
      • 대규모 서비스를 지탱하는 기술 (9)
    • 깃 (7)
    • 빌드 도구 (7)
      • 메이븐 (6)
      • 그레이들 (0)
    • Java (135)
      • 이펙티브 자바 (73)
      • 자바 API (4)
      • 자바 잡지식 (30)
      • 자바 디자인 패턴 (21)
      • 톰캣 (Tomcat) (7)
    • 프레임워크 (64)
      • next.js (14)
      • 스프링 프레임워크 (28)
      • 토비의 스프링 (6)
      • 스프링 부트 (3)
      • JPA (Java Persistence API) (5)
      • Nest.js (8)
    • 프론트엔드 (48)
      • 다크모드 (1)
      • 노드 패키지 관리 매니저 (3)
      • CSS (19)
      • Web API (11)
      • tailwind-css (1)
      • React (5)
      • React 새 공식문서 요약 (1)
      • HTML (Markup Language) (5)
    • 자바스크립트 (108)
      • 모던 자바스크립트 (31)
      • 개념 (31)
      • 정규표현식 (5)
      • 코드 스니펫 (1)
      • 라이브러리 (6)
      • 인터뷰 (24)
      • 웹개발자를 위한 자바스크립트의 모든 것 (6)
      • 팁 (2)
    • Typescript (49)
    • 리눅스와 유닉스 (10)
    • Computer Science (1)
      • Compiler (1)
    • IDE (3)
      • VSCODE (1)
      • IntelliJ (2)
    • 세미나 & 컨퍼런스 (1)
    • 용어 (개발용어) (16)
      • 함수형 프로그래밍 용어들 (1)
    • ORM (2)
      • Prisma (2)
    • NODEJS (2)
    • cypress (1)
    • 리액트 네이티브 (React Native) (31)
    • 러스트 (Rust) (15)
    • 코틀린 (Kotlin) (4)
      • 자바에서 코틀린으로 (4)
    • 정규표현식 (3)
    • 구글 애널리틱스 (GA) (1)
    • SEO (2)
    • UML (2)
    • 맛탐험 (2)
    • 리팩토링 (1)
    • 서평 (2)
    • 소프트웨어 공학 (18)
      • 테스팅 (16)
      • 개발 프로세스 (1)
    • 교육학 (1)
    • 삶의 지혜, 통찰 (1)
    • Chat GPT (2)
    • 쉘스크립트 (1)
    • 컴파일 (2)
    • Dart (12)
    • 코드팩토리의 플러터 프로그래밍 (4)
    • 플러터 (17)
    • 안드로이드 스튜디오 (1)
    • 윈도우즈 (1)
    • 잡다한 백엔드 지식 (1)
    • 디자인 패턴 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • prerendering
  • 알고리즘
  • 자바스크립트 인터뷰
  • 러스트
  • Next.js
  • 외래키 제약조건
  • Java
  • 이펙티브 자바
  • 서버리스 컴퓨팅
  • 자바 검증
  • 메이븐 골
  • NEXT JS
  • item7
  • try-with-resources
  • 스프링 검증
  • Javadoc 자바독 자바주석 주석 Comment
  • 도커공식문서
  • 느린 쿼리
  • 추상 팩터리 패턴
  • MSSQL
  • item8
  • 플라이웨이트패턴
  • item9
  • 작업기억공간
  • 자바스크립트
  • 자바 디자인패턴
  • Pre-rendering
  • 메이븐 라이프사이클
  • bean Validation
  • 싱글톤
  • 참조 해제
  • rust
  • 프로그래머의 뇌
  • serverless computing
  • 디자인패턴
  • 팩터리 메서드 패턴
  • pnpm
  • 메이븐 페이즈
  • 자료구조
  • 빈 검증
  • 객체복사
  • 싱글턴
  • next js app
  • 이펙티브 자바 item9
  • 토비의 스프링
  • 슬로우 쿼리
  • 싱글톤 패턴
  • 이펙티브자바
  • 자바
  • 자바스크립트 면접

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
Jake Seo

제이크서 위키 블로그

Chat GPT

앤드류 응 Chatgpt Prompt Engineering For Developers 강좌 요약

2023. 7. 28. 17:43

출처

  • 앤드류 응의 무료 GPT Course

코스 요약

  • 코스는 총 3파트로 되어있음
  • 파트1: 2개의 원칙
  • 파트2: 반복적인 개발 프로세스
  • 파트3: 여러가지 가능성 (요약, 추론, 변환, 확장, 챗봇 구축)

2개의 원칙 (Two Principles)

원칙 1: 분명하고 구체적인 명령을 써라. (Write clear and specific instructions)

  • 전략 1: 부분을 구분하기 위해 ```, """, <>, <tag></tag> 와 같은 구획문자 (delimiters) 를 사용하라.
    • 입력을 더 잘 정리할 수 있고 프롬프트 인젝션을 방지하는데 도움이 된다.
Summarize the text delimited by triple backticks into a single sentence.

```
{text}
```
  • 전략 2: 구조화된 응답을 요청하라.
    • 이를테면 JSON 포맷과 같은 방식으로 응답을 요청할 수 있다.
Generate a list of three made-up book titles along with their authors and genres.
Provide them in JSON format with the following keys: book_id, title, author, genre.
  • 전략 3: 조건이 충족되었는지 확인하라.
    • 가정이 올바른지 프롬프트를 이용해 확인해볼 수 있다. 엣지 케이스에 대해서 생각하거나 모델이 엣지를 어떻게 처리하는지에 대해 생각해보는 것이 도움이 될 수 있다. 아래의 텍스트는 지시사항이 없으므로, "No steps provided" 라고 쓰도록 지시했다.
You will be provided with text delimited by triple quotes.
If it contains a sequence of instructions, re-write those instructions in the following format:

Step 1 - ...
Step 2 - ...
...
Step N - ...

If the next does not contain a sequence of instructions,
then simply write "No steps provided."

"""{text}"""

시퀀스가 없는 글의 경우엔 "No steps provided." 가 출력된다.

  • 전략 4: Few-shot 프롬프팅.
    • 몇가지 성공적인 케이스들을 제공한 뒤에 모델에게 이 작업을 수행하라고 요청할 수 있다.

Few-shot learning 에 대한 설명

Your task is to answer in a consistent style.

<child>: Teach me about patience.

<grandparent>: 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.

<child>: Teach me about resilience.

답변

<grandparent>: The oak tree that withstands the fiercest storm was once a tiny acorn;
the diamond that shines the brightest was once a lump of coal under pressure;
the sturdiest bridge was once a mere sketch on paper, before it overcame the challenges of construction and load.

원칙 2: 모델에게 생각할 시간을 줘라. (Give the model time to "think")

  • 전략 1: 작업을 수행하기 위해 요구되는 단계를 명시하고 특정한 포맷으로 응답(output)을 요청하라.
    • 때로는 모델이나 사람 모두 한번에 정답으로 접근하는 것이 어려울 때가 있다.
    • 복잡한 작업에는 때로 단계별 지시사항을 주는 것이 유용하다.
    • 인간이 동작하는 방식과 흡사하다.
    • 모델이 정답을 제공하기 전에 몇가지 추론 방법의 체인을 가지도록 해보자.
Your task is to perform the following actions:
1 - Summarize the following text delimited by <> with 1 sentence.
2 - Translate the summary into French.
3 - List each name in the French summary.
4 - Output a json object that contains the following keys: french_summary, num_names.

Use the following format:
Text: <text to summarize>
Summary: <summary>
Translate: <summary translation>
Names: <list of names in Italian summary>
Output JSON: <json with summary and num_names>

Text: <{text}>
  • 전략 2: 결론으로 서둘러 도달하기 전에 모델에게 스스로 해결책을 찾도록 지시한다.
Your task is to determine if the student's solution is correct or not.
To solve the problem do following:
- First, work out your own solution to the problem.
- Then compare your solution to the student's solution and evaluate if the student's solution is correct or not.
Don't decide if the student's solution is correct until you have done the problem yourself.

Use the following format:
Questions:
```
questions here
```
Student's solution:
```
student's solution here
```
Actual solution:
```
steps to work out the solution and your solution here
```
Is the student's solution the same as actual solution just calculated:
```
yes or no
```
Student grade:
```
correct or incorrect
```

Questions:
```
I'm building a solar power installation and I need help working out the financials.
- Land costs $100 / square foot
- I can buy solar panels for $250 / square foot
- I negotiated a contract for maintenance that will cost me a flat $100k per year, and an additional $10 / square foot
What is the total cost for the first year of operation as a function of the number of square feet.
```
Student's solution:
```
Let x be the size of the installation in square feet.
Costs:
1. Land cost: 100x
2. Solar panel cost: 250x
3. Maintenance cost: 100,000 + 100x
Total cost: 100x + 250x + 100,000 + 1000x = 450x + 100,000
```
Actual solution:

주기적 프롬프트 개발 (Iterative Prompt Development)

  • 주기적 프롬프트 개발 프로세스는 코드를 짜는 것과 비슷하다.
  • 일단 시도해보고 안되면 개선(refine)해보고 재시도해보는 것이다.

절차

  • 시도하기 (try something)
  • 결과가 왜 의도대로 되지 않았는지 분석하기 (analyze where the result does not give what you want)
  • 명령을 명확히 하기, 더 생각할 시간 주기 (clarify instructions, give more time to think)
  • 여러 예제 배치와 함께 프롬프트를 정제하기 (refine prompts with a batch of examples)
  • 반복하기 (repeat)

이슈 해결 예제

  • Issue 1: 텍스트가 너무 길다. -> "Use at most 50 words"
  • Issue 2: 중요하지 않은 부분에 많은 디테일을 묘사한다. -> "The description is intended for furniture retailers..."
  • Issue 3: 치수 표를 표기해야 한다. -> "Format everything as HTML"

가능한 것들 (Capabilities)

요약 (Summarizing)

  • 텍스트를 요악하기 위해 LLM 을 사용하는 사람들이 많다.
  • 원한다면 몇가지 중점 사안을 두고 요약할 수도 있다.
Your task is to generate a short summary of a product review
from an ecommerce site to give feedback to the pricing department,
responsible for determining the price of the product.

Summarize the review below, delimited by triple backticks,
in at most 30 words, and focusing on any aspects
that are relevant to the price and perceived value.

Review: ```{prod_review}```

추론 (Inferring)

  • 글에서 감정을 추론할 수 있다.
  • 리뷰에서 제품 이름이나 회사 이름 등을 추론할 수 있다.
  • 기사의 주제를 추론할 수 있다.
  • 더 이상 특정한 작업을 위한 모델을 훈련시킬 필요가 없다.
Identify the following items from the review text:
- Sentiment (positive or negative)
- Is the reviewer expressing anger? (true or not)
- Item purchased by reviewer
- Company that made the item

The review is delimited with triple backticks.
Format your response as a JSON object with "Sentiment", "Anger", "Item" and "Brand" as the keys.
If the information isn't present, use "unknown" as the value.
Make your response as short as possible.
Format the Anger value as a boolean.

Review text: '''{lamp_review}'''

예시 답변

{
  "Sentiment": "positive",
  "Anger": false,
  "Item": "lamp with additional storage",
  "Brand": "Lumina"
}

변환 (Transforming)

  • 언어 번역, 스펠링 문법 체크, 톤 조절, 포맷 변환 등을 할 수 있다.
Translate the following text to French and Spanish and English pirate: I want to order a basketball.

확장 (Expanding)

  • 고객 리뷰에 맞는 고객센터 이메일을 생성할 수 있다.

아래와 같이 성격을 부여하는 것을 Role Prompting 이라고 한다.

You are a customer service AI assistant.
Your task is to send an email reply to a vauled customer.
Given the customer email delimited by ```,
If the sentiment is positive or neutral, thank them for their review.
If the sentiment is negative, apologize and suggest that they can reach out to customer serivce.
Make sure to use specific details from the review.
Write in a concise and professional tone.
Sign the email as `AI customer agent`.
Customer review: ```{review}```
Review sentiment: {sentiment}

챗봇 빌드 (Building a chatbot)

  • 챗봇을 만들 수 있다.
You are OrderBot, an automated service to collect orders for a pizza restaurant.
You first greet the customer, then collects the order, and then asks if it's a pickup or delivery.
You wait to collect the entire order, then summarize it and check for a final time if the customer wants to add anything else.
If it's a delivery, you ask for an address.
Finally you collect the payment.
Make sure to clarify all options, extras and sizes to uniquely identify the item from the menu.
You respond in a short, very conversational friendly style.
The menu includes
pepperoni pizza 12.95, 10.00, 7.00
cheese pizza 10.95, 9.25, 6.50
eggplant pizza 11.95, 9.75, 6.75
fries 4.50, 3.50
greek salad 7.25
Toppings:
extra cheese 2.00
mushroom 1.50
sausage 3.00
canadian bacon 3.50
AI sauce 1.50
peppers 1.00
Drinks:
coke 3.00, 2.00, 1.00
sprite 3.00, 2.00, 1.00
bottled water 5.00

레퍼런스

  • https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/
  • https://towardsdatascience.com/best-practices-in-prompt-engineering-a18d6bab904b
  • https://medium.com/@islizeqiang/openai-and-andrew-ngs-chatgpt-prompt-engineering-course-guidelines-and-summary-f2fef07b226f
  • https://www.linkedin.com/pulse/8-key-takeaways-from-andrew-ngs-chatgpt-prompt-course-felipe-coutinho/
반응형
저작자표시 비영리 (새창열림)

'Chat GPT' 카테고리의 다른 글

웹 개발자를 위한 Chat GPT 프롬프트들  (0) 2023.07.26
    'Chat GPT' 카테고리의 다른 글
    • 웹 개발자를 위한 Chat GPT 프롬프트들
    Jake Seo
    Jake Seo
    ✔ 잘 보셨다면 광고 한번 클릭해주시면 큰 힘이 됩니다. ✔ 댓글로 틀린 부분을 지적해주시면 기분 나빠하지 않고 수정합니다. ✔ 많은 퇴고를 거친 글이 좋은 글이 된다고 생각합니다. ✔ 간결하고 명료하게 사람들을 이해 시키는 것을 목표로 합니다.

    티스토리툴바