https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/
3 - Summarizing 정리
Setup
import openai
import os
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())
openai.api_key = os.getenv('OPENAI_API_KEY')
def get_completion(prompt, model="gpt-3.5-turbo"):
messages = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0, # this is the degree of randomness of the model's output
)
return response.choices[0].message["content"]
Summarizing
ex) 인기 식당의 매니저의 경우 배민 리뷰나 요기요 리뷰에 민감할 수 밖에 없다. 이런 상황에 하루 백 건 이상의 문의를 응대해야한다면 이 또한 상당히 시간이 걸리는 작업이 될 것이다. 이 경우 ChatGPT를 이용해 해결할 수 있다. 위의 배민 리뷰를 ChatGPT의 Prompt 조작을 통해 요약해보자.
먼저 Task를 정의.
1) Your task is to generate a short summary of a delivery service review from an food delivery app.
2) Summarize the review below, delimited by triple backticks, in at most 10 words.
3) translate in korean.
결과 정의.
<result format>
Review: ```{prod_review}```
prod_review = """
쟁반짜장과 삼선짬뽕을 시키려 했는데... 실수로 삼선짜장을 클릭했네요.
짜장을 2개 시키는 경우 많지 않을텐데...
제 실수이긴 하지만... 주문을 한 번 확인해 주시는 센스가 부족하네요 --;;;
그리고 군만두가 전혀 바삭하지 않고 미리 튀겨 놓은 거 주신 건지 많이 눅눅하네요
짜장은 그럭저럭 맛있었습니다.
"""
prompt = f"""
Your task is to generate a short summary of a delivery service review from an food delivery app.
Summarize the review below, delimited by triple backticks, in at most 10 words.
translate in korean.
Review: ```{prod_review}```
"""
response = get_completion(prompt)
print(response)
+ 추가로 맛과 배달 서비스의 퀄리티가 어떠한지 평가에 추가요청
1) Your task is to generate a short summary of a delivery service review from an food delivery app.
2) Summarize the review below, delimited by triple backticks, in at most 30 words, and focusing on any aspects that mention taste and satisfying and delivery of the food.
3) translate in korean.
결과 정의.
<result format>
Review: ```{prod_review}```
prompt = f"""
Your task is to generate a short summary of a delivery service review from an food delivery app.
Summarize the review below, delimited by triple backticks, in at most 30 words, and focusing on any aspects that mention taste and satisfying and delivery of the food.
translate in korean.
Review: ```{prod_review}```
"""
response = get_completion(prompt)
print(response)
배달의 민족의 악플 또한 판매자의 확인 부족으로 정확히 요약하는 것을 볼 수 있다.
'Tools > ChatGPT' 카테고리의 다른 글
[LLM] ChatGPT Prompt Engineering for Developers - Transforming (0) | 2023.05.05 |
---|---|
[LLM] ChatGPT Prompt Engineering for Developers - Inferring (0) | 2023.05.04 |
[LLM] ChatGPT Prompt Engineering for Developers - Iterative (0) | 2023.05.03 |
[LLM] ChatGPT Prompt Engineering for Developers - Guidelines (0) | 2023.05.02 |
[ChatGPT] ChatGPT + Iphone User Mode 공유 (0) | 2023.03.02 |