lighteval icon indicating copy to clipboard operation
lighteval copied to clipboard

Allow AdapterModels to have custom tokens

Open mapmeld opened this issue 1 year ago • 0 comments

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 checking config.tokenizer
  • the new tokenizer and base model will have a mismatched number of embeddings

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(...) before PeftModel.from_pretrained(base, adapter_weights) This is based on my fix for llm-evaluation-harness: https://github.com/EleutherAI/lm-evaluation-harness/pull/1828

Notes:

  • +1 please merge #298 (cherry-picked here), their one-line fix passed model_config_path to AdapterModel and this is necessary for most advanced models
  • opinion: I think that adapter_weights and delta_weights should be optional so I do not need delta_weights: false in my config

mapmeld avatar Sep 14 '24 03:09 mapmeld