Update the Sentence Transformers section for the v6.0.1 prefix fix

#2
by tomaarsen HF Staff - opened

Hello again!

A correction to the Sentence Transformers section I added in #1, and an apology for the trouble.

Your checkpoints pair the [Q] /[D] markers with the search_query: /search_document: prompts. PyLate applies both, but Sentence Transformers v6.0.0 applied only the prompts and silently dropped the markers, so encode_query rendered [CLS]search_query: ... where PyLate renders [CLS][Q] search_query: ..., one token short. That was a bug on my side, not in your configuration. It is fixed for v6.0.1, and the two paths are now token-for-token identical again (per-token cosine 1.000000 against PyLate, on queries and documents).

This PR updates the section for the corrected behaviour. The snippet's shapes and scores were captured under the old behaviour and no longer reproduce, so they are refreshed, and the install line moves to >=6.0.1 because that is the first release where the snippet is correct.

Worth reporting the size of it, since your card is right that prompt alignment is not negotiable. On NanoBEIR the missing markers cost 0.0256 nDCG@10, 0.6569 before against 0.6824 after, and the ColBERT-Zero row in my documentation moves up accordingly. Your "Prompt Alignment Is Non-Negotiable" section turned out to apply to the markers just as much as to the prompts.

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

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

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

I am opening matching sections on ColBERT-Zero-supervised and ColBERT-Zero-unsupervised, which were affected the same way and had not been integrated yet.

The config also gains a requirements block pinning sentence-transformers>=6.0.1. Sentence Transformers reads it at load time and fails with a clear message rather than letting an older install return the wrong embeddings silently, which is what happens today.

To try this before merging, pass revision="refs/pr/2" to MultiVectorEncoder.

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
ameliechatelain changed pull request status to merged

Sign up or log in to comment