Az örnekli (few-shot) istem şablonu oluşturma
Örneklerini yapılandırılmış bir biçime getirdiğine göre, şimdi az örnekli istem şablonunu oluşturma zamanı! Soru-cevap çiftlerini aşağıdaki biçime dönüştüren bir şablon oluşturacaksın:
Question: Example question
Example Answer
Bu egzersizi tamamlamak için gereken tüm LangChain sınıfları senin için önceden yüklendi.
Bu egzersiz
LangChain ile LLM Uygulamaları Geliştirme
kursunun bir parçasıdırEgzersiz talimatları
- Yanıtları biçimlendiren istemi
questionveansweranahtarlarını içerecek şekilde tamamla. FewShotPromptTemplatekullanarakexamplesveexample_promptile az örnekli istemi oluştur.- Verilen soneye (suffix) göre giriş değişkenleri listesini tamamla.
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)