Find answers from the community

Updated 3 months ago

custom prompt to better control the decomposition

I'm currently exploring the capabilities of the SubQuestionQueryEngine and its potential, and was wondering how I can use a custom prompt to better control the decomposition of complex queries into subqueries. Could you guide me on how to define and integrate a custom prompt for this purpose? Thanks!
A
W
2 comments
@Logan M @WhiteFang_Jr will this be possible to set a custom prompt for SubQuestionQueryEngine ? Thanks
SubQuestionQueryEngine uses prompt for generating sub questions , if you want to change the prompt for generating the sub questions you can do it this way:

CHeck both the generator code: https://github.com/run-llama/llama_index/tree/main/llama-index-integrations/question_gen


They have a default prompt that they use to generate queries, modify that and create the object of question generator and pass it in the subquestion engine:

Plain Text
question_gen = OpenAIQuestionGenerator.from_defaults(prompt_template_str="ADD_HERE"...)

# add it to SubQ
query_engine = SubQuestionQueryEngine.from_defaults(
    query_engine_tools=query_engine_tools,
    use_async=True,
    question_gen=question_gen
)
Add a reply
Sign up and join the conversation on Discord