Skip to content

Conversation

Forget-C
Copy link
Contributor

@Forget-C Forget-C commented Aug 14, 2025

Summary

The current combination knowledge base has the following issues:

  1. The combination knowledge base will create a new data table, which can still retrieve the removed data because the data table does not change when the source knowledge base is removed from sources.

  2. Multiple knowledge bases do not support result priority, which cannot reflect the importance of certain knowledge bases.

Make the following changes:

  1. Add a priority_score field to the Document object, used to sort documents by priority when multiple knowledge bases are involved.
  2. Adjust the CombinedKnowledgeBase, add create_table parameter. When create_table is False, the knowledge base priority takes effect.
  3. When the create parameter is set to False, a separate data table will not be created, but instead the data logic in the source knowledge base will be executed, and data will be aggregated during retrieval. Conversely, this is consistent with the current logic. The create parameter defaults to True to maintain logical consistency.
  4. Priority parameters affect the ranking of results from multiple knowledge bases, the final result of Document.priority_score is (reranking_score + reranking_score * priority) or priority, depending on whether the source knowledge base has enabled re-ranking.
  5. The following is an example of a priority declaration:
kb = CombinedKnowledgeBase(
        create_table=False,
        num_documents=1,
        sources=[
            {
                "source": kb_a,
                "priority": 0.5,
            },
            {
                "source": kb_b,
                "priority": 0,
            },
        ],
    )
  1. update the cookbook

I don't know how to update the document. If needed, please provide me with the update method, and I will update the document.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)

@Forget-C Forget-C requested a review from a team as a code owner August 14, 2025 12:21
@Forget-C Forget-C changed the title [feature] Enhance CombinedKnowledgeBase, support knowledge base priority [feat] Enhance CombinedKnowledgeBase, support knowledge base priority Aug 14, 2025
## Summary

1. Add a priority_score field to the Document object, used to sort documents by priority when multiple knowledge bases are involved.
2. Adjust the CombinedKnowledgeBase, add create_table parameter. When create_table is False, the knowledge base priority takes effect.
3. When the create parameter is set to False, a separate data table will not be created, but instead the data logic in the source knowledge base will be executed, and data will be aggregated during retrieval. Conversely, this is consistent with the current logic. The create parameter defaults to True to maintain logical consistency.
4. Priority parameters affect the ranking of results from multiple knowledge bases, the final result of Document.priority_score is reranking_score * priority or priority, depending on whether the source knowledge base has enabled re-ranking.
5. The following is an example of a priority declaration:
```python
kb = CombinedKnowledgeBase(
        create_table=False,
        num_documents=1,
        sources=[
            {
                "source": kb_a,
                "priority": 10,
            },
            {
                "source": kb_b,
                "priority": 1,
            },
        ],
    )
```

## Type of change

- [ ] Bug fix
- [x] New feature
- [ ] Breaking change
- [ ] Improvement
- [ ] Model update
- [ ] Other:

---

## Checklist

- [ ] Code complies with style guidelines
- [ ] Ran format/validation scripts (`./scripts/format.sh` and
`./scripts/validate.sh`)
- [x] Self-review completed
- [ ] Documentation updated (comments, docstrings)
- [ ] Examples and guides: Relevant cookbook examples have been included
or updated (if applicable)
- [x] Tested in clean environment
- [x] Tests added/updated (if applicable)
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.

1 participant