is the director of Casino Royale?    Intermediate Answer: The director of Casino Royale is Martin Campbell.    Follow up: Where is Martin Campbell from?    Intermediate Answer: New Zealand.    So the final answer is: No    Question: Who was the father of Mary Ball Washington?Using an example selector‚ÄãFeed examples into ExampleSelector‚ÄãWe will reuse the example set and the formatter from the previous section. However, instead of feeding the examples directly into the FewShotPromptTemplate object, we will feed them into an ExampleSelector object.In this tutorial, we will use the SemanticSimilarityExampleSelector class. This class selects few-shot examples based on their similarity to the input. It uses an embedding model to compute the similarity between the input and the few-shot examples, as well as a vector store to perform the nearest neighbor search.from langchain.prompts.example_selector import SemanticSimilarityExampleSelectorfrom langchain.vectorstores import Chromafrom langchain.embeddings import OpenAIEmbeddingsexample_selector = SemanticSimilarityExampleSelector.from_examples(    # This is the list of examples available to select from.    examples,    # This is the embedding class used to produce embeddings which are used to measure semantic similarity.    OpenAIEmbeddings(),    # This is the VectorStore class that is used to store the embeddings and do a similarity search over.    Chroma,    # This is the number of examples to produce.    k=1)# Select the most similar example to the input.question = "Who was the father of Mary Ball Washington?"selected_examples = example_selector.select_examples({"question": question})print(f"Examples most similar to the input: {question}")for example in selected_examples:    print("\n")    for k, v in example.items():        print(f"{k}: {v}")    Running Chroma using direct local API.    Using DuckDB in-memory for database. Data will be transient.    Examples most similar to the input: Who was the father of Mary Ball
In this tutorial, we'll learn how to create a prompt template that uses few-shot examples. A few-shot prompt template can be constructed from either a set of examples, or from an Example Selector object.
In this tutorial, we'll learn how to create a prompt template that uses few-shot examples. A few-shot prompt template can be constructed from either a set of examples, or from an Example Selector object. ->: is the director of Casino Royale?    Intermediate Answer: The director of Casino Royale is Martin Campbell.    Follow up: Where is Martin Campbell from?    Intermediate Answer: New Zealand.    So the final answer is: No    Question: Who was the father of Mary Ball Washington?Using an example selector‚ÄãFeed examples into ExampleSelector‚ÄãWe will reuse the example set and the formatter from the previous section. However, instead of feeding the examples directly into the FewShotPromptTemplate object, we will feed them into an ExampleSelector object.In this tutorial, we will use the SemanticSimilarityExampleSelector class. This class selects few-shot examples based on their similarity to the input. It uses an embedding model to compute the similarity between the input and the few-shot examples, as well as a vector store to perform the nearest neighbor search.from langchain.prompts.example_selector import SemanticSimilarityExampleSelectorfrom langchain.vectorstores import Chromafrom langchain.embeddings import OpenAIEmbeddingsexample_selector = SemanticSimilarityExampleSelector.from_examples(    # This is the list of examples available to select from.    examples,    # This is the embedding class used to produce embeddings which are used to measure semantic similarity.    OpenAIEmbeddings(),    # This is the VectorStore class that is used to store the embeddings and do a similarity search over.    Chroma,    # This is the number of examples to produce.    k=1)# Select the most similar example to the input.question = "Who was the father of Mary Ball Washington?"selected_examples = example_selector.select_examples({"question": question})print(f"Examples most similar to the input: {question}")for example in selected_examples:    print("\n")    for k, v in example.items():        print(f"{k}: {v}")    Running Chroma using direct local API.    Using DuckDB in-memory for database. Data will be transient.    Examples most similar to the input: Who was the father of Mary Ball