반응형
DeepLearning.AI 강의 ChatGPT Prompt Engineering for Developers - Expanding 요약
https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/
ChatGPT Prompt Engineering for Developers
What you’ll learn in this course In ChatGPT Prompt Engineering for Developers, you will learn how to use a large language model (LLM) to quickly build new and powerful applications. Using the OpenAI API, you’ll...
www.deeplearning.ai
모델의 입력 파라미터인 temperature를 사용하여 탐색의 정도와 다양성을 모델의 응답에 적용
temperature가 0일 시 모델은 항상 가장 가능성이 높은 다음 단어를 선택
temperature가 높아질 수록 가능성이 덜 높은 단어 중 하나를 선택
def get_completion(prompt, model="gpt-3.5-turbo",temperature=0): # Andrew mentioned that the prompt/ completion paradigm is preferable for this class
messages = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=temperature, # this is the degree of randomness of the model's output
)
return response.choices[0].message["content"]
자동 응답 커스터마이징
prompt = f"""
You are a customer service AI assistant.
Your task is to send an email reply to a valued customer.
Given the customer email delimited by ```, \
Generate a reply to thank the customer for their review.
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 service.
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}
"""
response = get_completion(prompt)
print(response)
자동 응답 시 받은 텍스트의 세부 사항을 활용할 것을 지시
prompt = f"""
You are a customer service AI assistant.
Your task is to send an email reply to a valued customer.
Given the customer email delimited by ```, \
Generate a reply to thank the customer for their review.
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 service.
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}
"""
response = get_completion(prompt, temperature=0.7)
print(response)
반응형
'Data Science > Prompt Engineering' 카테고리의 다른 글
ChatGPT API - 1. ChatGPT 기반 서비스의 유형 분류 (0) | 2023.12.04 |
---|---|
ChatGPT Prompt Engineering for Developers - (8) Chatbot (1) | 2023.11.08 |
ChatGPT Prompt Engineering for Developers - (6) Transforming (0) | 2023.11.08 |
ChatGPT Prompt Engineering for Developers - (5) Inferring (0) | 2023.11.08 |
ChatGPT Prompt Engineering for Developers - (4) Summarizing (0) | 2023.11.07 |