The effect of knowledge base rag is very poor after multiple rounds of dialogue. #908

Closed
opened 2026-02-21 17:28:58 -05:00 by yindo · 2 comments
Owner

Originally created by @Sunwc0 on GitHub (Jan 15, 2024).

Self Checks

Provide a description of the help you need

The effect of knowledge base rag is very poor after multiple rounds of dialogue.

Originally created by @Sunwc0 on GitHub (Jan 15, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to file this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). ### Provide a description of the help you need The effect of knowledge base rag is very poor after multiple rounds of dialogue.
yindo added the 🐞 bug label 2026-02-21 17:28:58 -05:00
yindo closed this issue 2026-02-21 17:28:58 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 15, 2024):

🤖

Hello @Sunwc0! I'm Dosu, a friendly bot here to assist you with your Dify needs. I'm here to help answer questions, solve bugs, or guide you in contributing to our project. While we're waiting for a human maintainer, feel free to ask me anything regarding the dify repository. Let's get started!

To improve the performance of the knowledge base RAG after multiple rounds of dialogue in dify, you can consider several strategies:

  1. Increase the number of iterations: You can increase the max_iterations parameter in the AgentConfiguration setup. This allows the agent to iterate more times, potentially improving the quality of the results. However, this could also increase the execution time. The default value for max_iterations is 6, as seen in the agent_executor.py file.
agent_configuration = AgentConfiguration(
    strategy=planning_strategy,
    model_config=model_config,
    tools=dataset_retriever_tools,
    memory=memory,
    max_iterations=20,  # Increase this value
    max_execution_time=400.0,
    early_stopping_method="generate"
)
  1. Adjust the retrieval strategy: You can adjust the retrieval strategy in the to_dataset_retriever_tool method. If you're currently using the SINGLE strategy, you might want to consider switching to the MULTIPLE strategy, or vice versa. The MULTIPLE strategy can potentially provide more diverse results, while the SINGLE strategy might provide more focused results. This can be adjusted in the dataset_retrieval.py file.
if retrieve_config.retrieve_strategy == DatasetRetrieveConfigEntity.RetrieveStrategy.SINGLE:
    # SINGLE strategy code
elif retrieve_config.retrieve_strategy == DatasetRetrieveConfigEntity.RetrieveStrategy.MULTIPLE:
    # MULTIPLE strategy code
  1. Adjust the top_k parameter: You can adjust the top_k parameter in the retrieval model config. This parameter determines the number of top results to consider. Increasing this value could potentially improve the quality of the results, but it could also increase the execution time.
top_k = retrieval_model_config['top_k']  # Adjust this value
  1. Enable reranking: If it's not already enabled, you might want to consider enabling reranking. This can potentially improve the quality of the results by reranking them based on a different model.
'reranking_enable': True,  # Enable reranking

These are just suggestions, and the optimal configuration can depend on your specific use case and requirements. Always test different configurations to find the one that works best for you. If you need further assistance, feel free to ask.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot[bot] commented on GitHub (Jan 15, 2024): _🤖_ <!-- Greeting --> Hello @Sunwc0! I'm [Dosu](https://dosu.dev), a friendly bot here to assist you with your Dify needs. I'm here to help answer questions, solve bugs, or guide you in contributing to our project. While we're waiting for a human maintainer, feel free to ask me anything regarding the dify repository. Let's get started! <!-- Answer --> To improve the performance of the knowledge base RAG after multiple rounds of dialogue in dify, you can consider several strategies: 1. **Increase the number of iterations**: You can increase the `max_iterations` parameter in the `AgentConfiguration` setup. This allows the agent to iterate more times, potentially improving the quality of the results. However, this could also increase the execution time. The default value for `max_iterations` is 6, as seen in the [agent_executor.py](https://github.com/langgenius/dify/blob/main/api/core/agent/agent_executor.py) file. ```py agent_configuration = AgentConfiguration( strategy=planning_strategy, model_config=model_config, tools=dataset_retriever_tools, memory=memory, max_iterations=20, # Increase this value max_execution_time=400.0, early_stopping_method="generate" ) ``` 2. **Adjust the retrieval strategy**: You can adjust the retrieval strategy in the `to_dataset_retriever_tool` method. If you're currently using the `SINGLE` strategy, you might want to consider switching to the `MULTIPLE` strategy, or vice versa. The `MULTIPLE` strategy can potentially provide more diverse results, while the `SINGLE` strategy might provide more focused results. This can be adjusted in the [dataset_retrieval.py](https://github.com/langgenius/dify/blob/main/api/core/features/dataset_retrieval.py) file. ```py if retrieve_config.retrieve_strategy == DatasetRetrieveConfigEntity.RetrieveStrategy.SINGLE: # SINGLE strategy code elif retrieve_config.retrieve_strategy == DatasetRetrieveConfigEntity.RetrieveStrategy.MULTIPLE: # MULTIPLE strategy code ``` 3. **Adjust the top_k parameter**: You can adjust the `top_k` parameter in the retrieval model config. This parameter determines the number of top results to consider. Increasing this value could potentially improve the quality of the results, but it could also increase the execution time. ```py top_k = retrieval_model_config['top_k'] # Adjust this value ``` 4. **Enable reranking**: If it's not already enabled, you might want to consider enabling reranking. This can potentially improve the quality of the results by reranking them based on a different model. ```py 'reranking_enable': True, # Enable reranking ``` These are just suggestions, and the optimal configuration can depend on your specific use case and requirements. Always test different configurations to find the one that works best for you. If you need further assistance, feel free to ask. ## Sources - [api/core/features/dataset_retrieval.py](https://github.com/langgenius/dify/blob/main/api/core/features/dataset_retrieval.py) - [api/core/agent/agent_executor.py](https://github.com/langgenius/dify/blob/main/api/core/agent/agent_executor.py) --- This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
Author
Owner

@takatost commented on GitHub (Jan 15, 2024):

Can you share the details of how to reproduce the issue and deployed version?

@takatost commented on GitHub (Jan 15, 2024): Can you share the details of how to reproduce the issue and deployed version?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#908