generates variants of the input question to improve retrieval.Max marginal relevance selects for relevance and diversity among the retrieved documents.Documents can be filtered during retrieval using metadata filters.import loggingfrom langchain.chat_models import ChatOpenAIfrom langchain.retrievers.multi_query import MultiQueryRetrieverlogging.basicConfig()logging.getLogger('langchain.retrievers.multi_query').setLevel(logging.INFO)retriever_from_llm = MultiQueryRetriever.from_llm(retriever=vectorstore.as_retriever(),                                                  llm=ChatOpenAI(temperature=0))unique_docs = retriever_from_llm.get_relevant_documents(query=question)len(unique_docs)In addition, a useful concept for improving retrieval is decoupling the documents from the embedded search key.For example, we can embed a document summary or question that are likely to lead to the document being retrieved.See details in here on the multi-vector retriever for this purpose.Step 5. Generate‚ÄãDistill the retrieved documents into an answer using an LLM/Chat model (e.g., gpt-3.5-turbo).We use the Runnable protocol to define the chain.Runnable protocol pipes together components in a transparent way.We used a prompt for RAG that is checked into the LangChain prompt hub (here).from langchain.chat_models import ChatOpenAIllm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)from langchain.schema.runnable import RunnablePassthroughrag_chain = (    {"context": retriever, "question": RunnablePassthrough()}     | rag_prompt     | llm )rag_chain.invoke("What is Task Decomposition?")    AIMessage(content='Task decomposition is the process of breaking down a task into smaller subgoals or steps. It can be done using simple prompting, task-specific instructions, or human inputs.')Go deeper‚ÄãChoosing LLMs‚ÄãBrowse the > 90 LLM and chat model integrations here.See further documentation on LLMs and chat models here.See a guide on local LLMS here.Customizing the prompt‚ÄãAs shown
Open In Colab
Open In Colab ->: generates variants of the input question to improve retrieval.Max marginal relevance selects for relevance and diversity among the retrieved documents.Documents can be filtered during retrieval using metadata filters.import loggingfrom langchain.chat_models import ChatOpenAIfrom langchain.retrievers.multi_query import MultiQueryRetrieverlogging.basicConfig()logging.getLogger('langchain.retrievers.multi_query').setLevel(logging.INFO)retriever_from_llm = MultiQueryRetriever.from_llm(retriever=vectorstore.as_retriever(),                                                  llm=ChatOpenAI(temperature=0))unique_docs = retriever_from_llm.get_relevant_documents(query=question)len(unique_docs)In addition, a useful concept for improving retrieval is decoupling the documents from the embedded search key.For example, we can embed a document summary or question that are likely to lead to the document being retrieved.See details in here on the multi-vector retriever for this purpose.Step 5. Generate‚ÄãDistill the retrieved documents into an answer using an LLM/Chat model (e.g., gpt-3.5-turbo).We use the Runnable protocol to define the chain.Runnable protocol pipes together components in a transparent way.We used a prompt for RAG that is checked into the LangChain prompt hub (here).from langchain.chat_models import ChatOpenAIllm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)from langchain.schema.runnable import RunnablePassthroughrag_chain = (    {"context": retriever, "question": RunnablePassthrough()}     | rag_prompt     | llm )rag_chain.invoke("What is Task Decomposition?")    AIMessage(content='Task decomposition is the process of breaking down a task into smaller subgoals or steps. It can be done using simple prompting, task-specific instructions, or human inputs.')Go deeper‚ÄãChoosing LLMs‚ÄãBrowse the > 90 LLM and chat model integrations here.See further documentation on LLMs and chat models here.See a guide on local LLMS here.Customizing the prompt‚ÄãAs shown