Langchain.
documents. Extract from each documents only the context that is relevant to the query. from langchain.retrievers import ContextualCompressionRetriever from langchain.retrievers.document_compressors import LLMChainExtractor #making the compressor compressor = LLMChainExtractor.from_llm(llm=llm)