Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve prompt for question decomposition + show more docs #3960

Closed

Conversation

joachim-danswer
Copy link
Contributor

@joachim-danswer joachim-danswer commented Feb 11, 2025

Description

The goal is A) to change the prompts to create better sub-questions, and B) to show also some of the context docs even if they were not cited.

For A) At the core, two main changes were made:

  1. The decomposition prompt is explicitly instructed not to generate follow-up questions to the user. All
    sub-questions need to be search-type questions

  2. The refinement sub-questions should have the ability to see the initial sub-answers to possibly refer to the
    results. Foe this, the prompts for both the initial and the refinement a sub-question generation need to be
    changed. (The initial prompt needs to know that it could be valuable to generate for example a question that gives us the competitors to a company A, so that then the refined subquestion could reference the competitors by name for
    searches.)
    Also, the node generating the LLM request to create the refined sub-questions had to change.

For B)

  • cited and context docs are now generated from the sub_question results, not relying on state.cited_documents, etc
  • The set of streamed docs is augmented by context docs.

How Has This Been Tested?

Locally, for some individual questions. No examples yet for sub-questions whose answers are used in refinement questions.
(More testing will follow.)

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ❌ Failed (Inspect) Feb 11, 2025 3:09am

@joachim-danswer joachim-danswer changed the title Improve prompt for question decomposition Improve prompt for question decomposition + show more docs Feb 11, 2025
Copy link
Contributor

@evan-danswer evan-danswer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor nits

question=question,
history=history,
entity_term_extraction_str=entity_term_extraction_str,
base_answer=base_answer,
answered_sub_questions="\n - ".join(addressed_question_list),
# answered_sub_questions="\n - ".join(addressed_question_list),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete commented code

question=question,
history=history,
entity_term_extraction_str=entity_term_extraction_str,
base_answer=base_answer,
answered_sub_questions="\n - ".join(addressed_question_list),
# answered_sub_questions="\n - ".join(addressed_question_list),
answered_subquestions_with_answers="\n\n---\n\n".join(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want a string constant here so it's easy to change across the board later

"""
# Start with relevant docs or fallback to original question docs
streaming_documents = (
relevant_docs if relevant_docs else original_question_docs[:15]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 15 should be a constant defined somewhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relevant_docs or ...

@evan-danswer evan-danswer force-pushed the agent-search-feature-decomp-prompt-change-v2 branch from a55b95f to 7fa453a Compare February 11, 2025 03:06
@@ -72,8 +72,14 @@ def create_refined_sub_questions(

initial_question_answers = state.sub_question_results

addressed_question_list = [
x.question for x in initial_question_answers if x.verified_high_quality
# addressed_question_list = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

@evan-danswer
Copy link
Contributor

rolled into #3994

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants