Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- ChatGPT
- 일기
- Linear Regression
- 코테
- 기계학습
- 알고리즘
- Linear Model
- gradient descent
- NLP
- Django
- Deeplearning
- Programmers
- GPT
- machinelearning
- rnn
- prompt engineering
- 코딩테스트
- LLM
- LeetCode
- deque
- transformer
- 프로그래머스
- dl
- BFS
- 부스트캠프
- 머신러닝
- 프롬프트
- attention
- 파이썬
- Python
Archives
- Today
- Total
크크루쿠쿠
Prompt Engineering: PAL(Program-Aided Language Models) 본문
이 글은 https://github.com/dair-ai/Prompt-Engineering-Guide 를 공부하기 위해 제 입맛대로 번역한 글입니다
PAL(Program-Aided Language Models)
이 논문은 자연어 문제를 읽고 intermediate reasing steps로 program을 생성하기 위해 LLM을 사용하는 방법을 제시합니다.
PAL은 free-form text를 사용하는 CoT와는 다르게 python interpreter같은 programmatic runtime으로 해답 단계를 오프로드 합니다.
예시를 들어봅시다.
구체적으로 우리는 날짜에 대한 이해를 필요로하는 질문을 LLM에게 답하게 해봅시다. 우리는 아래와 같은 예시를 LLM에게 제공할겁니다.
llm = OpenAI(model_name='text-davinci-003', temperature=0)
question = "Today is 27 February 2023. I was born exactly 25 years ago. What is the date I was born in MM/DD/YYYY?"
DATE_UNDERSTANDING_PROMPT = """
# Q: 2015 is coming in 36 hours. What is the date one week from today in MM/DD/YYYY?
# If 2015 is coming in 36 hours, then today is 36 hours before.
today = datetime(2015, 1, 1) - relativedelta(hours=36)
# One week from today,
one_week_from_today = today + relativedelta(weeks=1)
# The answer formatted with %m/%d/%Y is
one_week_from_today.strftime('%m/%d/%Y')
# Q: The first day of 2019 is a Tuesday, and today is the first Monday of 2019. What is the date today in MM/DD/YYYY?
# If the first day of 2019 is a Tuesday, and today is the first Monday of 2019, then today is 6 days later.
today = datetime(2019, 1, 1) + relativedelta(days=6)
# The answer formatted with %m/%d/%Y is
today.strftime('%m/%d/%Y')
# Q: The concert was scheduled to be on 06/01/1943, but was delayed by one day to today. What is the date 10 days ago in MM/DD/YYYY?
# If the concert was scheduled to be on 06/01/1943, but was delayed by one day to today, then today is one day later.
today = datetime(1943, 6, 1) + relativedelta(days=1)
# 10 days ago,
ten_days_ago = today - relativedelta(days=10)
# The answer formatted with %m/%d/%Y is
ten_days_ago.strftime('%m/%d/%Y')
# Q: It is 4/19/1969 today. What is the date 24 hours later in MM/DD/YYYY?
# It is 4/19/1969 today.
today = datetime(1969, 4, 19)
# 24 hours later,
later = today + relativedelta(hours=24)
# The answer formatted with %m/%d/%Y is
today.strftime('%m/%d/%Y')
# Q: Jane thought today is 3/11/2002, but today is in fact Mar 12, which is 1 day later. What is the date 24 hours later in MM/DD/YYYY?
# If Jane thought today is 3/11/2002, but today is in fact Mar 12, then today is 3/1/2002.
today = datetime(2002, 3, 12)
# 24 hours later,
later = today + relativedelta(hours=24)
# The answer formatted with %m/%d/%Y is
later.strftime('%m/%d/%Y')
# Q: Jane was born on the last day of Feburary in 2001. Today is her 16-year-old birthday. What is the date yesterday in MM/DD/YYYY?
# If Jane was born on the last day of Feburary in 2001 and today is her 16-year-old birthday, then today is 16 years later.
today = datetime(2001, 2, 28) + relativedelta(years=16)
# Yesterday,
yesterday = today - relativedelta(days=1)
# The answer formatted with %m/%d/%Y is
yesterday.strftime('%m/%d/%Y')
# Q: {question}
""".strip() + '\n'
llm_out = llm(DATE_UNDERSTANDING_PROMPT.format(question=question))
print(llm_out)
exec(llm_out)
print(born)
우리는 결과로 02/27/1988로 잘 나오는 모습을 볼 수 있습니다.
'DeepLearning > 공부' 카테고리의 다른 글
Prompt Engineering Guide 3. Advanced Prompting (0) | 2023.05.04 |
---|---|
Prompt Engineering Guide 2. Basic Prompting (0) | 2023.05.02 |
Prompt Engineering Guide 1. Introduction (0) | 2023.03.27 |
NLP 01.Text Classification (0) | 2021.01.21 |
DL04. Linear Regression in the PyTorch way (0) | 2021.01.13 |
Comments