most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.', metadata={'doc_id': '10e9cbc0-4ba5-4d79-a09b-c033d1ba7b01', 'source': '../../state_of_the_union.txt'})# Retriever returns larger chunkslen(retriever.get_relevant_documents("justice breyer")[0].page_content)    9874Summary‚ÄãOftentimes a summary may be able to distill more accurately what a chunk is about, leading to better retrieval. Here we show how to create summaries, and then embed those.from langchain.chat_models import ChatOpenAIfrom langchain.prompts import ChatPromptTemplatefrom langchain.schema.output_parser import StrOutputParserimport uuidfrom langchain.schema.document import Documentchain = (    {"doc": lambda x: x.page_content}    | ChatPromptTemplate.from_template("Summarize the following document:\n\n{doc}")    | ChatOpenAI(max_retries=0)    | StrOutputParser())summaries = chain.batch(docs, {"max_concurrency": 5})# The vectorstore to use to index the child chunksvectorstore = Chroma(    collection_name="summaries",    embedding_function=OpenAIEmbeddings())# The storage layer for the parent documentsstore = InMemoryStore()id_key = "doc_id"# The retriever (empty to start)retriever = MultiVectorRetriever(    vectorstore=vectorstore,     docstore=store,     id_key=id_key,)doc_ids = [str(uuid.uuid4()) for _ in docs]summary_docs = [Document(page_content=s,metadata={id_key: doc_ids[i]}) for i, s in enumerate(summaries)]retriever.vectorstore.add_documents(summary_docs)retriever.docstore.mset(list(zip(doc_ids, docs)))# # We can also add the original chunks to the vectorstore if we so want# for i, doc in enumerate(docs):#     doc.metadata[id_key] = doc_ids[i]# retriever.vectorstore.add_documents(docs)sub_docs = vectorstore.similarity_search("justice breyer")sub_docs[0]    Document(page_content="The document is a transcript of a speech given by the President of the United States. The President discusses several important issues and
It can often be beneficial to store multiple vectors per document. There are multiple use cases where this is beneficial. LangChain has a base MultiVectorRetriever which makes querying this type of setup easy. A lot of the complexity lies in how to create the multiple vectors per document. This notebook covers some of the common ways to create those vectors and use the MultiVectorRetriever.
It can often be beneficial to store multiple vectors per document. There are multiple use cases where this is beneficial. LangChain has a base MultiVectorRetriever which makes querying this type of setup easy. A lot of the complexity lies in how to create the multiple vectors per document. This notebook covers some of the common ways to create those vectors and use the MultiVectorRetriever. ->: most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.', metadata={'doc_id': '10e9cbc0-4ba5-4d79-a09b-c033d1ba7b01', 'source': '../../state_of_the_union.txt'})# Retriever returns larger chunkslen(retriever.get_relevant_documents("justice breyer")[0].page_content)    9874Summary‚ÄãOftentimes a summary may be able to distill more accurately what a chunk is about, leading to better retrieval. Here we show how to create summaries, and then embed those.from langchain.chat_models import ChatOpenAIfrom langchain.prompts import ChatPromptTemplatefrom langchain.schema.output_parser import StrOutputParserimport uuidfrom langchain.schema.document import Documentchain = (    {"doc": lambda x: x.page_content}    | ChatPromptTemplate.from_template("Summarize the following document:\n\n{doc}")    | ChatOpenAI(max_retries=0)    | StrOutputParser())summaries = chain.batch(docs, {"max_concurrency": 5})# The vectorstore to use to index the child chunksvectorstore = Chroma(    collection_name="summaries",    embedding_function=OpenAIEmbeddings())# The storage layer for the parent documentsstore = InMemoryStore()id_key = "doc_id"# The retriever (empty to start)retriever = MultiVectorRetriever(    vectorstore=vectorstore,     docstore=store,     id_key=id_key,)doc_ids = [str(uuid.uuid4()) for _ in docs]summary_docs = [Document(page_content=s,metadata={id_key: doc_ids[i]}) for i, s in enumerate(summaries)]retriever.vectorstore.add_documents(summary_docs)retriever.docstore.mset(list(zip(doc_ids, docs)))# # We can also add the original chunks to the vectorstore if we so want# for i, doc in enumerate(docs):#     doc.metadata[id_key] = doc_ids[i]# retriever.vectorstore.add_documents(docs)sub_docs = vectorstore.similarity_search("justice breyer")sub_docs[0]    Document(page_content="The document is a transcript of a speech given by the President of the United States. The President discusses several important issues and