You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def save_model(self, output_dir=None, _internal_call=False):
from transformers.trainer import TRAINING_ARGS_NAME
os.makedirs(output_dir, exist_ok=True)
torch.save(self.args, os.path.join(output_dir, TRAINING_ARGS_NAME))
saved_params = {
k: v.to("cuda:0") for k, v in self.model.named_parameters() if v.requires_grad
}
torch.save(saved_params, os.path.join(output_dir, "adapter_model.bin"))
完整的报错信息如下:
2024-06-18 11:58:33-train-INFO: 从dataset/huanhuan.json加载数据集成功
log_name: log.log
2024-06-18 11:58:33-train-INFO: 开始 LoRA 训练
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:08<00:00, 4.03s/it]
2024-06-18 11:58:41-train-INFO: 从deepseek-ai/deepseek-llm-7b-chat加载模型成功
2024-06-18 11:59:20-train-INFO: 加载 LoRA 参数成功
Found cached dataset generator (C:/Users/admin/.cache/huggingface/datasets/generator/default-d2f54e55ff33160c/0.0.0)
2024-06-18 11:59:20-train-INFO: 从dataset/huanhuan.json加载数据集成功
2024-06-18 11:59:20-train-INFO: 成功加载 Trainer
0%| | 0/1401 [00:00<?, ?it/s]Traceback (most recent call last):
File "D:\Pythonprojects\chat_test\deepseek_test2.py", line 376, in
main()
File "D:\Pythonprojects\chat_test\deepseek_test2.py", line 368, in main
trainer.train()
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\transformers\trainer.py", line 1885, in train
return inner_training_loop(
^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\transformers\trainer.py", line 2216, in _inner_training_loop
tr_loss_step = self.training_step(model, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\transformers\trainer.py", line 3238, in training_step
loss = self.compute_loss(model, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\deepseek_test2.py", line 156, in compute_loss
return model(
^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\peft\peft_model.py", line 922, in forward
return self.base_model(
^^^^^^^^^^^^^^^^
return self.base_model(
return self.base_model(
^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: LlamaModel.forward() got an unexpected keyword argument 'labels'
The text was updated successfully, but these errors were encountered:
transformers version: 4.41.2
Python version: 3.12
System: windows
class ModifiedTrainer(Trainer):
def compute_loss(self, model, inputs, return_outputs=False):
# 7B
# print(model)
# print(inputs)
return model(
input_ids=inputs["input_ids"],
labels=inputs["labels"]
).loss
log_name: log.log
2024-06-18 11:58:33-train-INFO: 开始 LoRA 训练
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:08<00:00, 4.03s/it]
2024-06-18 11:58:41-train-INFO: 从deepseek-ai/deepseek-llm-7b-chat加载模型成功
2024-06-18 11:59:20-train-INFO: 加载 LoRA 参数成功
Found cached dataset generator (C:/Users/admin/.cache/huggingface/datasets/generator/default-d2f54e55ff33160c/0.0.0)
2024-06-18 11:59:20-train-INFO: 从dataset/huanhuan.json加载数据集成功
2024-06-18 11:59:20-train-INFO: 成功加载 Trainer
0%| | 0/1401 [00:00<?, ?it/s]Traceback (most recent call last):
File "D:\Pythonprojects\chat_test\deepseek_test2.py", line 376, in
main()
File "D:\Pythonprojects\chat_test\deepseek_test2.py", line 368, in main
trainer.train()
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\transformers\trainer.py", line 1885, in train
return inner_training_loop(
^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\transformers\trainer.py", line 2216, in _inner_training_loop
tr_loss_step = self.training_step(model, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\transformers\trainer.py", line 3238, in training_step
loss = self.compute_loss(model, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\deepseek_test2.py", line 156, in compute_loss
return model(
^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\peft\peft_model.py", line 922, in forward
return self.base_model(
^^^^^^^^^^^^^^^^
return self.base_model(
return self.base_model(
^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Pythonprojects\chat_test\venv\Lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: LlamaModel.forward() got an unexpected keyword argument 'labels'
The text was updated successfully, but these errors were encountered: