= docsearch.get_relevant_documents(query)from langchain.chains.question_answering import load_qa_chainfrom langchain.llms import OpenAIQuickstart‚ÄãIf you just want to get started as quickly as possible, this is the recommended way to do it:chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff")query = "What did the president say about Justice Breyer"chain.run(input_documents=docs, question=query)    ' The president said that Justice Breyer has dedicated his life to serve the country and thanked him for his service.'If you want more control and understanding over what is happening, please see the information below.The stuff Chain‚ÄãThis sections shows results of using the stuff Chain to do question answering.chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff")query = "What did the president say about Justice Breyer"chain({"input_documents": docs, "question": query}, return_only_outputs=True)    {'output_text': ' The president said that Justice Breyer has dedicated his life to serve the country and thanked him for his service.'}Custom PromptsYou can also use your own prompts with this chain. In this example, we will respond in Italian.prompt_template = """Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.{context}Question: {question}Answer in Italian:"""PROMPT = PromptTemplate(    template=prompt_template, input_variables=["context", "question"])chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff", prompt=PROMPT)chain({"input_documents": docs, "question": query}, return_only_outputs=True)    {'output_text': ' Il presidente ha detto che Justice Breyer ha dedicato la sua vita a servire questo paese e ha ricevuto una vasta gamma di supporto.'}The map_reduce Chain‚ÄãThis sections shows results of using the map_reduce Chain to do question answering.chain = load_qa_chain(OpenAI(temperature=0), chain_type="map_reduce")query = "What
Here we walk through how to use LangChain for question answering over a list of documents. Under the hood we'll be using our Document chains.
Here we walk through how to use LangChain for question answering over a list of documents. Under the hood we'll be using our Document chains. ->: = docsearch.get_relevant_documents(query)from langchain.chains.question_answering import load_qa_chainfrom langchain.llms import OpenAIQuickstart‚ÄãIf you just want to get started as quickly as possible, this is the recommended way to do it:chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff")query = "What did the president say about Justice Breyer"chain.run(input_documents=docs, question=query)    ' The president said that Justice Breyer has dedicated his life to serve the country and thanked him for his service.'If you want more control and understanding over what is happening, please see the information below.The stuff Chain‚ÄãThis sections shows results of using the stuff Chain to do question answering.chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff")query = "What did the president say about Justice Breyer"chain({"input_documents": docs, "question": query}, return_only_outputs=True)    {'output_text': ' The president said that Justice Breyer has dedicated his life to serve the country and thanked him for his service.'}Custom PromptsYou can also use your own prompts with this chain. In this example, we will respond in Italian.prompt_template = """Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.{context}Question: {question}Answer in Italian:"""PROMPT = PromptTemplate(    template=prompt_template, input_variables=["context", "question"])chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff", prompt=PROMPT)chain({"input_documents": docs, "question": query}, return_only_outputs=True)    {'output_text': ' Il presidente ha detto che Justice Breyer ha dedicato la sua vita a servire questo paese e ha ricevuto una vasta gamma di supporto.'}The map_reduce Chain‚ÄãThis sections shows results of using the map_reduce Chain to do question answering.chain = load_qa_chain(OpenAI(temperature=0), chain_type="map_reduce")query = "What