Allow AdapterModels to have custom tokens #306
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PEFT has a feature for adapters to add tokens to a model: https://github.com/huggingface/peft/blob/main/examples/causal_language_modeling/peft_lora_clm_with_additional_tokens.ipynb
When using an AdapterModel with new tokens in LightEval, the script fails because:
AdapterModel._create_auto_tokenizer
always uses the base model path, without checkingconfig.tokenizer
Notebook with error: https://colab.research.google.com/drive/1AMJ6_MiZGFTBf8KdRn-zj7soKyZrzpbf?usp=sharing
This PR would create the tokenizer from
config.tokenizer or config.base_model
and run
base.resize_token_embeddings(...)
beforePeftModel.from_pretrained(base, adapter_weights)
This is based on my fix for llm-evaluation-harness: EleutherAI/lm-evaluation-harness#1828
Notes:
You can't create a model without either a list of model_args or a model_config_path
when model_config_path was submited. #298 (cherry-picked here), their one-line fix passedmodel_config_path
to AdapterModel and this is necessary for most advanced modelsadapter_weights
anddelta_weights
should be optional so I do not needdelta_weights: false
in my config