复制原模型的tokenizer_config.json文件到新模型下,覆盖新模型的这个文件
;
而后报错:
def load_model_and_tokenizer(model_dir: Union[str, Path]) -> tuple[Mode │ │ 28 │ model_dir = _resolve_path(model_dir) │ │ 29 │ if (model_dir / 'adapter_config.json').exists(): │ │ ❱ 30 │ │ model = AutoPeftModelForCausalLM.from_pretrained( │ │ 31 │ │ │ model_dir, trust_remote_code=True, device_map='auto' │ │ 32 │ │ ) │ │ 33 │ │ tokenizer_dir = model.peft_config['default'].base_model_name_or │ │ │ │ /home/dell/anaconda3/envs/llm3/lib/python3.11/site-packages/peft/auto.py:126 │ │ in from_pretrained
解决方法:
peft-0.7.1
而后又报错:
) │ │ 33 │ │ tokenizer_dir = model.peft_config['default'].base_model_name_or │ │ │ │ /home/dell/anaconda3/envs/llm3/lib/python3.11/site-packages/peft/auto.py:69 │ │ in from_pretrained │ │ │
...
│ 139 │ │ │ 140 │ @classmethod │ ╰──────────────────────────────────────────────────────────────────────────────╯ TypeError: LoraConfig.__init__() got an unexpected keyword argument 'use_dora'
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
解决思路:
peft 包: 训练时与推理时版本不一致
peft->0.7.1 ,然后训练,再推理试试看
另外:
# training_args: Seq2SeqTrainingArguments = dc.field(
# default=Seq2SeqTrainingArguments(output_dir='./output')
# )
代码改为如下代码:
training_args: Seq2SeqTrainingArguments = dc.field(
default_factory=Seq2SeqTrainingArguments
)
结果:pass ,ok