Sentence Similarity
Safetensors
Japanese
RAGatouille
bert
ColBERT

Add Sentence Transformers usage

#3
by tomaarsen HF Staff - opened

Hello!

As of Sentence Transformers v6.0.0, this checkpoint loads directly as a multi-vector (ColBERT-style late interaction) retriever through the new MultiVectorEncoder. This PR adds a Sentence Transformers usage section to the model card and the multi-vector and sentence-transformers tags. The weights and the existing usage are untouched.

pip install "sentence-transformers>=6.0.0" fugashi unidic-lite
from sentence_transformers import MultiVectorEncoder

model = MultiVectorEncoder("bclavie/JaColBERTv2")

query = "日本で一番高い山は何ですか?"
documents = [
    "富士山は日本で最も高い山で、標高は3776メートルです。",
    "東京は日本の首都で、世界最大の都市圏の一つです。",
]

query_embeddings = model.encode_query(query)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings[0].shape)
# torch.Size([32, 128]) torch.Size([21, 128])

# MaxSim late-interaction scoring (higher is more relevant)
scores = model.similarity(query_embeddings, document_embeddings)
print(scores)
# tensor([[29.9530, 16.4604]], device='cuda:0')

Verified against a PyLate reference: the snippet reproduces exactly, and the token embeddings match with per-token cosine similarity above 0.999 and matching MaxSim scores.

  • Tom Aarsen
tomaarsen changed pull request status to open
Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment