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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Allow for overriding pad_token_id #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

peterwilli
Copy link

@peterwilli peterwilli commented Dec 21, 2023

Description

Currently, the library selects eos when no pad token is defined in the tokenizer. This negatively impacts finetuning some Llama models such as Mistral-Instruct since it uses eos to end it's answer in a chat setting. I believe this is because when eos is a pad token, it'll be ignored (attention mask to 0) and the model might forget using eos as training progresses.

To fix this, we can now override the pad token with anything we wish. In my case, I have something like this:

config = Config(model_name_or_path="mistralai/Mistral-7B-Instruct-v0.2",
                tokenizer_padding_token="<unk>", # << Note this change
                apply_lora=True,
                lora_rank=2,
                neftune_noise_alpha=0.1,
                load_in_4bit=True,
                per_device_train_batch_size=2,
                gradient_accumulation_steps=4,
                prepare_model_for_kbit_training=True,
                llm_int8_threshold=6.0,
                llm_int8_has_fp16_weight=True,
                bnb_4bit_use_double_quant=True,
                bnb_4bit_quant_type="nf4",
                use_gradient_checkpointing=True,
                use_flash_attention_2=True)

This does not update the tokenizer of the final model, and I noticed positive results during inference compared to training without it. I hope this PR finds you well and thank you for such an awesome library, it's now my daily driver!

Type of Change

  • 馃摎 Examples / docs / tutorials / dependencies update
  • 馃敡 Bug fix (non-breaking change which fixes an issue)
  • 馃 Improvement (non-breaking change which improves an existing feature)
  • 馃殌 New feature (non-breaking change which adds functionality)
  • 馃挜 Breaking change (fix or feature that would cause existing functionality to change)
  • 馃攼 Security fix

Checklist

  • I've updated the code style using make codestyle.
  • I've written tests for all new methods and classes that I created.

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.

None yet

1 participant