Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
Baichuan_pytorch
Commits
907320eb
Commit
907320eb
authored
Nov 10, 2023
by
zhaoying1
Browse files
update
parent
257399d8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
54 deletions
+22
-54
Dockerfile
Dockerfile
+1
-1
README.md
README.md
+20
-51
run-full.sh
run-full.sh
+0
-1
src/llmtuner/hparams/__pycache__/data_args.cpython-38.pyc
src/llmtuner/hparams/__pycache__/data_args.cpython-38.pyc
+0
-0
src/llmtuner/hparams/data_args.py
src/llmtuner/hparams/data_args.py
+1
-1
No files found.
Dockerfile
View file @
907320eb
...
@@ -3,4 +3,4 @@ COPY requirements.txt requirements.txt
...
@@ -3,4 +3,4 @@ COPY requirements.txt requirements.txt
RUN
source
/opt/dtk-23.04/env.sh
RUN
source
/opt/dtk-23.04/env.sh
RUN
cp
/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
echo
'Asia/Shanghai'
>
/etc/timezone
RUN
cp
/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
echo
'Asia/Shanghai'
>
/etc/timezone
ENV
LANG C.UTF-8
ENV
LANG C.UTF-8
RUN
pip
install
-r
requirements.txt
--no-dependencies
-i
http://mirrors.aliyun.com/pypi/simple/
--trusted-host
mirrors.aliyun.com
RUN
pip
install
-r
requirements.txt
-i
http://mirrors.aliyun.com/pypi/simple/
--trusted-host
mirrors.aliyun.com
README.md
View file @
907320eb
...
@@ -22,9 +22,7 @@ Baichuan整体模型基于标准的Transformer结构,采用了和LLaMA一样
...
@@ -22,9 +22,7 @@ Baichuan整体模型基于标准的Transformer结构,采用了和LLaMA一样
</div>
</div>
## 环境配置
## 环境配置
说明1:若在accelerate、transformers等库中遇到对deepspeed0.9.3的依赖,请注释掉相应的version check代码,目前暂未对deepspeed0.9.3进行适配,deepspeed0.9.2即可使用。
说明2: 如需使用lora训练,请安装transformer 4.31.0版本
### Docker(方式一)
### Docker(方式一)
推荐使用docker方式运行,提供拉取的docker镜像:
推荐使用docker方式运行,提供拉取的docker镜像:
...
@@ -33,9 +31,7 @@ docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk
...
@@ -33,9 +31,7 @@ docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk
```
```
安装docker中没有的依赖:
安装docker中没有的依赖:
```
```
pip install transformers==4.28.0 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install accelerate --no-dependencies -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install datasets peft trl tiktoken jieba rouge-chinese nltk gradio matplotlib uvicore fastapi sse-starlette sentencepiece
```
```
...
@@ -64,6 +60,25 @@ conda create -n chatglm python=3.8
...
@@ -64,6 +60,25 @@ conda create -n chatglm python=3.8
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
```
```
### 注意
由于dtk版本的deepspeed目前最高是0.9.2因此需要进入虚拟环境修改一些版本判断
```
#到虚拟环境下对应的python/site-packages注释掉一些版本判断
site-packages/accelerate/accelerator.py 文件
287 #if not is_deepspeed_available():
288 # raise ImportError("DeepSpeed is not installed => run `pip install deepspeed` or build it from source.")
289 #if compare_versions("deepspeed", "<", "0.9.3"):
290 # raise ImportError("DeepSpeed version must be >= 0.9.3. Please update DeepSpeed.")
site-packages/transformers/utils/versions.py 文件
43 #if not ops[op](version.parse(got_ver), version.parse(want_ver)):
44 # raise ImportError(
45 # f"{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}"
46 # )
```
## 数据集
## 数据集
输入数据为放置在项目
[
data
](
.data
)
目录下的 json 文件,用--dataset选项指定(参考下面示例),多个输入文件用
`,`
分隔。json 文件示例格式和字段说明如下:
输入数据为放置在项目
[
data
](
.data
)
目录下的 json 文件,用--dataset选项指定(参考下面示例),多个输入文件用
`,`
分隔。json 文件示例格式和字段说明如下:
...
@@ -152,52 +167,6 @@ python src/cli_demo.py \
...
@@ -152,52 +167,6 @@ python src/cli_demo.py \
```
```
注意:对于所有“基座”(Base)模型,--template 参数可以是 default 或者 baichuan任意值。但“对话”(Chat)模型请务必使用baichuan。
注意:对于所有“基座”(Base)模型,--template 参数可以是 default 或者 baichuan任意值。但“对话”(Chat)模型请务必使用baichuan。
### 导出微调后的模型
导出模型为huggingface格式:
```
bash
python src/export_model.py
\
--model_name_or_path
path_to_model
\
--template
default
\
--finetuning_type
lora
\
--checkpoint_dir
path_to_checkpoint
\
--output_dir
path_to_export
```
### 指标评估(BLEU 分数和汉语 ROUGE 分数)
```
bash
CUDA_VISIBLE_DEVICES
=
0 python src/train_bash.py
\
--stage
sft
\
--model_name_or_path
path_to_model
\
--do_eval
\
--dataset
alpaca_gpt4_zh
\
--template
default
\
--finetuning_type
lora
\
--checkpoint_dir
path_to_checkpoint
\
--output_dir
path_to_eval_result
\
--per_device_eval_batch_size
8
\
--max_samples
100
\
--predict_with_generate
```
### 模型预测
```
bash
CUDA_VISIBLE_DEVICES
=
0 python src/train_bash.py
\
--stage
sft
\
--model_name_or_path
path_to_llama_model
\
--do_predict
\
--dataset
alpaca_gpt4_zh
\
--template
default
\
--finetuning_type
lora
\
--checkpoint_dir
path_to_checkpoint
\
--output_dir
path_to_predict_result
\
--per_device_eval_batch_size
8
\
--max_samples
100
\
--predict_with_generate
```
## Result
## Result
...
...
run-full.sh
View file @
907320eb
...
@@ -6,7 +6,6 @@ deepspeed --num_gpus=8 src/train_bash.py \
...
@@ -6,7 +6,6 @@ deepspeed --num_gpus=8 src/train_bash.py \
--dataset
alpaca_gpt4_en,alpaca_gpt4_zh,self_cognition,oaast_sft,sharegpt_zh,lima
\
--dataset
alpaca_gpt4_en,alpaca_gpt4_zh,self_cognition,oaast_sft,sharegpt_zh,lima
\
--finetuning_type
full
\
--finetuning_type
full
\
--output_dir
output
\
--output_dir
output
\
--overwrite_cache
\
--per_device_train_batch_size
1
\
--per_device_train_batch_size
1
\
--per_device_eval_batch_size
1
\
--per_device_eval_batch_size
1
\
--gradient_accumulation_steps
2
\
--gradient_accumulation_steps
2
\
...
...
src/llmtuner/hparams/__pycache__/data_args.cpython-38.pyc
View file @
907320eb
No preview for this file type
src/llmtuner/hparams/data_args.py
View file @
907320eb
...
@@ -35,7 +35,7 @@ class DataArguments:
...
@@ -35,7 +35,7 @@ class DataArguments:
metadata
=
{
"help"
:
"The name of provided dataset(s) to use. Use commas to separate multiple datasets."
}
metadata
=
{
"help"
:
"The name of provided dataset(s) to use. Use commas to separate multiple datasets."
}
)
)
dataset_dir
:
Optional
[
str
]
=
field
(
dataset_dir
:
Optional
[
str
]
=
field
(
default
=
"/
public/home/zhaoying1/work/Baichuan-13B-main/LLaMA-Efficient-Tuning-remove-pe
/data"
,
default
=
"/
baichuan/baichuan-pytorch
/data"
,
metadata
=
{
"help"
:
"The name of the folder containing datasets."
}
metadata
=
{
"help"
:
"The name of the folder containing datasets."
}
)
)
split
:
Optional
[
str
]
=
field
(
split
:
Optional
[
str
]
=
field
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment