Skip to content

Commit

Permalink
Merge pull request #2945 from marko1616/bugfix/lora-model-merge
Browse files Browse the repository at this point in the history
修复了在 transformers > 4.36.2 版本中部分模型合并 Lora 模型时因生成配置校验而导致的崩溃问题
  • Loading branch information
hiyouga authored Mar 25, 2024
2 parents 140ad4a + c8f0d99 commit 49f9dbb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/llmtuner/train/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ def export_model(args: Optional[Dict[str, Any]] = None):
for param in model.parameters():
param.data = param.data.to(output_dtype)

# Configuration check and fix
config = model.generation_config
if not config.do_sample and (
(config.temperature is not None and config.temperature != 1.0) or
(config.top_p is not None and config.top_p != 1.0) or
(config.typical_p is not None and config.typical_p != 1.0)
):
config.do_sample = True

model.save_pretrained(
save_directory=model_args.export_dir,
max_shard_size="{}GB".format(model_args.export_size),
Expand Down

0 comments on commit 49f9dbb

Please sign in to comment.