DeepLearning.AI에서 챗 지피티 프롬프트 엔지니어링에 대한 1시간 짜리 무료 강의 영상을 공개했다.
DLAI - ChatGpt Prompt Engineering for Developers
강의 영상은 1시간의 짧은 시간으로 구성되어 있다.
LLM을 활용한 대표 사례들을 짧게 만들어보고 최적의 prompt를 작성하기 위한 가이드라인 등을 배울 수 있다.
openai의 api 콜을 마음껏 할 수 있도록 환경 세팅을 설정 해주며
실습을 할 수 있는 주피터 노트북 파일과 강의 영상이 제공된다.
최근 prompt만 잘 작성하는 것 만으로도 모델을 fine tuning한 것과 같은 효과를 낼 수 있다는 연구들이 나오면서 "프롬프트 엔지니어링"이 화두이다.
few shot learning이나 chain of thought 등의 기법이 공개되어 활용되고 있지만 그 외에는 어떻게 프롬프트를 튜닝할지 막막했는데, chat gpt를 만들어낸 openai에서 공식적으로 만들어낸 강의인 만큼 코스를 수강하면 오피셜한 prompt 엔지니어링 기법들을 습득할 수 있게 되었다!
또한 파이썬과 LLM에 대한 기본적인 이해도만 있다면 누구나 수강할 수 있다.
다만 모든 강의는 영어로 진행되며 자막도 영어 자막만 제공된다.
또한 prompt 예시들이 전부 영어 텍스트이기 때문에
한국어 NLP Task로 적용시킬 때는 얼마나 효과적으로 영어 프롬프트 예시 format을 활용할지 고려해봐야 한다.
다행인 점은 GPT-4는 한국어도 잘한다는 점! Technical Report
🍕 마지막으로 강의에 소개된 피자 주문 챗봇 예시를 가볍게 소개하며 ... 🍕
def collect_messages(_):
prompt = inp.value_input
inp.value = ''
context.append({'role':'user', 'content':f"{prompt}"})
response = get_completion_from_messages(context)
context.append({'role':'assistant', 'content':f"{response}"})
panels.append(
pn.Row('User:', pn.pane.Markdown(prompt, width=600)))
panels.append(
pn.Row('Assistant:', pn.pane.Markdown(response, width=600, style={'background-color': '#F6F6F6'})))
return pn.Column(*panels)
import panel as pn # GUI
pn.extension()
panels = [] # collect display
context = [ {'role':'system', 'content':"""
You are OrderBot, an automated service to collect orders for a pizza restaurant. \
You first greet the customer, then collects the order, \
and then asks if it's a pickup or delivery. \
You wait to collect the entire order, then summarize it and check for a final \
time if the customer wants to add anything else. \
If it's a delivery, you ask for an address. \
Finally you collect the payment.\
Make sure to clarify all options, extras and sizes to uniquely \
identify the item from the menu.\
You respond in a short, very conversational friendly style. \
The menu includes \
pepperoni pizza 12.95, 10.00, 7.00 \
cheese pizza 10.95, 9.25, 6.50 \
eggplant pizza 11.95, 9.75, 6.75 \
fries 4.50, 3.50 \
greek salad 7.25 \
Toppings: \
extra cheese 2.00, \
mushrooms 1.50 \
sausage 3.00 \
canadian bacon 3.50 \
AI sauce 1.50 \
peppers 1.00 \
Drinks: \
coke 3.00, 2.00, 1.00 \
sprite 3.00, 2.00, 1.00 \
bottled water 5.00 \
모든 대답은 한국어로 대답합니다.
"""} ] # 예시 prompt에서 마지막 한 줄만 추가해줬다.
inp = pn.widgets.TextInput(value="Hi", placeholder='Enter text here…')
button_conversation = pn.widgets.Button(name="Chat!")
interactive_conversation = pn.bind(collect_messages, button_conversation)
dashboard = pn.Column(
inp,
pn.Row(button_conversation),
pn.panel(interactive_conversation, loading_indicator=True, height=300),
)
dashboard
멋진 피자 주문 챗봇을 5분만에 손쉽게 만들 수 있다!
prompt를 한국어 버전으로 조금 더 정성스럽게 수정하고 약간의 condition을 제공해주면 더 자연스러운 대화도 가능할 것이다!