mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-08-03 20:22:49 +08:00
Merge pull request #2945 from marko1616/bugfix/lora-model-merge
修复了在 transformers > 4.36.2 版本中部分模型合并 Lora 模型时因生成配置校验而导致的崩溃问题 Former-commit-id: 49f9dbb4b168b0e9f72e2233271aca130fca55e7
This commit is contained in:
commit
abbbdae903
@ -64,6 +64,15 @@ def export_model(args: Optional[Dict[str, Any]] = None):
|
|||||||
for param in model.parameters():
|
for param in model.parameters():
|
||||||
param.data = param.data.to(output_dtype)
|
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(
|
model.save_pretrained(
|
||||||
save_directory=model_args.export_dir,
|
save_directory=model_args.export_dir,
|
||||||
max_shard_size="{}GB".format(model_args.export_size),
|
max_shard_size="{}GB".format(model_args.export_size),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user