Few-shot 프롬프트 템플릿 만들기
이제 예시가 구조화된 형식으로 준비되었으니, few-shot 프롬프트 템플릿을 만들어 볼 차례예요! 질문-답변 쌍을 다음 형식으로 변환하는 템플릿을 작성해 주세요:
Question: Example question
Example Answer
이 연습 문제를 완료하는 데 필요한 LangChain 클래스는 모두 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
LangChain으로 LLM 애플리케이션 개발하기
연습 안내
- 답변을 서식화하는 프롬프트를 완성해
question과answer키가 모두 포함되도록 하세요. FewShotPromptTemplate에examples와example_prompt를 사용해 few-shot 프롬프트를 생성하세요.- 제공된 suffix를 기준으로 입력 변수 목록을 완성하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Complete the prompt for formatting answers
example_prompt = PromptTemplate.from_template("Question: {____}\n{____}")
# Create the few-shot prompt
prompt_template = ____(
examples=____,
example_prompt=____,
suffix="Question: {input}",
input_variables=["____"],
)
prompt = prompt_template.invoke({"input": "What is Jack's favorite technology on DataCamp?"})
print(prompt.text)