개발 이야기/[스터디] 프롬프트 엔지니어링
[Prompt Engineering Guide] 2. Techniques - (12) PAL (Program-Aided Language Models)
경이로운아일라
2024. 12. 19. 21:41
이 글은 <Prompt Engineering Guide>를 참고해 작성하였습니다.
2. Techniques - (12) PAL (Program-Aided Language Models)
PAL은 중간 추론 단계로 프로그램 코드를 생성하는 방법을 제안합니다.
다시, Chain of Thought 프롬프트의 경우, 모델이 어떻게 문제를 풀어나가야 하는지 자연어로 설명을 해주었다면,
Program-Aided Language Model의 경우 모델이 어떻게 문제를 풀어나가야 하는지 코드로 설명해주는 방식을 의미합니다.
이를 통해 모델은 답을 계산할 수 있는 코드를 출력하고, 코드를 실행한 결과물을 출력함으로써 모델이 올바른 답을 도출할 가능성을 높일 수 있습니다.
PAL 예시
기존 Chain-of-Thought Prompt 예시
# Prompt
Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?
A: Roger started with 5 tennis balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.
Q: The bakers at the Beverly Hills Bakery baked 200 loaves of bread on Monday morning. They sold 93 loaves in the morning and 39 loaves in the afternoon. A grocery store returned 6 unsold loaves. How many loaves of bread did they have left?
Program aided Language Models Prompt 예시
Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?
A: Roger started with 5 tennis balls.
tennis_balls = 5
2 cans of 3 tennis balls each is
bought_balls = 2 * 3
tennis ball. The answer is
answer = tennis_balls + bought_balls
Q: The bakers at the Beverly Hills Bakery baked 200 loaves of bread on Monday morning. They sold 93 loaves in the morning and 39 loaves in the afternoon. A grovery store returned 6 unsold loaves. How many loaves of bread did they have left?