Add a default "query" prompt for `model.encode_query`

#1
by tomaarsen HF Staff - opened

Hello!

Preface

First of all, congratulations on the big release! I'd be glad to help out with comms on the socials to help boost this as much as possible. I'm loving the look of the model (I saw the MTEB PR as well), the license is very valuable to the community, and the model is already very nicely integrated with Sentence Transformers and thus also LangChain, LlamaIndex, etc. etc.

Pull Request overview

  • Add a default "query" prompt for model.encode_query

Details

Since the Sentence Transformers v5.0.0 release, I've added encode_document and encode_query helper methods alongside encode, which are essentially shorthands for model.encode(..., prompt_name="query") (or "document") with a bit of checking if these prompts exist, so that third party libraries like LangChain or PydanticAI can rely on these methods directly for their retrieval-related inference. Because of that, I think it might be useful to additionally add a "query" prompt that just mirrors the "web_search_query". We don't have to update the README, but with this PR, model.encode_query(...) immediately uses a generic retrieval query instead of no query. It's still always recommended to use a custom prompt if you're not working with simple web search queries, at which point users can use e.g. model.encode_query(..., prompt="...") or model.encode(..., prompt="...") (they'll be equivalent).

Overall, this is a very minor change as you've done great with the integration already, nicely done!

  • Tom Aarsen
Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment