diff --git a/nlp/ner/bert/pytorch/README.md b/nlp/ner/bert/pytorch/README.md index c528ec1b09fa3cdc45f435d56394017dc26b4b23..0d3d06e12f577afc0b7869f3b95cb229fb32c68a 100644 --- a/nlp/ner/bert/pytorch/README.md +++ b/nlp/ner/bert/pytorch/README.md @@ -4,32 +4,45 @@ BERT-base NER task Fine-tuning -## Step 1: Installing packages +## Step 1: Installation -``` shell -cd /nlp/ner/bert/pytorch +```bash pip3 install -r requirements.txt ``` -## Step 2: Training +## Step 2: Preparing datasets -### On single GPU +```bash +# Get "bert-base-uncased" from [Huggingface](https://huggingface.co/bert-base-uncased) -``` shell -bash run.sh +## Install lfs +wget https://packagecloud.io/github/git-lfs/packages/el/7/git-lfs-2.13.2-1.el7.x86_64.rpm/download -O lfs.rpm +rpm -ivh lfs.rpm + +## Clone from Huggingface, it may take long time for large file +git lfs install +git clone https://huggingface.co/bert-base-uncased ``` -### Multiple GPUs on one machine -```shell +## Step 3: Training + +**Make sure you've got "bert-base-uncased" ready in `./bert-base-uncased`** + +```bash +# On single GPU +bash run.sh + +# Multiple GPUs on one machine bash run_dist.sh ``` -## Results on BI-V100 + +## Results | GPUs | Samples/s | Loss | |------|------|----| -| 1x1 | 100 | 0.0696 | -| 1x8 | 252 | 0.0688 | +| BI-V100 x1 | 100 | 0.0696 | +| BI-V100 x8 | 252 | 0.0688 | ## Reference https://github.com/huggingface/ diff --git a/nlp/ner/bert/pytorch/run.sh b/nlp/ner/bert/pytorch/run.sh index 2dd49117d2d44afb20f64aba6c291e5be340b282..2e32b7e798737abadcc38445ff67937847349664 100755 --- a/nlp/ner/bert/pytorch/run.sh +++ b/nlp/ner/bert/pytorch/run.sh @@ -13,7 +13,7 @@ # limitations under the License. python3 run_ner.py \ - --model_name_or_path bert-base-uncased \ + --model_name_or_path ./bert-base-uncased \ --dataset_name conll2003 \ --output_dir /tmp/test-ner \ --do_train \ diff --git a/nlp/ner/bert/pytorch/run_dist.sh b/nlp/ner/bert/pytorch/run_dist.sh index c55803c15bc39fd7b1c3d976f34453e7a2f41cd5..f80a1ef8f986c0a523115e3ea5cb228d13dbc638 100755 --- a/nlp/ner/bert/pytorch/run_dist.sh +++ b/nlp/ner/bert/pytorch/run_dist.sh @@ -15,7 +15,7 @@ python3 -m torch.distributed.launch --nproc_per_node=8 --master_port 12333 \ run_ner.py \ - --model_name_or_path bert-base-uncased \ + --model_name_or_path ./bert-base-uncased \ --dataset_name conll2003 \ --output_dir /tmp/test-ner \ --do_train \ diff --git a/nlp/question_answering/bert/pytorch/README.md b/nlp/question_answering/bert/pytorch/README.md index 5adbdb524303e48bdb00c9d94303819d87668813..9f525da3e20c91a60867e63e67d9a2e6e5afbb86 100644 --- a/nlp/question_answering/bert/pytorch/README.md +++ b/nlp/question_answering/bert/pytorch/README.md @@ -4,32 +4,43 @@ BERT-base SQuAD task Fine-tuning -## Step 1: Installing packages +## Step 1: Installation -``` shell -cd /nlp/querstion_answering/bert/pytorch +``` bash pip3 install -r requirements.txt ``` -## Step 2: Training +## Step 2: Preparing datasets +```bash +# Get "bert-base-uncased" from [Huggingface](https://huggingface.co/bert-base-uncased) -### On single GPU +## Install lfs +wget https://packagecloud.io/github/git-lfs/packages/el/7/git-lfs-2.13.2-1.el7.x86_64.rpm/download -O lfs.rpm +rpm -ivh lfs.rpm -``` shell -bash run.sh +## Clone from Huggingface, it may take long time for large file +git lfs install +git clone --depth 1 https://huggingface.co/bert-base-uncased ``` -### Multiple GPUs on one machine +## Step 3: Training + +**Make sure you've got "bert-base-uncased" ready in `./bert-base-uncased`** -```shell +```bash +# On single GPU +bash run.sh + +# Multiple GPUs on one machine bash run_dist.sh ``` + ## Results on BI-V100 | GPUs | Samples/s | F1 | |------|-----------|--------| -| 1x1 | 128.86 | 87 | -| 1x8 | 208.6 | 78.69 | +| BI-V100 x1 | 128.86 | 87 | +| BI-V100 x8 | 208.6 | 78.69 | ## Reference https://github.com/huggingface/ diff --git a/nlp/question_answering/bert/pytorch/run.sh b/nlp/question_answering/bert/pytorch/run.sh index 921bd2e31d7a20b6e23cae9356c7b8c703d877e0..d64e59c6feff831db2120c30e929f4e4d6b0d35a 100644 --- a/nlp/question_answering/bert/pytorch/run.sh +++ b/nlp/question_answering/bert/pytorch/run.sh @@ -15,7 +15,7 @@ python3 run_qa.py \ - --model_name_or_path bert-base-uncased \ + --model_name_or_path ./bert-base-uncased \ --dataset_name squad \ --do_train \ --do_eval \ diff --git a/nlp/question_answering/bert/pytorch/run_dist.sh b/nlp/question_answering/bert/pytorch/run_dist.sh index 4bc503363dec540196b84f9cd5f60fb917ab6427..28a5c9851106423ab3634604c5bb493187e9c32d 100644 --- a/nlp/question_answering/bert/pytorch/run_dist.sh +++ b/nlp/question_answering/bert/pytorch/run_dist.sh @@ -15,7 +15,7 @@ python3 -m torch.distributed.launch --nproc_per_node=8 --master_port 12333 \ run_qa.py \ - --model_name_or_path bert-base-uncased \ + --model_name_or_path ./bert-base-uncased \ --dataset_name squad \ --do_train \ --do_eval \ diff --git a/nlp/text_classification/bert/pytorch/README.md b/nlp/text_classification/bert/pytorch/README.md index f1c8e77a6e8939a74178acf265dcdd16b07e8cdc..c80c82085650c50479b474c403980e689cb16e37 100644 --- a/nlp/text_classification/bert/pytorch/README.md +++ b/nlp/text_classification/bert/pytorch/README.md @@ -4,32 +4,45 @@ BERT-base WNLI task Fine-tuning -## Step 1: Installing packages +## Step 1: Installation ``` shell -cd /nlp/text_classification/bert/pytorch pip3 install -r requirements.txt ``` -## Step 2: Training +## Step 2: Preparing datasets -### On single GPU +```bash +# Get "bert-base-uncased" from [Huggingface](https://huggingface.co/bert-base-uncased) -``` shell -bash train.sh +## Install lfs +wget https://packagecloud.io/github/git-lfs/packages/el/7/git-lfs-2.13.2-1.el7.x86_64.rpm/download -O lfs.rpm +rpm -ivh lfs.rpm + +## Clone from Huggingface, it may take long time for large file +git lfs install +git clone https://huggingface.co/bert-base-uncased ``` -### Multiple GPUs on one machine +## Step 3: Training + +**Make sure you've got "bert-base-uncased" ready in `./bert-base-uncased`** -```shell + +```bash +# On single GPU +bash train.sh + +# Multiple GPUs on one machine bash train_dist.sh ``` -## Results on BI-V100 + +## Results | GPUs | Samples/s | Loss | |------|-----------|------| -| 1x1 | 144.5 | 0.74 | -| 1x8 | 322.74 | 0.71 | +| BI-V100 x1 | 144.5 | 0.74 | +| BI-V100 x8 | 322.74 | 0.71 | ## Reference https://github.com/huggingface/ diff --git a/nlp/text_classification/bert/pytorch/train.sh b/nlp/text_classification/bert/pytorch/train.sh index 238abee2fcb204ee46daa0ac8d98aee293689424..abedf907cfd945c7ff75c4f6522f933e6c148500 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-cased \ --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 458f1cb0a5b58c719c8dcd88e37de59f1b6f4373..05794aa34afb1a25dca508df2fbce63df8cfbd4b 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-cased \ --task_name $TASK_NAME \ --do_train \ --do_eval \