From the course: Prompt Engineering with LangChain

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Few-shot prompt templates

Few-shot prompt templates

- [Instructor] Earlier in the course, we talked about the ability of large language models to perform tasks with zero-shot prompting, meaning they've never seen this example before and they weren't specifically trained on that task. There's also a emergent ability in large language models called few-shot learning. So few-shot learning is just a form of in-context learning where in the prompt you're providing a few examples to help the language model perform on the tasks that you want it to. LangChain offers a FewShotPromptTemplate that's going to allow you to provide a few examples to prime the model before your main prompt. This is useful for providing relevant context and, quote, unquote, warming up the model on your task. So when do you want to use a FewShotPromptTemplate? Well, you want to use it if your task requires some background context to perform well. For example, summarization tasks often benefit from example summaries. If you want to bias the model towards a certain style…

Contents