haystack-hybrid-embedding
Recently, Pinecone announced support for Sparse-dense embeddings, allowing for hybrid vector search (both semantic and keyword search).
haystack is a fantastic NLP framework that does not yet support hybrid vectors for Retrievers.
This little library helps temporarily bridge the gap!
Installation
$ pip install haystack-hybrid-embedding
Usage
from haystack_hybrid_embedding import SpladeEmbeddingEncoder
from haystack_hybrid_embedding.pinecone import PineconeHybridDocumentStore, SparseDenseRetriever
document_store = PineconeHybridDocumentStore(...)
retriever = SparseDenseRetriever(
sparse_encoder=SpladeEmbeddingEncoder(),
alpha=0.8,
...
)
Replacing EmbeddingRetriever
Simply replace your imports of PineconeDocumentStore and EmbeddingRetriever/MultihopEmbeddingRetriever.
1,2c1,3
< from haystack.document_stores.pinecone import PineconeDocumentStore
< from haystack.nodes import EmbeddingRetriever, MultihopEmbeddingRetriever
---
> from haystack_hybrid_embedding import SpladeEmbeddingEncoder
> from haystack_hybrid_embedding.pinecone import PineconeHybridDocumentStore, SparseDenseRetriever, SparseDenseMultihopRetriever
>
4c5
< document_store = PineconeDocumentStore(...)
---
> document_store = PineconeHybridDocumentStore(...)
6c7
< retriever = EmbeddingRetriever(
---
> retriever = SparseDenseRetriever(
7a9,10
> sparse_encoder=SpladeEmbeddingEncoder(),
> alpha=0.8,
Config
There are only two additional parameters exposed on SparseDenseRetriever over EmbeddingRetriever:
sparse_encoderembeds both queries and documents into sparse vectorsalphacontrols the weighting between the sparse and dense vectors (0is all sparse, and1is all dense)
Metadata
Release files for haystack-hybrid-embedding 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| haystack_hybrid_embedding-0.1.0.tar.gz | 3.5 kB | Without provenance | Details for haystack_hybrid_embedding-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| haystack_hybrid_embedding-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for haystack_hybrid_embedding-0.1.0-py3-none-any.whl |
Total release size: 8.8 kB
Release files / haystack_hybrid_embedding-0.1.0.tar.gz
| Download URL | haystack_hybrid_embedding-0.1.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec856acbfaf83f99bd93bf3430b190a8af4c73ac5dbcde6b5428ad8ab9bc40f4
|
|
BLAKE2b-256 checksum How to use checksums |
eba1d3d578594ddc882bc62b142a46855503a273c8bea9fc2b466301c1ad4a4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.9.15 Darwin/22.1.0
|
Release files / haystack_hybrid_embedding-0.1.0-py3-none-any.whl
| Download URL | haystack_hybrid_embedding-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a53edf9e185ac4150bbb33f30aeee99d6cbe82c1a5f9da25e86bca0d76cc316e
|
|
BLAKE2b-256 checksum How to use checksums |
47c017df5360ffe16c846c37d3a925987266cb1a5a1d0dbac6a86d6f754c3fde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.9.15 Darwin/22.1.0
|
Security for haystack-hybrid-embedding 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.