BaşlayınÜcretsiz Başlayın

Building the few-shot prompt template

With your examples in a structured format, it's now time to create the few-shot prompt template! You'll create a template that converts the question-answer pairs into the following format:

Question: Example question
Example Answer

All of the LangChain classes necessary for completing this exercise have been pre-loaded for you.

Bu egzersiz

Developing LLM Applications with LangChain

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Complete the prompt for formatting answers so it includes the question and answer keys.
  • Create the few-shot prompt using FewShotPromptTemplate with examples and example_prompt.
  • Complete the list of input variables based on the suffix provided.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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)
Kodu Düzenle ve Çalıştır