Skip to content
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

[feat] Add option to mask prompts with left-padded tokenizer and corpus and query prompts to IREvaluator #2951

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ArthurCamara
Copy link
Contributor

Most models, specially based on Mistral, are trained with left-padding in the tokenizer, instead of the common right-padding when evaluating. (e.g., LLM2Vec), but this is not covered in the current prompt_length strategy.
Currently, If a batch with mismatched lengths is left-padded, the masking will mostly mask out padding tokens. This PR fixes that by adding a mask_prompt argument to the tokenize function. When this flag is set, the code tries to find the first non-padding token in each sentence, and will mask everything between that and prompt_length, adding a prompt_mask representation to the output dictionary.

Perhaps a more "elegant" solution would be to replace prompt_length entirely, but this could break Instructor models.

@ArthurCamara ArthurCamara marked this pull request as draft September 23, 2024 09:01
@ArthurCamara ArthurCamara changed the title [feat] Add option to mask prompts with left-padded tokenizer [feat] Add option to mask prompts with left-padded tokenizer and corpus and query prompts to IREvaluator Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant