-
Notifications
You must be signed in to change notification settings - Fork 500
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
实现了baichuan-7B模型的LoRA微调 #23
Comments
牛逼,好快啊 |
牛逼 |
大佬太强了 |
有微调数据集格式吗? |
@GalSang17 项目自带了,点进data文件夹就可以看示例格式。 |
谢谢! |
赞👍🏻 |
@hiyouga 没有出现这个错误吗?
|
@bytes-lost 完整的报错信息是什么?哪一行代码导致的? |
|
@bytes-lost 应该是数组越界了,我在加载 tokenizer 时手动将 pad_token_id 设置为了 0,检查一下你那边有没有设置。输入序列中不能有大于等于 64000 的值。 |
@hiyouga
|
@bytes-lost 看起来是 torch 的 checkpointing 过程出现了问题,可能和本地的 torch 以及 CUDA 环境有关,我这边测试了好几遍都没有问题。 |
好的,我重新创建环境测测看,torch=2.0.1版本是可以的吗? |
@gebilaoman 用项目自带 cli_demo 启动时请添加 |
好快的速度,好猛 |
我这边也实现了baichuan-7b 的lora微调,baichuan模型的结构跟llama一致,它的SFT微调方法跟bloom/llama基本一致的。 支持baichuan-7b微调项目地址:https://github.com/shibing624/MedicalGPT 该项目还实现了GPT模型训练,包括二次预训练、有监督微调、奖励建模、强化学习训练。 运行以下指令即可实现 belle 数据集指令微调(instruction-tuning):
欢迎大家测试,验证效果。 |
我同样的问题tokenizer.pad_token_id = 0 之后就可以了 |
不是 ChatGLM 的代码,是 LLAMA 那一份。https://github.com/hiyouga/LLaMA-Efficient-Tuning |
能实现多轮对话的微调吗,具体多轮对话的数据格式能不能演示一下谢谢 |
@hiyouga |
@cristianohello 因为我微调时候用的是 ziya 的 template😁 |
@hiyouga |
@cristianohello 目前的 SFT 模型没有进行多轮对话训练,所以多轮时候偶尔会出现问题。 |
好吧,对比了些别的指引,启动加了参数--lora_target W_pack 就可以正常启动了。。。 |
@xiaoningli92 你用的是谁的代码? |
Alpaca Lora的代码 https://github.com/tloen/alpaca-lora |
跑成功了,但是没有diff出哪里的问题,想问下Baichuan 的Lora微调相比Llama,需要做哪些特殊配置吗? |
@hiyouga 微调完后,推理后出现重复回答。请问大概知道什么原因吗? |
可以看下你微调的 loss 曲线吗? |
@bytes-lost 您好,请问这个问题解决了吗? 我这边也是碰到同样的问题,在推理环节报错数组越界 |
我也想问这个问题,能否在微调之后利用最新得到的模型参数进行二次微调,有大佬指教吗? |
你好,请问一下为什么我多卡微调会报错?RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1! (when checking argument for argument index in method wrapper_CUDA__index_select) 作者说多卡跑需要使用deepspeed,但是具体我不太明白,可以指教一下吗? |
lib/python3.10/site-packages/transformers/hf_argparser.py", line 347, in parse_args_into_dataclasses 出现这个--dev_ratio 的错误,这是怎么回事? @hiyouga |
@warkcod 改为 --val_size |
可以了,谢谢 |
您好,请问出现 |
@Elllllllvin use transformers==4.33.2 |
谢谢这个问题解决了,但是显存爆了。torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 820.00 MiB. GPU 0 has a total capacty of 31.74 GiB of which 33.38 MiB is free. Process 10596 has 31.70 GiB memory in use. Of the allocated memory 30.19 GiB is allocated by PyTorch, and 638.01 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF 我使用的指令为: |
--per_device_train_batch_size 4
--gradient_accumulation_steps 8
都往下降试试
***@***.***
发件人: Elllllllvin
发送时间: 2023-10-18 17:07
收件人: baichuan-inc/Baichuan-7B
抄送: grantchenhuarong; Comment
主题: Re: [baichuan-inc/Baichuan-7B] 实现了baichuan-7B模型的LoRA微调 (Issue #23)
@Elllllllvin use transformers==4.33.2
谢谢这个问题解决了,但是显存爆了。torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 820.00 MiB. GPU 0 has a total capacty of 31.74 GiB of which 33.38 MiB is free. Process 10596 has 31.70 GiB memory in use. Of the allocated memory 30.19 GiB is allocated by PyTorch, and 638.01 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
0%|▏ | 8/4530 [01:12<11:24:57, 9.09s/it]
请问不是说12G就够了吗?有些迷惑,希望大佬解惑。
我使用的指令为:
CUDA_VISIBLE_DEVICES=0 python src/train_bash.py
--stage sft
--model_name_or_path /home/jovyan/models/baichuan-7b
--do_train
--dataset alpaca_gpt4_zh
--template baichuan
--finetuning_type lora
--lora_rank 8
--lora_target W_pack
--val_size 0.01
--output_dir alpaca_baichuan
--per_device_train_batch_size 4
--per_device_eval_batch_size 4
--gradient_accumulation_steps 8
--lr_scheduler_type cosine
--logging_steps 10
--save_steps 100
--eval_steps 100
--learning_rate 5e-5
--max_grad_norm 0.5
--num_train_epochs 3.0
--evaluation_strategy steps
--load_best_model_at_end
--plot_loss
--fp16
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
12G 是使用 4bit 量化后的占用量 |
推理的时候是不是没有用对应的模版? |
hi, have you fixed this problem? |
|
CUDA_VISIBLE_DEVICES=0 python src/train_bash.py |
@zhangyun-w 去掉这三个参数,改为 --cutoff_len 512 |
谢谢,明天试试 CUDA_VISIBLE_DEVICES=0 python src/train_bash.py |
@hiyouga 这个怎么解决呢? |
@zhangyun-w pip install -U huggingface_hub |
@hiyouga 你好,我使用transformers==4.33.2的时候会报下面的错误,应该是需要升级transformers, 我试了4.34,4.35和4.36,都会报错。请问这个问题该怎么解决呢? |
支持Alpaca等指令数据集的SFT和RLHF流程:https://github.com/hiyouga/LLaMA-Efficient-Tuning
LoRA微调可在单块3090 GPU上运行,同时支持QLoRA方法。(最低12G显存)
微调模型的 LoRA 权重:https://huggingface.co/hiyouga/baichuan-7b-sft
运行以下指令即可实现 Alpaca 数据集指令微调(instruction-tuning):
程序运行截图示例:
经过LoRA指令微调后的对话效果:
The text was updated successfully, but these errors were encountered: