Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何使用8bit model做inference #1462

Closed
tonyaw opened this issue Nov 10, 2023 · 7 comments
Closed

如何使用8bit model做inference #1462

tonyaw opened this issue Nov 10, 2023 · 7 comments
Labels
solved This problem has been already solved

Comments

@tonyaw
Copy link

tonyaw commented Nov 10, 2023

您好,我想把codellama的model做8bit的quantization,然后再用它做inference。
使用参数如下:
{
"stage": "sft",
"model_name_or_path": "/workspace/model/CodeLlama-34b-Instruct-hf",
"do_train": false,
"do_predict": true,
"dataset": "test_no_answer",
"template": "llama2",
"finetuning_type": "lora",
"quantization_bit": 8,
"bf16": true,
"lora_target": "all",
"output_dir": "/workspace/34b_baseline",
"cutoff_len": 16384,
"per_device_eval_batch_size": 1,
"max_samples": 100,
"predict_with_generate": true
}

遇到error:
File "/workspace/task_entry.py", line 30, in training_task
run_exp(args_dict)
File "/workspace/src/llmtuner/tuner/tune.py", line 65, in run_exp
run_sft(model_args, data_args, training_args, finetuning_args, generating_args, callbacks)
File "/workspace/src/llmtuner/tuner/sft/workflow.py", line 49, in run_sft
trainer = CustomSeq2SeqTrainer(
File "/usr/local/lib/python3.9/dist-packages/transformers/trainer_seq2seq.py", line 56, in init
super().init(
File "/usr/local/lib/python3.9/dist-packages/transformers/trainer.py", line 412, in init
raise ValueError(

Message:

You cannot perform fine-tuning on purely quantized models. Please attach trainable adapters on top of the quantized model to correctly perform fine-tuning. Please see: https://huggingface.co/docs/transformers/peft for more details

User error.

请问应该如何解决?
谢谢!

@hiyouga
Copy link
Owner

hiyouga commented Nov 10, 2023

安装 transformers==4.33.2

@hiyouga hiyouga added the solved This problem has been already solved label Nov 10, 2023
@hiyouga hiyouga closed this as completed Nov 10, 2023
@tonyaw
Copy link
Author

tonyaw commented Nov 13, 2023

请问这个要求是完全等于4.33.2,还是
transformers>=4.33.2?

@tonyaw
Copy link
Author

tonyaw commented Nov 13, 2023

且LlamaFactory的code需要update么?
我现在用的是大概两周前的snapshot。
如果需要更新,请问有个PR告诉我哪些需要改么?

@hiyouga
Copy link
Owner

hiyouga commented Nov 13, 2023

完全等于
你先试试

@tonyaw
Copy link
Author

tonyaw commented Nov 13, 2023

测试结果是:

  • 完全等于,没有问题。

  • 但是如果是大于等于,实际安装的是4.34.1,然后是同样的error。

这意味着以后不能再升级transformers了(暂时)?

@hiyouga
Copy link
Owner

hiyouga commented Nov 13, 2023

是的

@tonyaw
Copy link
Author

tonyaw commented Nov 15, 2023

您好,
我下了最新的code,又遇到这个error,发现requirements.txt:
transformers>=4.31.0,<4.35.0
请问为何不是transformers==4.33.2呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved This problem has been already solved
Projects
None yet
Development

No branches or pull requests

2 participants