together.    First, beat the opioid epidemic.    ----------------------------------------------------------------------------------------------------    Document 4:    Tonight, I‚Äôm announcing a crackdown on these companies overcharging American businesses and consumers.    And as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up.    That ends on my watch.    Medicare is going to set higher standards for nursing homes and make sure your loved ones get the care they deserve and expect.    We‚Äôll also cut costs and keep the economy going strong by giving workers a fair shot, provide more training and apprenticeships, hire them based on their skills not degrees.    Let‚Äôs pass the Paycheck Fairness Act and paid leave.    Raise the minimum wage to $15 an hour and extend the Child Tax Credit, so no one has to raise a family in poverty.    Let‚Äôs increase Pell Grants and increase our historic support of HBCUs, and invest in what Jill‚Äîour First Lady who teaches full-time‚Äîcalls America‚Äôs best-kept secret: community colleges.Adding contextual compression with an LLMChainExtractor‚ÄãNow let's wrap our base retriever with a ContextualCompressionRetriever. We'll add an LLMChainExtractor, which will iterate over the initially returned documents and extract from each only the content that is relevant to the query.from langchain.llms import OpenAIfrom langchain.retrievers import ContextualCompressionRetrieverfrom langchain.retrievers.document_compressors import LLMChainExtractorllm = OpenAI(temperature=0)compressor = LLMChainExtractor.from_llm(llm)compression_retriever = ContextualCompressionRetriever(base_compressor=compressor, base_retriever=retriever)compressed_docs = compression_retriever.get_relevant_documents("What did the president say about Ketanji Jackson Brown")pretty_print_docs(compressed_docs)    Document 1:    "One of the most serious constitutional responsibilities a President has is nominating
One challenge with retrieval is that usually you don't know the specific queries your document storage system will face when you ingest data into the system. This means that the information most relevant to a query may be buried in a document with a lot of irrelevant text. Passing that full document through your application can lead to more expensive LLM calls and poorer responses.
One challenge with retrieval is that usually you don't know the specific queries your document storage system will face when you ingest data into the system. This means that the information most relevant to a query may be buried in a document with a lot of irrelevant text. Passing that full document through your application can lead to more expensive LLM calls and poorer responses. ->: together.    First, beat the opioid epidemic.    ----------------------------------------------------------------------------------------------------    Document 4:    Tonight, I‚Äôm announcing a crackdown on these companies overcharging American businesses and consumers.    And as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up.    That ends on my watch.    Medicare is going to set higher standards for nursing homes and make sure your loved ones get the care they deserve and expect.    We‚Äôll also cut costs and keep the economy going strong by giving workers a fair shot, provide more training and apprenticeships, hire them based on their skills not degrees.    Let‚Äôs pass the Paycheck Fairness Act and paid leave.    Raise the minimum wage to $15 an hour and extend the Child Tax Credit, so no one has to raise a family in poverty.    Let‚Äôs increase Pell Grants and increase our historic support of HBCUs, and invest in what Jill‚Äîour First Lady who teaches full-time‚Äîcalls America‚Äôs best-kept secret: community colleges.Adding contextual compression with an LLMChainExtractor‚ÄãNow let's wrap our base retriever with a ContextualCompressionRetriever. We'll add an LLMChainExtractor, which will iterate over the initially returned documents and extract from each only the content that is relevant to the query.from langchain.llms import OpenAIfrom langchain.retrievers import ContextualCompressionRetrieverfrom langchain.retrievers.document_compressors import LLMChainExtractorllm = OpenAI(temperature=0)compressor = LLMChainExtractor.from_llm(llm)compression_retriever = ContextualCompressionRetriever(base_compressor=compressor, base_retriever=retriever)compressed_docs = compression_retriever.get_relevant_documents("What did the president say about Ketanji Jackson Brown")pretty_print_docs(compressed_docs)    Document 1:    "One of the most serious constitutional responsibilities a President has is nominating