Sub Question Query Engine

class llama_index.query_engine.sub_question_query_engine.SubQuestionQueryEngine(question_gen: BaseQuestionGenerator, response_synthesizer: ResponseSynthesizer, query_engine_tools: Sequence[QueryEngineTool], callback_manager: Optional[CallbackManager] = None, verbose: bool = True, use_async: bool = False)

Sub question query engine.

A query engine that breaks down a complex query (e.g. compare and contrast) into

many sub questions and their target query engine for execution. After executing all sub questions, all responses are gathered and sent to response synthesizer to produce the final response.

  • question_gen (BaseQuestionGenerator) – A module for generating sub questions given a complex question and tools.

  • response_synthesizer (ResponseSynthesizer) – A response synthesizer for generating the final response

  • query_engine_tools (Sequence[QueryEngineTool]) – Tools to answer the sub questions.

  • verbose (bool) – whether to print intermediate questions and answers. Defaults to True

  • use_async (bool) – whether to execute the sub questions with asyncio. Defaults to True