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

Add top_k Support for Tree Collapsing Functionality #12

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

parthsarthi03
Copy link
Owner

This PR introduces the top_k parameter to the retrieve_information_collapse_tree method in the TreeRetriever class. It allows users to control the number of top nodes to consider when retrieving information from the collapsed tree.

Usage:

  • The top_k parameter is an integer that specifies the number of top nodes to consider during retrieval.
  • It defaults to 10 if not provided, meaning the method will consider the top 10 most relevant nodes.
  • Users can adjust the value of top_k to retrieve more or fewer nodes based on their requirements.

Functionality:

  • The retrieve_information_collapse_tree method retrieves the most relevant information from the collapsed tree based on the given query.
  • It uses the max_tokens parameter to limit the maximum number of tokens in the retrieved context, defaulting to 3500 tokens.
  • The method calculates the distances between the query embedding and the node embeddings to determine the most relevant nodes.
  • It then iterates over the top top_k nodes, adding them to the selected nodes list until the token limit is reached.
  • it returns the selected nodes and the retrieved context.

@salman-abdullah
Copy link
Collaborator

Looks good to me!

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.

2 participants