[pytorch] pytorch_model.bin 和 training_args.bin 的区别

pytorch_model.bin 和 training_args.bin 是与 PyTorch 框架和训练过程相关的两个文件。

  1. pytorch_model.bin: 这是保存了 PyTorch 模型的二进制文件。在使用 PyTorch 进行深度学习训练时,经过训练的模型会被保存为这个文件,其中包含了模型的权重参数。这个文件可以被加载到 PyTorch 中,以便进行推理、评估或继续训练。

  2. training_args.bin: 这是保存了训练参数的二进制文件。在使用 PyTorch 进行训练时,可以使用一个包含了各种训练参数的对象(通常是一个命名元组或类实例)来配置训练过程。training_args.bin 文件保存了这些训练参数,包括学习率、优化器类型、训练批次大小、训练时的超参数等等。当需要重新加载模型进行训练或进行进一步的微调时,这个文件可以用来还原训练参数的配置。

综上所述,pytorch_model.bin 包含了经过训练的模型的权重参数,而 training_args.bin 则包含了训练模型时使用的各种训练参数的配置信息。这两个文件在训练和推理过程中都具有重要的作用。

[WARNING|logging.py:329] 2025-03-04 21:16:20,919 >> Unsloth: Dropout = 0 is supported for fast patching. You are using dropout = 0.01. Unsloth will patch all other layers, except LoRA matrices, causing a performance hit. Unsloth: Offloading input_embeddings to disk to save VRAM Traceback (most recent call last): File "/root/miniconda3/bin/llamafactory-cli", line 8, in <module> sys.exit(main()) ^^^^^^ File "/root/autodl-tmp/ai/LLaMA-Factory/src/llamafactory/cli.py", line 112, in main run_exp() File "/root/autodl-tmp/ai/LLaMA-Factory/src/llamafactory/train/tuner.py", line 93, in run_exp _training_function(config={"args": args, "callbacks": callbacks}) File "/root/autodl-tmp/ai/LLaMA-Factory/src/llamafactory/train/tuner.py", line 67, in _training_function run_sft(model_args, data_args, training_args, finetuning_args, generating_args, callbacks) File "/root/autodl-tmp/ai/LLaMA-Factory/src/llamafactory/train/sft/workflow.py", line 52, in run_sft model = load_model(tokenizer, model_args, finetuning_args, training_args.do_train) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/ai/LLaMA-Factory/src/llamafactory/model/loader.py", line 169, in load_model model = init_adapter(config, model, model_args, finetuning_args, is_trainable) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/ai/LLaMA-Factory/src/llamafactory/model/adapter.py", line 299, in init_adapter model = _setup_lora_tuning( ^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/ai/LLaMA-Factory/src/llamafactory/model/adapter.py", line 235, in _setup_lora_tuning model = get_unsloth_peft_model(model, model_args, peft_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/ai/LLaMA-Factory/src/llamafactory/model/model_utils/unsloth.py", line 79, in get_unsloth_peft_model return FastLanguageModel.get_peft_model(**peft_kwargs, **unsloth_peft_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda3/lib/python3.12/site-packages/unsloth/models/llama.py", line 2377, in get_peft_model offload_input_embeddings(model, temporary_location) File "/root/miniconda3/lib/python3.12/site-packages/unsloth/models/_utils.py", line 767, in offload_input_embeddings offloaded_W = offload_to_disk(model.get_input_embeddings(), model, "input_embeddings", temporary_location) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda3/lib/python3.12/site-packages/unsloth/models/_utils.py", line 760, in offload_to_disk offloaded_W = torch.load(filename, map_location = "cpu", mmap = True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda3/lib/python3.12/site-packages/torch/serialization.py", line 1470, in load raise pickle.UnpicklingError(_get_wo_message(str(e))) from None _pickle.UnpicklingError: Weights only load failed. In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source. Please file an issue with the following so that we can make `weights_only=True` compatible with your use case: WeightsUnpickler error: Unsupported operand 149 Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

心心喵

喵喵(*^▽^*)

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值