728x90

 

 

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

 

ChatGPT Prompt Engineering for Developers 

 

6 - Expanding  ์ •๋ฆฌ

 

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",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"]

 

Expanding 

1) ๊ณ ๊ฐ ๋ฆฌ๋ทฐ ์ž๋™์‘๋‹ต  

์ฃผ์–ด์ง„ Sentiment(๊ฐ์ • positive/negative)์„ ํ™œ์šฉํ•˜์—ฌ ๊ณ ๊ฐ ๋ฆฌ๋ทฐ ์ž‘์„ฑ

 

<prompt task>

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`.

translate in korean.

 

Customer review: ```{review}```

Review sentiment: {sentiment}

 

 

 

+ Model์˜ Exploration(์ž์œ ๋„) Expanding  / Temperature Randomness

Temperature๋ฅผ ๋†’์—ฌ ํŠน์ • ํ‚ค์›Œ๋“œ์— ๋Œ€ํ•œ ์–ธ๊ธ‰ ๋นˆ๋„๋ฅผ ๋žœ๋ค์„ฑ์œผ๋กœ ์ถ”๊ฐ€ํ•œ๋‹ค. 

 

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`.
translate in korean.
Customer review: ```{review}```
Review sentiment: {sentiment}
"""
response = get_completion(prompt, temperature=0.7)
print(response)

 

 

temperature = 0.7
temperature = 1.0

 

Temperature์˜ ์ •๋„์— ๋”ฐ๋ผ ๊ฐ™์€ parameter๋ผ๋„ ๋‹ค๋ฅธ ๊ฐ’์ด ๋‚˜์˜ค๋Š” ๊ฒƒ์„ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

temperature = 1.0

๋ฐ˜์‘ํ˜•
๋‹คํ–ˆ๋‹ค