From the course: Prompt Engineering with LangChain

Unlock the full course today

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

Introduction to example selectors

Introduction to example selectors

- [Instructor] Example selectors in LangChain are classes that are responsible for selecting which examples to include in a prompt. They're useful when you have a large number of examples available, but need to select a subset of them to include in your prompt. Some key things to know about example selectors is that they implement a select_examples method, which takes in the input variables and returns a list of examples to include in the prompt. There are several different strategies for selecting examples. For example, you can select based on semantic similarity to the input, you can select based on maximal marginal relevance, so you can balance similarity and diversity using that. Or you can select based on prompt length. Example selectors allow prompts to dynamically choose examples based on the inputs rather than having fixed examples. They help you manage long prompts by only including the most relevant examples for the given inputs. New example selectors can be implemented…

Contents