Skip to content

Commit

Permalink
THUDM#277 代码解释
Browse files Browse the repository at this point in the history
  • Loading branch information
zRzRzRzRzRzRzR committed Jul 4, 2024
1 parent 3dec01c commit b5683f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions finetune_demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ pip install -r requirements.txt
通过以下代码执行 **单机多卡/多机多卡** 运行,这是使用 `deepspeed` 作为加速方案的,您需要安装 `deepspeed`。接着,按照此命令运行:

```shell
OMP_NUM_THREADS=1 torchrun --standalone --nnodes=1 --nproc_per_node=8 finetune_hf.py data/AdvertiseGen/ THUDM/glm-4-9b-chat configs/lora.yaml # For Chat Fine-tune
OMP_NUM_THREADS=1 torchrun --standalone --nnodes=1 --nproc_per_node=8 finetune.py data/AdvertiseGen/ THUDM/glm-4-9b-chat configs/lora.yaml # For Chat Fine-tune
OMP_NUM_THREADS=1 torchrun --standalone --nnodes=1 --nproc_per_node=8 finetune_vision.py data/CogVLM-311K/ THUDM/glm-4v-9b configs/lora.yaml # For VQA Fine-tune
```

通过以下代码执行 **单机单卡** 运行。

```shell
python finetune.py data/AdvertiseGen/ THUDM/glm-4-9b-chat configs/lora.yaml # For Chat Fine-tune
python finetune.py data/CogVLM-311K/ THUDM/glm-4v-9b configs/lora.yaml # For VQA Fine-tune
python finetune_vision.py data/CogVLM-311K/ THUDM/glm-4v-9b configs/lora.yaml # For VQA Fine-tune
```

## 从保存点进行微调
Expand Down
4 changes: 2 additions & 2 deletions finetune_demo/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ Execute **single machine multi-card/multi-machine multi-card** run through the f
the acceleration solution, and you need to install `deepspeed`.

```shell
OMP_NUM_THREADS=1 torchrun --standalone --nnodes=1 --nproc_per_node=8 finetune_hf.py data/AdvertiseGen/ THUDM/glm-4-9b-chat configs/lora.yaml # For Chat Fine-tune
OMP_NUM_THREADS=1 torchrun --standalone --nnodes=1 --nproc_per_node=8 finetune.py data/AdvertiseGen/ THUDM/glm-4-9b-chat configs/lora.yaml # For Chat Fine-tune
OMP_NUM_THREADS=1 torchrun --standalone --nnodes=1 --nproc_per_node=8 finetune_vision.py data/CogVLM-311K/ THUDM/glm-4v-9b configs/lora.yaml # For VQA Fine-tune
```

Execute **single machine single card** run through the following code.

```shell
python finetune.py data/AdvertiseGen/ THUDM/glm-4-9b-chat configs/lora.yaml # For Chat Fine-tune
python finetune.py data/CogVLM-311K/ THUDM/glm-4v-9b configs/lora.yaml # For VQA Fine-tune
python finetune_vision.py data/CogVLM-311K/ THUDM/glm-4v-9b configs/lora.yaml # For VQA Fine-tune
```

## Fine-tune from a saved point
Expand Down
5 changes: 4 additions & 1 deletion finetune_demo/finetune_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def get_dataset(
orig_dataset = self._get_dataset(split)
if orig_dataset is None:
return

if remove_orig_columns:
remove_columns = orig_dataset.column_names
else:
Expand All @@ -236,6 +235,10 @@ def get_dataset(
batched=batched,
remove_columns=remove_columns,
num_proc=self._num_proc,
# This is default params of orig_dataset.map, and you can change it smaller
# https://github.com/THUDM/GLM-4/issues/277
writer_batch_size=1000,
batch_size=1000,
)


Expand Down

0 comments on commit b5683f2

Please sign in to comment.