-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement prompt/instruction templates #2439
Comments
This would be an important feature, as currently users of these models either miss out on the instruction features or have to use their own template to concatenate instruction+query to take advantage of it. For best results probably best to stick as closely as possible to the format used by the relevant model during training (including punctuation etc). E.g. BGE and Instructor seam to prepend the instruction. |
One option is to allow users to specify prompts with
|
We may also want to include some configuration options of whether the instruction must be included in the pooling output? For example, for INSTRUCTOR, these instructions are removed via attention masking when pooling.
|
Hi @tomaarsen, thanks for adding this new prompt feature in the library! I'm curious if there's a way to use prompt along with the evaluator. Currently, I only find examples by passing the prompt_name or prompt to model.encode, but all evaluators don't seem to take any prompt arguments, thus prohibiting evaluation on a full test set with the required prompts. |
Hello!
Context
This issue describes a feature that I am planning to be included in a release before v3, or alternatively, in v3 of Sentence Transformers.
Details
Many recent works, e.g. Wang et al., 2024, Li & Li, 2023, Xiao et al., 2023, and many more, use instructions/prompts to improve their model performance and instruct the models on the specific task at hand.
Ideally, Sentence Transformers should support this more easily by allowing prompt/instruction templates to be stored in the model configuration. For example, we could include the following two options in the configuration (e.g.
config_sentence_transformers.json
):And then the
SentenceTransformers.encode
method would also supportprompt
andprompt_name
arguments:I am still very unsure about the names of all of these arguments - I think they're not amazing. Additionally, I'm considering whether the prompt should include
{}
, which will be filled withprompt.format(text)
. This would allow"Classify this text: {}. That was all."
or something, but then the end of the text will be cut off in the case of truncation, which is not great.I'm definitely open to suggestions or ideas here!
cc @bwanglzu @ir2718 @johneckberg @aamir-s18 as I know you're interested in my TODO list.
cc @intfloat
The text was updated successfully, but these errors were encountered: