From f60561abf214b29705ae637162f7ebbc0cfd1218 Mon Sep 17 00:00:00 2001 From: fanglaipeng Date: Wed, 10 Sep 2025 07:28:00 +0000 Subject: [PATCH 1/4] Fix model name mismatch in nlp/text_classification/bert/pytorch: update train.sh to use 'bert-base-uncased' (matches README) --- nlp/text_classification/bert/pytorch/train.sh | 2 +- nlp/text_classification/bert/pytorch/train_dist.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nlp/text_classification/bert/pytorch/train.sh b/nlp/text_classification/bert/pytorch/train.sh index abedf907c..895f28ecc 100644 --- a/nlp/text_classification/bert/pytorch/train.sh +++ b/nlp/text_classification/bert/pytorch/train.sh @@ -16,7 +16,7 @@ export TASK_NAME=WNLI python3 run_glue.py \ - --model_name_or_path ./bert-base-cased \ + --model_name_or_path ./bert-base-uncased \ --task_name $TASK_NAME \ --do_train \ --do_eval \ diff --git a/nlp/text_classification/bert/pytorch/train_dist.sh b/nlp/text_classification/bert/pytorch/train_dist.sh index 05794aa34..e6b30f7f0 100644 --- a/nlp/text_classification/bert/pytorch/train_dist.sh +++ b/nlp/text_classification/bert/pytorch/train_dist.sh @@ -17,7 +17,7 @@ export TASK_NAME=WNLI python3 -m torch.distributed.launch --nproc_per_node=8 --master_port 12333 \ run_glue.py \ - --model_name_or_path ./bert-base-cased \ + --model_name_or_path ./bert-base-uncased \ --task_name $TASK_NAME \ --do_train \ --do_eval \ -- Gitee From 662f5346dee196b02903ffea825a57541a1d1aef Mon Sep 17 00:00:00 2001 From: fanglaipeng Date: Wed, 10 Sep 2025 07:35:36 +0000 Subject: [PATCH 2/4] fix(dependencies): Pin datasets to v2.14.6 to resolve evaluate's use_auth_token dependency conflict --- nlp/text_classification/bert/pytorch/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nlp/text_classification/bert/pytorch/requirements.txt b/nlp/text_classification/bert/pytorch/requirements.txt index 71dc11dd1..b38e4fe5e 100644 --- a/nlp/text_classification/bert/pytorch/requirements.txt +++ b/nlp/text_classification/bert/pytorch/requirements.txt @@ -1,5 +1,5 @@ accelerate >= 0.12.0 -datasets >= 1.8.0 +datasets == 2.14.6 sentencepiece != 0.1.92 scipy scikit-learn -- Gitee From 879222644051f408d8edf641b9435506f5161a5b Mon Sep 17 00:00:00 2001 From: fanglaipeng Date: Wed, 10 Sep 2025 07:46:56 +0000 Subject: [PATCH 3/4] Add train_dist_torch2.sh for PyTorch 2.x multi-GPU compatibility in nlp/text_classification/bert/pytorch --- .../bert/pytorch/README.md | 4 +++ .../bert/pytorch/train_dist_torch2.sh | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 nlp/text_classification/bert/pytorch/train_dist_torch2.sh diff --git a/nlp/text_classification/bert/pytorch/README.md b/nlp/text_classification/bert/pytorch/README.md index b5576feb2..14e65cc84 100644 --- a/nlp/text_classification/bert/pytorch/README.md +++ b/nlp/text_classification/bert/pytorch/README.md @@ -45,7 +45,11 @@ git clone https://huggingface.co/bert-base-uncased bash train.sh # Multiple GPUs on one machine +## torch 1.x bash train_dist.sh + +## torch 2.x +bash train_dist_torch2.sh ``` ## Model Results diff --git a/nlp/text_classification/bert/pytorch/train_dist_torch2.sh b/nlp/text_classification/bert/pytorch/train_dist_torch2.sh new file mode 100644 index 000000000..c7194d8ec --- /dev/null +++ b/nlp/text_classification/bert/pytorch/train_dist_torch2.sh @@ -0,0 +1,28 @@ +# Copyright (c) 2023, Shanghai Iluvatar CoreX Semiconductor Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +export TASK_NAME=WNLI +torchrun --nproc_per_node=8 --master_port 12333 \ + run_glue.py \ + --model_name_or_path ./bert-base-uncased \ + --task_name $TASK_NAME \ + --do_train \ + --do_eval \ + --max_seq_length 128 \ + --per_device_train_batch_size 32 \ + --learning_rate 2e-5 \ + --num_train_epochs 5 \ + --output_dir /tmp/$TASK_NAME/ -- Gitee From 46905e5c46e56e786859c5b30c001f4ad74d7e7d Mon Sep 17 00:00:00 2001 From: fanglaipeng Date: Wed, 10 Sep 2025 08:08:12 +0000 Subject: [PATCH 4/4] Fix: Pin pyarrow version to <13.0.0 to resolve 'module has no attribute 'PyExtensionType'' due to dependency conflicts. --- nlp/text_classification/bert/pytorch/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/nlp/text_classification/bert/pytorch/requirements.txt b/nlp/text_classification/bert/pytorch/requirements.txt index b38e4fe5e..844d85924 100644 --- a/nlp/text_classification/bert/pytorch/requirements.txt +++ b/nlp/text_classification/bert/pytorch/requirements.txt @@ -8,3 +8,4 @@ protobuf numpy == 1.21.6 evaluate == 0.4.1 transformers == 4.30.2 +pyarrow < 13.0.0 -- Gitee