tomaarsen HF Staff commited on
Commit
b00b50f
·
verified ·
1 Parent(s): 21996dc

Add Sentence Transformers usage

Browse files
Files changed (1) hide show
  1. README.md +35 -0
README.md CHANGED
@@ -3,6 +3,7 @@ language:
3
  - en
4
  tags:
5
  - ColBERT
 
6
  - PyLate
7
  - sentence-transformers
8
  - sentence-similarity
@@ -783,6 +784,40 @@ This model is a lightweight, 17 million parameter ColBERT with a projection dime
783
 
784
  ## Usage
785
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
786
  To use this model, you first need to install PyLate:
787
 
788
  via uv
 
3
  - en
4
  tags:
5
  - ColBERT
6
+ - multi-vector
7
  - PyLate
8
  - sentence-transformers
9
  - sentence-similarity
 
784
 
785
  ## Usage
786
 
787
+ ### Sentence Transformers
788
+
789
+ This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
790
+
791
+ ```bash
792
+ pip install "sentence-transformers>=6.0.0"
793
+ ```
794
+
795
+ ```python
796
+ from sentence_transformers import MultiVectorEncoder
797
+
798
+ model = MultiVectorEncoder("mixedbread-ai/mxbai-edge-colbert-v0-17m")
799
+
800
+ query = "Which planet is known as the Red Planet?"
801
+ documents = [
802
+ "Venus is often called Earth's twin because of its similar size and proximity.",
803
+ "Mars, known for its reddish appearance, is often referred to as the Red Planet.",
804
+ "Jupiter, the largest planet in our solar system, has a prominent red spot.",
805
+ "Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
806
+ ]
807
+
808
+ query_embeddings = model.encode_query(query)
809
+ document_embeddings = model.encode_document(documents)
810
+ print(query_embeddings.shape, document_embeddings[0].shape)
811
+ # (12, 48) (18, 48)
812
+
813
+ # MaxSim late-interaction scoring (higher is more relevant)
814
+ scores = model.similarity(query_embeddings, document_embeddings)
815
+ print(scores)
816
+ # tensor([[11.5693, 11.7584, 11.7099, 11.7229]])
817
+ ```
818
+
819
+ ### PyLate
820
+
821
  To use this model, you first need to install PyLate:
822
 
823
  via uv