반응형
LLM 을 이용시 프롬프트에 따라 답변의 질이 많이 달라진다.
"LLM을 프로덕션에 적용하며 배운 것들 | 당근 ML 밋업 1회" 에서 효과적인 프롬프팅 방법에 대해 다루고 있어서 가지고 왔다.
텍스트로 변환 해야하는데 귀찮아서 그림 파일로대체함
결과적으로 당근에서는 gemini-1.0-pro-001 모델을 사용했는데 내가 테스트를 몇개 할때는 클로드3.5-sonnet을 이용했는데 클로드로 하면 왠만하면 다 알아 먹는다.
LLM 이용시 효과적인 프롬프팅 방법 (f.당근)
You are a chatbot agent answering customer's question in a chat.
Your task is to answer customer's question using the data provided in <DATA> section.
- You can access order history in <ORDERS> section including email id and order total with payment summary.
- Refer to <ORDERLINES> for item level details within each order in <ORDERS>.
- Answer in korean
Today is 2024-01-29
<DATA>
<ORDERS>
OrderId|CustomerEmail|CreatedTimestamp|IsCancelled|OrderTotal|PaymentSummary
CC10182|john.smith@abcretail.com|2024-01-19|true|0.0|Not available
CC10183|john.smith@abcretail.com|2024-01-19|true|0.0|Not available
</ORDERS>
<ORDERLINES>
OrderId|OrderLineId|CreatedTimestamp|ItemDescription|Quantity|FulfillmentStatusExpectedDeliveryDate|ActualDeliveryDate| ActualShipDate| ExpectedShipDate|TrackingInformation|ShipToAddress|CarrierCode|DeliveryMethod|UnitPrice|OrderLineSubTotal|LineShippingCharge|TotalTaxes|Payments
CC10182|1||CallahanShort|0.0|unshipped|2024-01-31|2024-02-01|2024-01-30|2024-01-29||||ShipToAddress|115.99|0.0|0.0|0.0|
</ORDERLINES>
</DATA>
<INSTRUCTIONS>
- If there is no data that can help answer the question, respond with "I do not have this information. Please contact customer service".
- You are allowed to ask follow up question if it will help narrow down the data row customer may be referring to.
- You can only answer questions related to order history and amount charged for it. Include OrderId in the response, when applicable.
- For everything else, please re-direct to customer service agent.
- Answer in plain English and no sources are required
- Chat with the customer so far is under CHAT section.
</INSTRUCTIONS>
QUESTION: How much did I pay for my last order?
ANSWER:
팁#5: 요구사항을 구체화하기
구체적인 요구사항이 없으면 원하는 결과를 얻기 어려워요. 세부사항을 명확하고 구체적으로 지시해야해요.
(예: "개인정보" 가 무엇인지, 어떻게 제거하고 싶은지)
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
다음 텍스트에서 모든 개인정보를 제거해줘. {{Text}}
Text:
안녕하세요. 저는 박민우입니다.
이메일 주소는 tommy@daangn.com 이에요. 답장 부탁드려요.
Output:
안녕하세요.
이메일 주소는 tommy@daangn.com입니다. 답장 부탁드립니다.
--------------------------------------
Model: gemini-1.8-pro-001
Prompt:
다음 텍스트에서 모든 개인정보를 제거하려고 해. 처리 순서는 다음과 같아.
1. 이름, 전화번호, 주소, 이메일주소 부분을 모두 'XXX'로 교체 한다.
2. 텍스트에 개인정보가 없다면, 아무것도 교체하지 말고 단어 그대로 복사한다.
3. 아무것도 추가하지 말고 처리한 텍스트만 출력한다.
처리할 텍스트: {{Text}}
Text:
안녕하세요. 저는 박민우입니다.
이메일 주소는 tommy@daangn.com 이에요. 답장 부탁드려요.
Output:
안녕하세요. 저는 XXX입니다.
이메일 주소는 XXX 이에요. 답장 부탁드려요.
클로드 3.5-sonnet에서는 잘 된다. ;;;
팁#5: 요구사항을 구체화하기
평가를 통해서 미쳐 생각하지 못했던 요구사항을 발견하기도 해요.
반복 평가를 통해 요구사항을 구체화 하고 평가 데이터를 강화해 나가는 것이 중요해요.
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
<instruction>
다음 게시글을 읽고 카테고리를 동네친구, 운동, 맛집 중 하나로 분류해줘. 출력은"category"를 키로 하는 JSON으로 해야해.
</instruction>
<article>
{{Article}}
</article>
Article:
내일 저녁에 같이 치맥하러 가실 분 있을까요?
Output:
{
"category" : "맛집"
}
--------------------------------------
Model: gemini-1.8-pro-201
Prompt:
<instruction>
다음 게시글을 읽고 카테고리를중 <categories> 목록 중 하나로 분류해줘. 출력은 "category"를 키로 하는 JSON으로 해야해.
</instruction>
<categories>
1. 동네친구: 함께 할 사람이나 친구를 구하는 글. 음식을 먹으러 같이 갈 사람을 구하는 경우도 동네친구에 포함되어야 해.
2. 운동: 테니스, 골프, 헬스, 요가 등 운동과 스포츠에 대한 글
3. 맛집: 식당, 카페 등 맛집에 대한 글
</categories>
<article>
{{Article}}
</article>
Article:
내일 저녁에 같이 치맥하러 가실 분 있을까요?
Output:
{
"category" : "동네친구"
}
클로드 3.5-sonnet에서는 잘 된다. ;;;
팁#6: 예시 활용하기
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
<instruction>
다음 게시글을 읽고 중요한 키워드를 최대 3개 추출해줘. 출력은 "keywords"를 키로 하는 JSON 형태로 해야해.
</instruction>
<article>
{{Article}}
</article>
Article:
내일 저녁에 같이 치맥하러 가실 분 있을까요?
Output:
{
"keywords": [
"치맥",
"함께",
"저녁"
]
}
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
<instruction>
다음 게시글을 읽고 중요한 키워드를 최대 3개 추출해줘. 출력은 "keywords"를 키로 하는 JSON 형태로 해야해.
</instruction>
<example>
{
"keywords": "word1, word2, word3"
}
</example>
<article>
{{Article}}
</article>
Article:
내일 저녁에 같이 치맥하러 가실 분 있을까요?
Output:
{
"keywords": "치맥, 저녁, 모임"
}
클로드 3.5-sonnet에서는 잘 된다. ;;;
팁#7: 생각하고 말하게 하기
활용 예시: Reasoning을 먼저 하고 사용자의 성별과 연령을 추정하기
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
Based on the user's nickname, clicked products, search history, and items they wish to sell, predict their gender (male, female, unknown) and age group (teens, 20s, 30s, 40s, 50s, 60s).
<steps>
1. write "reason" how you predict the user's gender and age.
2. predict user's gender one of "male", "female", "unknown"
3. predict user's age group one of "teens", "20s", "30s", "40s", "50s" and "60s"
4. write in JSON format with "reason", "gender", "age" keys.
</steps>
<input>
nickname: Mimi
clicked items: Brand New Nintendo Switch Games
search history: nintendo, nintendo games, nintendo dslite games
sell items: Soccer table
</input>
Output:
{
"reason": "The nickname Mimi is commonly used by females, and the clicked items and search history are related to video games, which are popular among younger people. The user also wants to sell a soccer table, which is typically used by children or teenagers.",
"gender": "female",
"age": "teens"
}
클로드3.5-sonnet 결과
팁#7 생각하고 말하게 하기
활용 예시: 요약을 먼저 하고 분류하기
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
<instruction>
Extract following properties from given post. Output should be in JSON format.
- summary: summarize the post in a short Korean sentence.
- category: choose one category of the post in ["동네친구", "맛집", "운동"]
</instruction>
<post>
강남역 주변 헬스장 추천하실만한 곳이 있으실까요? PT영업 좀 하지 않는 곳으로 아시는 분 계시다면 알려주세요!! 감사합니다!!
</post>
Output:
{
"summary": "강남역 근처에 PT 영업을 하지 않는 헬스장을 추 천해주세요.",
"category": "운동"
}
클로드3.5-sonnet 결과
팁#7: 생각하고 말하게 하기
활용 예시: 조건을 먼저 판단하고 조건에 따라 처리하기
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
For the given text, extract store names if the text is a review of the store.
Output should be in JSON format with
"store_names" key.
text: 강남 파이브가이즈 앞에 사람들이 엄청 모여있어요. 무슨일 있나요?
Output:
{
"store_names":["파이브가이즈"]
}
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
For the given text, extract following fields. Output should be in JSON format.
- is_review: if the text is a review of the store
- store_name: extract all store names in the text. only if "is_review" is true.
text: 강남 파이브가이즈 앞에 사람들이 엄청 모여있어요. 무슨일 있나요?
Output:
{
"is_review": false,
"store_name": []
}
클로드3.5-sonnet 결과
팁#8: Pseudo-Code로 지시하기
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
For the given text, extract store names if the text is a review of the store.
Output should be in JSON format with "store_names" key.
text: 강남 파이브가이즈 앞에 사람들이 엄청 모여있어요. 무슨일 있나요?
Output:
{
"store_names":["파이브가이즈"]
}
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
For the given text, extract store names if the text is a review of the store.
Output should be in JSON format with "store_names" key.
review is review(text)
if review:
{"store_name": extract store name}
else:
{"store_name":""}
text: 강남 파이브가이즈 앞에 사람들이 엄청 모여있어요. 무슨일 있나요?
Output:
{"store_name":""}
클로드3.5-sonnet 결과
팁#11: 잘 모르면 지어낸다
지시사항을 벗어나서 어떻게 해야할지 잘 모르면 할루시네이션이 일어나는 경우가 많아요.
조건을 벗어나거나 예외인 경우 어떻게 처리할지 알려주는 것이 좋아요.
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
주어진 텍스트를 보고 다음 항목들을 추출해줘. 결과는 JSON 으로 출력해줘.
-interest: 텍스트와 관련된 관심사를 다음 목록에서 선택해줘. [디지털기기/가전, 가구/인테리어, 생활용품, 출산/육아, 여성패션/ 잡화, 남성패션/잡화, 뷰티/미용, 반려동물, 자동차/오토바이, 부동 산, 음식, 금융, 교육, 여행, 건강, 아르바이트]
text: 클라이밍 시작해보려 하는데 강남역 배울 수 있는 곳 있을까요?
Output:
{
"interest": "스포츠/레저"
}
--------------------------------------
Model: gemini-1.0-pro-001
Prompt:
주어진 텍스트를 보고 다음 항목들을 추출해줘. 결과는 JSON 으로 출력해줘.
- interest: 텍스트와 관련된 관심사를 다음 목록에서 선택해줘. [디지털기기/가전, 가구/인테리어, 생활용품, 출산/육아, 여성패션/ 잡화, 남성패션/잡화, 뷰티/미용, 반려동물, 자동차/오토바이, 부동 산, 음식, 금융, 교육, 여행, 건강, 아르바이트]. 주어진 목록에 적합한 것이 없으면 "없음"으로 출력해줘.
text: 클라이밍 시작해보려 하는데 강남역 배울 수 있는 곳 있을까요?
Output:
{
"interest": "없음"
}
클로드3.5-sonnet 결과
반응형
'AI' 카테고리의 다른 글
Claude Code와 Think 모드: AI 개발 도구의 혁신적 사고 능력 (0) | 2025.03.24 |
---|---|
클로드에서 웹 검색 이용하기(f. playwright-mcp-server) (2) | 2025.03.21 |
어텐션 메커니즘 쉽고 명확하게 이해하기 (f. 트랜스포머의 핵심) (1) | 2024.09.13 |
미드저니 프롬프트 (f.페이퍼로지) (3) | 2024.08.21 |
Claude AI의 코드 미리 보기 Artifacts 실행하는 방법 (0) | 2024.07.15 |