From the course: Prompt Engineering with LangChain

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Length-based example selector

Length-based example selector

- [Instructor] One of the simplest ways to select examples for your prompt is by length. And so what we're going to see how to do in this video is use the length based example selector, which does what it says on the tin. It selects examples based on their length. This is useful for situations where you're worried about the total length of the constructed prompt, especially given the context limitations of some models. So we'll start by just importing the prompt template, as well as the few shot prompt template, and the length based example selector. We'll define our examples. We will define our example prompt, and then now we can use the length based example selector. So essentially, the primary goal of this selector is to adjust the number of examples included in the prompt based on the length of the input and the examples themselves. Again, this is useful when you're worried about the total length of the constructed prompt. So it works like this. When you're adding a new example…

Contents