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 HybridRecordEncoder #265

Merged
merged 9 commits into from Jan 29, 2024
Merged

Conversation

izellevy
Copy link
Collaborator

@izellevy izellevy commented Jan 23, 2024

Problem

We don't have support for Hybrid Search in canopy.

Solution

Adds a new HybridRecordEncoder that uses the given dense encoder and the BM25 sparse encoder for
hybrid search purposes.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

Added relevant tests.

Copy link
Contributor

@acatav acatav left a comment

Choose a reason for hiding this comment

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

LGTM, see my small comments

src/canopy/knowledge_base/record_encoder/hybrid.py Outdated Show resolved Hide resolved
tests/unit/record_encoder/test_hybrid_record_encoder.py Outdated Show resolved Hide resolved
src/canopy/knowledge_base/record_encoder/hybrid.py Outdated Show resolved Hide resolved
src/canopy/knowledge_base/record_encoder/hybrid.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@igiloh-pinecone igiloh-pinecone left a comment

Choose a reason for hiding this comment

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

One more change.

(And one suggestion, that can be deferred to a separate PR)

src/canopy/knowledge_base/knowledge_base.py Show resolved Hide resolved
src/canopy/knowledge_base/record_encoder/hybrid.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@igiloh-pinecone igiloh-pinecone left a comment

Choose a reason for hiding this comment

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

@izellevy see a few last comments about unit tests

**kwargs: Additional arguments to pass to the RecordEncoder.
""" # noqa: E501

if not 0 < alpha <= 1:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably add an explicit error message for alpha==0, saying "sparse only not supported"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

tests/unit/record_encoder/test_hybrid_record_encoder.py Outdated Show resolved Hide resolved
tests/unit/record_encoder/test_hybrid_record_encoder.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@igiloh-pinecone igiloh-pinecone left a comment

Choose a reason for hiding this comment

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

LGTM

@izellevy izellevy added this pull request to the merge queue Jan 29, 2024
Merged via the queue into pinecone-io:main with commit 444804b Jan 29, 2024
7 checks passed
@izellevy izellevy deleted the feature/hybrid_support branch January 29, 2024 10:24
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

3 participants