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 k to pinecone's "ask" functionality #297

Merged
merged 3 commits into from
Aug 21, 2023

Conversation

asmorris
Copy link
Contributor

We were running into an issue when asking a question of OpenAI using pinecone, where there were occasions where the context provided by the ask method was over the 4096 tokens, and so was exceeding the default OpenAI context window for question asking. This change would allow a user to add in an additional parameter k to the ask method, which could be subsequently passed to similarity_search to allow the user to have the amount of relevant results they wish, instead of defaulting to the 4 that is with similarity_search currently.

@@ -141,7 +141,7 @@ def similarity_search_by_vector(embedding:, k: 4, namespace: "", filter: nil)
# @param filter [String] The filter to use
# @yield [String] Stream responses back one String at a time
# @return [String] The answer to the question
def ask(question:, namespace: "", filter: nil, &block)
def ask(question:, namespace: "", filter: nil, k: 4, &block)
search_results = similarity_search(query: question, namespace: namespace, filter: filter)
Copy link
Collaborator

@andreibondarev andreibondarev Aug 21, 2023

Choose a reason for hiding this comment

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

I think you meant to also pass the k: param to the similarity_search(..., k: k)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 yes - absolutely did mean to do that. long day sorry.

@andreibondarev andreibondarev self-requested a review August 21, 2023 22:15
@andreibondarev andreibondarev merged commit 0874cba into patterns-ai-core:main Aug 21, 2023
5 checks passed
@andreibondarev
Copy link
Collaborator

@asmorris I wouldn't be opposed to adding the same param to all other vector search DBs if you feel like coding it up!

@asmorris
Copy link
Contributor Author

I wouldn't be opposed to adding the same param to all other vector search DBs if you feel like coding it up!

I can absolutely do that! Great idea

@asmorris asmorris mentioned this pull request Aug 22, 2023
@asmorris asmorris deleted the add-k-to-pinecone-ask branch August 22, 2023 02:12
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.

None yet

2 participants