ChatGPT Prompt Engineering for Developers (1)

City_Duck·2023년 5월 22일
0

Prompt Engineering

목록 보기
2/3

Iterative Prompt Develelopment


다음과 같은 Cycle을 지나며 Prompt를 원하는 결과에 맞게 변경해 나간다.
이와 같은 Cycle을 예시를 통해 실습해보고자 한다.

product fact sheet을 통해 마케팅에 사용할 product description을 만들기

fact_sheet_chair = """
OVERVIEW
- Part of a beautiful family of mid-century inspired office furniture, 
including filing cabinets, desks, bookcases, meeting tables, and more.
- Several options of shell color and base finishes.
- Available with plastic back and front upholstery (SWC-100) 
or full upholstery (SWC-110) in 10 fabric and 6 leather options.
- Base finish options are: stainless steel, matte black, 
gloss white, or chrome.
- Chair is available with or without armrests.
- Suitable for home or business settings.
- Qualified for contract use.

CONSTRUCTION
- 5-wheel plastic coated aluminum base.
- Pneumatic chair adjust for easy raise/lower action.

DIMENSIONS
- WIDTH 53 CM | 20.87”
- DEPTH 51 CM | 20.08”
- HEIGHT 80 CM | 31.50”
- SEAT HEIGHT 44 CM | 17.32”
- SEAT DEPTH 41 CM | 16.14”

OPTIONS
- Soft or hard-floor caster options.
- Two choices of seat foam densities: 
 medium (1.8 lb/ft3) or high (2.8 lb/ft3)
- Armless or 8 position PU armrests 

MATERIALS
SHELL BASE GLIDER
- Cast Aluminum with modified nylon PA6/PA66 coating.
- Shell thickness: 10 mm.
SEAT
- HD36 foam

COUNTRY OF ORIGIN
- Italy
"""

해당 글과 단순한 instruction만을 추가하여 prompt를 구성하면 다음과 같은 결과가 나온다.

prompt = f"""
Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple backticks.

Technical specifications: ```{fact_sheet_chair}```
"""
response = get_completion(prompt)
print(response)

1. 결과물이 너무 길기에 이를 줄이고자 한다.

  • Limit the number of words/sentences/characters.

Prompt에 "Use at most 50 words" 혹은 "Use at most 3 sentences"와 같이 길이를 제한하는 문구를 추가하면 다음과 같은 결과물이 나온다.

prompt = f"""
Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple backticks.

Use at most 50 words.

Technical specifications: ```{fact_sheet_chair}```
"""
response = get_completion(prompt)
print(response)

2. 원하는 부분을 강조하고 싶다.

  • Ask it to focus on the aspects that are relevant to the intended audience.

"The description is intended for furniture retailers,
so should be technical in nature and focus on the
materials the product is constructed from.

At the end of the description, include every 7-character
Product ID in the technical specification."

다음과 같이 원하는 강조 사항과 요구사항을 추가할 경우 해당 내용을 반영하여 결과물이 나온다.

3. HTML 형식으로 table을 추가하고 싶다.

prompt = f"""
Your task is to help a marketing team create a 
description for a retail website of a product based 
on a technical fact sheet.

Write a product description based on the information 
provided in the technical specifications delimited by 
triple backticks.

The description is intended for furniture retailers, 
so should be technical in nature and focus on the 
materials the product is constructed from.

At the end of the description, include every 7-character 
Product ID in the technical specification.

After the description, include a table that gives the 
product's dimensions. The table should have two columns.
In the first column include the name of the dimension. 
In the second column include the measurements in inches only.

Give the table the title 'Product Dimensions'.

Format everything as HTML that can be used in a website. 
Place the description in a <div> element.

Technical specifications: ```{fact_sheet_chair}```
"""

response = get_completion(prompt)
print(response)

다음과 같이 prompt를 수정했을 시 이와 같이 HTML 형식으로 결과물을 반환한다.

이를 HTML로 실행하면 다음과 같은 결과물이 나온다.

from IPython.display import display, HTML
display(HTML(response))

이와 같이 결과물을 피드백하며 원하는 방향으로 Prompt를 변경한다면 원하는 결과물을 얻을 수 있다.

profile
AI 새싹

2개의 댓글

comment-user-thumbnail
2023년 11월 10일

Geben Sie einfach ein, was Sie brauchen - egal ob es sich um eine einfache Übersetzung, Grammatikhilfe oder allgemeine Konversationsübungen handelt - und Sie erhalten sofort präzise Hilfe von ChatGPT! Die Bots sind superschlau, so dass Sie sicher sein können, dass Sie detaillierte und hilfreiche Antworten zu allem bekommen, von Vokabeln bis hin zur Satzstruktur und mehr. Nutzen Sie die kostenlosen Ressourcen auf https://gptdeutsch.de/, um Ihre Sprachkenntnisse schnell und unkompliziert aufzufrischen - mit vielen hilfreichen Antworten, wann immer Sie sie brauchen!

답글 달기
comment-user-thumbnail
2023년 12월 20일

이 콘텐츠를 작성하는 데 시간을 할애해 주셔서 진심으로 감사드립니다. 당신의 작업은 품질이 너무 좋아서 연구를 많이 했다는 것을 보여줍니다. Quick Draw

답글 달기