我所使用的代码仓库是LLaMA-Factoryhiyouga/LLaMA-Factory: Easy-to-use LLM fine-tuning framework (LLaMA, BLOOM, Mistral, Baichuan, Qwen, ChatGLM) (github.com)https://github.com/hiyouga/LLaMA-Factory/tree/main

A.解决问题推荐两个查询网址,在issue中查询:Issues · hiyouga/LLaMA-Factory (github.com)Issues · hiyouga/LLaMA-Factory (github.com)

和Issues · baichuan-inc/Baichuan2 (github.com)

B.baichuan-7B-chat模型下载到本地可以使用国内镜像,代码如下,cache_dir字段设置本地路径:

import os

import torch

import torch as torch

from modelscope import snapshot_download, AutoModelForCausalLM, AutoTokenizer, GenerationConfig

model_dir = snapshot_download("baichuan-inc/Baichuan2-7B-Chat", revision='v1.0.4', cache_dir='Base_LLMs')

tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto",

trust_remote_code=True, torch_dtype=torch.float16)

model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto",

trust_remote_code=True, torch_dtype=torch.float16)

参考:百川2-7B-对话模型 · 模型库 (modelscope.cn)

1.报错:     raise NotImplementedError(f"Loading a dataset cached in a {type(self._fs).__name__} is not supported.") NotImplementedError: Loading a dataset cached in a LocalFileSystem is not supported.

解决办法:

pip install fsspec==2023.9.2

2.报错:

ValueError: Target modules ['q_proj', 'v_proj'] not found in the base model. Please check the target modules and try again.

我的配置是:

CUDA_VISIBLE_DEVICES=0 python src/train_bash.py \

--stage sft \

--model_name_or_path ./Base_LLMs/baichuan-inc/Baichuan2-7B-Chat \

--do_train \

--dataset jjxq \

--template baichuan2 \

--finetuning_type lora \

--lora_target q_proj,v_proj \

--output_dir ./new_baichuan_test \

--overwrite_cache \

--per_device_train_batch_size 1 \

--gradient_accumulation_steps 8 \

--quantization_bit 4 \

--lr_scheduler_type cosine \

--logging_steps 10 \

--save_steps 1000 \

--learning_rate 5e-5 \

--num_train_epochs 3.0 \

--plot_loss \

--fp16

解决办法:将 --lora_target q_proj,v_proj \改为

--lora_target q_proj,v_proj,W_pack \

还可参考下面链接中说明的各种模型参数:

LLaMA-Factory/README_zh.md at main · hiyouga/LLaMA-Factory (github.com)https://github.com/hiyouga/LLaMA-Factory/blob/main/README_zh.md#%E6%A8%A1%E5%9E%8B

3.报错:TypeError: sdp_kernel() got an unexpected keyword argument 'enable_mem_efficient'

解决办法:好像是torch版本的问题,2.0以上就没有问题了,pip install torch==2.0.1

或者pip install xformers -i https://pypi.tuna.tsinghua.edu.cn/simple,不加镜像我安装时这个包下载的很慢,也挺大的,注意加镜像。

可参考:Baichuan2-7B-Chat执行推理报错TypeError: sdp_kernel() got an unexpected keyword argument 'enable_mem_efficient' · Issue #111 · baichuan-inc/Baichuan2 (github.com)https://github.com/baichuan-inc/Baichuan2/issues/111

4.报错:在pip install xformers时遇到OSError: [Errno 28] No space left on device,经过一番研究,似乎由于多种原因而发生此错误。 有时是磁盘空间问题,有时是因为文件数量问题。 在这种情况下,似乎是因为容量。

$ df -h

df -h显示/盘空间用尽

解决办法:将其放在一个空间尚充足的目录(我设为了home下的一个自建目录),就可以顺利安装了,如下:

$ mkdir $HOME/tmp

$ export TMPDIR=$HOME/tmp

export TMPDIR=$HOME/tmp 该命令指定 tmp 目录。 此规范是临时的,在会话关闭时将被丢弃。

也可以扩容ubuntu–vg-ubuntu–lv,参考下面链接:Linux /dev/mapper/ubuntu–vg-ubuntu–lv磁盘满了 - 知乎 (zhihu.com)

推荐链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: