Add Sentence Transformers usage

#1
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, alongside its existing PyLate usage. This PR adds a Sentence Transformers usage section to the model card, and I would also love to feature GLInt in the accompanying ST documentation. The weights and the existing files are untouched.

Heads up, this PR was AI-generated and human-reviewed.

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

model = MultiVectorEncoder("chungimungi/GLInt")

query = "Which planet is known as the Red Planet?"
documents = [
    "Venus is often called Earth's twin because of its similar size and proximity.",
    "Mars, known for its reddish appearance, is often referred to as the Red Planet.",
    "Jupiter, the largest planet in our solar system, has a prominent red spot.",
    "Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
]

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

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

Verified against PyLate itself on the snippet above: the token embeddings match on every one of the five sequences (per-token cosine 1.000000, maximum absolute deviation 3e-07) and the MaxSim scores match to full float precision. Everything your config_sentence_transformers.json pins carries over, including the three Dense projections with their residual connections, the [Q] /[D] prefixes, the punctuation skiplist and query expansion being off. For reference, loaded through this integration the model scores 0.6914 mean nDCG@10 on NanoBEIR, the best of the 32 text late interaction models I have run through that evaluation so far (LateOn-regularized is next at 0.6897).

Happy to tweak anything you'd like changed. Please let me know if you have any questions or feedback!

  • Tom Aarsen
tomaarsen changed pull request status to open
chungimungi changed pull request status to merged

Sign up or log in to comment