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

Make prepending of bos token configurable. #1114

Merged
merged 4 commits into from
Dec 20, 2023

Conversation

pacman100
Copy link
Contributor

What does this PR do?

  1. Tokenization using chat template doesn't add special tokens such as bos_token by default. https://github.com/huggingface/transformers/blob/17506d1256c1780efc9e2a5898a828c10ad4ea69/src/transformers/tokenization_utils_base.py#L1750
  2. Related issue elsewhere: "/v1/chat/completions" tokenization issue vllm-project/vllm#2012
  3. This leads to redundant bos/special tokens being added by the tokenizer in SFT training here:

tokenized_inputs = self.tokenizer(buffer, truncation=False)["input_ids"]

This PR makes it configurable while retaining backwards compatibility.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

pacman100 and others added 2 commits December 20, 2023 15:13
Co-Authored-By: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
@younesbelkada younesbelkada merged commit f2acd82 into huggingface:main Dec 20, 2023
9 checks passed
@pacman100 pacman100 deleted the smangrul/bos-token-fix branch December 20, 2023 11:02
lapp0 pushed a commit to lapp0/trl that referenced this pull request May 10, 2024
* make prepending of bos token configurable.

* address comments

* fix bug

Co-Authored-By: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>

* Update trl/trainer/sft_trainer.py

Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>

---------

Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
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.

3 participants