Self-consistency 프롬프트
여러분이 노트북과 모바일폰을 판매하는 가게를 운영한다고 가정해 봅시다. 아침에 가게에는 기기가 50대 있고, 그중 60%가 모바일폰입니다. 하루 동안 손님 세 분이 방문했고, 각자 모바일폰을 한 대씩 구매했으며, 그중 한 분은 노트북도 추가로 한 대 구매했습니다. 또한 재고에 노트북 10대와 모바일폰 5대를 추가했습니다. 하루가 끝날 때 노트북과 모바일폰은 각각 몇 대가 되나요? 이 문제는 problem_to_solve 문자열에 정의되어 있으며, self-consistency 프롬프트를 사용해 해결할 것입니다.
OpenAI 패키지와 get_response() 함수는 미리 로드되어 있습니다.
이 연습 문제에서 get_response() 함수는 실행 속도를 높이기 위해 max_tokens 파라미터를 사용합니다.
이 연습은 강의의 일부입니다
OpenAI API로 배우는 프롬프트 엔지니어링
연습 안내
- 세 명의 전문가가 문제를 풀고, 다수결로 결과를 결합하도록 하는
self_consistency_instruction을 만드세요. self_consistency_instruction과problem_to_solve를 결합해 최종prompt를 만드세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
client = OpenAI(api_key="")
# Create the self_consistency instruction
self_consistency_instruction = ____
# Create the problem to solve
problem_to_solve = "If you own a store that sells laptops and mobile phones. You start your day with 50 devices in the store, out of which 60% are mobile phones. Throughout the day, three clients visited the store, each of them bought one mobile phone, and one of them bought additionally a laptop. Also, you added to your collection 10 laptops and 5 mobile phones. How many laptops and mobile phones do you have by the end of the day?"
# Create the final prompt
prompt = ____
response = get_response(prompt)
print(response)