LazarusNLP/NusaBERT

NusaBERT: Teaching IndoBERT to be multilingual and multicultural!

Python

2

15 commits

updated Aug 7, 2024

See the code

README

NusaBERT: Teaching IndoBERT to be multilingual and multicultural!

This project aims to extend the multilingual and multicultural capability of IndoBERT (Wilie et al., 2020). We expanded the IndoBERT tokenizer on 12 new regional languages of Indonesia, and continued pre-training on a large-scale corpus consisting of the Indonesian language and 12 regional languages of Indonesia. Our models are highly competitive and robust on multilingual and multicultural benchmarks, such as IndoNLU, NusaX, and NusaWrites.

logo

Pre-trained Models

Results

We evaluate our models on three benchmarks: IndoNLU, NusaX, and NusaWrites, which measures the model's natural language understanding, multilingual, and multicultural capabilities. The datasets supports a variety of languages of Indonesia.

The values on the table below denotes the F1 score on the test set.

IndoNLU (Classification)

ModelEmoTSmSACASAHoASAWReTEAVG
mBERT67.3084.1472.2384.6384.4078.54
XLM-MLM65.7586.3382.1788.8964.3577.50
XLM-R Base71.1591.3991.7191.5779.9585.15
XLM-R Large78.5192.3592.4094.2783.8288.27
IndoBERT Lite Base p173.8890.8589.6888.0782.1784.93
IndoBERT Lite Base p272.2790.2987.6387.6283.6284.29
IndoBERT Base p175.4887.7393.2392.0778.5585.41
IndoBERT Base p276.2887.6693.2492.7078.6885.71
IndoBERT Lite Large p175.1988.6690.9989.5378.9884.67
IndoBERT Lite Large p270.8088.6188.1391.0585.4184.80
IndoBERT Large p177.0892.7295.6993.7582.9188.43
IndoBERT Large p279.4792.0394.9493.3880.3088.02
Our work
LazarusNLP/NusaBERT-base76.1087.4691.2689.8076.7784.28
LazarusNLP/NusaBERT-large78.9087.3692.1393.1882.6486.84

IndoNLU (Sequence Labeling)

ModelPOSPBaPOSTermAKEPSNERGritNERPFacQAAVG
mBERT91.8583.2589.5164.3175.0269.2761.2976.36
XLM-MLM95.8788.4090.5565.3574.7575.0662.1578.88
XLM-R Base95.1684.6490.9968.8279.0975.0364.5879.76
XLM-R Large92.7387.0391.4570.8878.2678.5274.6181.92
IndoBERT Lite Base p191.4075.1089.2969.0266.6246.5854.9970.43
IndoBERT Lite Base p290.0577.5989.1969.1366.7150.5249.1870.34
IndoBERT Base p195.2687.0990.7370.3669.8775.5253.4577.47
IndoBERT Base p295.2385.7291.1369.1767.4275.6857.0677.34
IndoBERT Lite Large p191.5683.7490.2367.8971.1974.3765.5077.78
IndoBERT Lite Large p294.5384.9190.7268.5573.0774.8962.8778.51
IndoBERT Large p195.7190.3591.8771.1877.6079.2562.4881.21
IndoBERT Large p295.3487.3692.1471.2776.6377.9968.0981.26
Our work
LazarusNLP/NusaBERT-base95.7796.0290.5466.6772.9382.2954.8179.86
LazarusNLP/NusaBERT-large96.8996.7691.7371.5379.8685.1266.7784.09

NusaX

ModelacebanbbcbjnbugengindjavmadminnijsunAVG
Naive Bayes72.572.673.071.973.776.573.169.466.873.268.871.972.0
SVM75.775.376.774.877.275.078.771.373.876.775.174.375.4
Logistic Regression77.476.376.375.077.275.974.773.774.774.873.475.875.4
IndoNLU IndoBERT Base75.474.870.083.173.979.590.081.777.882.575.877.578.5
IndoNLU IndoBERT Large76.379.574.083.270.987.390.285.677.282.975.877.280.0
IndoLEM IndoBERT Base72.665.461.771.266.971.287.674.571.868.969.371.771.1
mBERT Base72.270.669.370.468.084.178.073.267.474.970.274.572.7
XLM-R Base73.972.862.376.666.690.888.478.969.779.175.080.176.2
XLM-R Large75.977.165.586.370.092.691.684.274.983.173.386.080.0
Our work
LazarusNLP/NusaBERT-base76.5178.6774.0282.3871.6484.0989.7484.0975.6280.7774.9385.2179.81
LazarusNLP/NusaBERT-large81.882.8374.7186.5173.3684.6393.3387.2082.5083.5477.7282.7482.57

NusaWrites (NusaParagraph)

ModelsEmotionRhetorical ModeTopic
Naive Bayes75.5137.7385.06
SVM76.3645.4485.86
Logistic Regression78.2345.2187.67
IndoNLU IndoBERT Base67.1247.9285.87
IndoNLU IndoBERT Large62.6531.7585.41
IndoLEM IndoBERT Base66.9451.9384.87
mBERT63.1550.0173.82
XLM-R Base59.1549.1771.68
XLM-R Large67.4251.5783.05
Our work
LazarusNLP/NusaBERT-base67.1851.3484.17
LazarusNLP/NusaBERT-large71.8253.0685.89

NusaWrites (NusaTranslation)

ModelsEmotionSentiment
Naive Bayes52.7074.89
SVM55.0876.04
Logistic Regression56.1874.89
IndoNLU IndoBERT Base54.5075.24
IndoNLU IndoBERT Large57.8077.40
IndoLEM IndoBERT Base52.5969.08
mBERT44.1368.72
XLM-R Base47.0268.62
XLM-R Large54.8479.06
Our work
LazarusNLP/NusaBERT-base56.5477.07
LazarusNLP/NusaBERT-large61.4079.54

Installation

git clone https://github.com/LazarusNLP/NusaBERT.git
cd NusaBERT
pip install -r requirements.txt

Dataset

For pre-training we leverage three existing open-source corpora that includes the Indonesian language and regional languages of Indonesia. A summary of the datasets are as follows:

DatasetLanguage#documents
uonlp/CulturaXIndonesian (ind)23,251,368
uonlp/CulturaXJavanese (jav)2,058
uonlp/CulturaXMalay (msa)238,000
uonlp/CulturaXSundanese (sun)1,554
sabilmakbar/indo_wikiAcehnese (ace)12,904
sabilmakbar/indo_wikiBalinese (ban)19,837
sabilmakbar/indo_wikiBanjarese (bjn)10,437
sabilmakbar/indo_wikiBuginese (bug)9,793
sabilmakbar/indo_wikiGorontalo (gor)14,514
sabilmakbar/indo_wikiIndonesian (ind)654,287
sabilmakbar/indo_wikiJavanese (jav)72,667
sabilmakbar/indo_wikiBanyumasan (map_bms)11,832
sabilmakbar/indo_wikiMinangkabau (min)225,858
sabilmakbar/indo_wikiMalay (msa)346,186
sabilmakbar/indo_wikiNias (nia)1,650
sabilmakbar/indo_wikiSundanese (sun)61,494
sabilmakbar/indo_wikiTetum (tet)1,465
acul3/KoPI-NLLBAcehnese (ace)792,594
acul3/KoPI-NLLBBalinese (ban)244,545
acul3/KoPI-NLLBBanjarese (bjn)296,314
acul3/KoPI-NLLBJavanese (jav)1,155,142
acul3/KoPI-NLLBMinangkabau (min)113,323
acul3/KoPI-NLLBSundanese (sun)894,626

Extend NusaBERT Tokenizer

We first need to train a WordPiece tokenizer on our pre-pretraining corpus, whose vocab size we limit up to 10,000. We then add non-overlapping tokens from the new tokenizer to the original IndoBERT tokenizer. Since there are overlapping tokens between the two tokenizers, we only ended up adding 1,511 new tokens to the original tokenizer. Refer to the script for more details.

Pre-train NusaBERT

We modified the Hugging Face 🤗 masked language modeling pre-training script and conducted continued pre-training of IndoBERT on the dataset detailed above. Running pre-training is as simple as:

python scripts/run_mlm.py \
    --model_name_or_path indobenchmark/indobert-base-p1 \
    --tokenizer_name LazarusNLP/nusabert-base \
    --max_seq_length 128 \
    --per_device_train_batch_size 256 \
    --per_device_eval_batch_size 256 \
    --do_train --do_eval \
    --max_steps 500000 \
    --warmup_steps 24000 \
    --learning_rate 3e-4 \
    --weight_decay 0.01 \
    --optim adamw_torch_fused \
    --bf16 \
    --preprocessing_num_workers 24 \
    --dataloader_num_workers 24 \
    --save_steps 10000 --save_total_limit 3 \
    --output_dir outputs/nusabert-base \
    --overwrite_output_dir \
    --report_to tensorboard \
    --push_to_hub --hub_private_repo \
    --hub_model_id LazarusNLP/nusabert-base

We achieved a negative log-likelihood loss of 1.4876 and an accuracy of 68.66% on a heldout subset (5%) of the pre-training corpus.

Fine-tune NusaBERT

We developed fine-tuning scripts for NusaBERT based on fine-tuning scripts from Hugging Face 🤗's sample fine-tuning scripts.

In particular, we developed fine-tuning scripts for single-sentence classification, multi-class multi-label classification, token classification, and pair token classification, which you can find in scripts. These scripts support IndoNLU, NusaX, and NusaWrites datasets.

Single-Sentence Classification Task

The tasks included under this category are emotion classification, sentiment analysis, topic classification, etc. To fine-tune for single-sentence classification, run the following command and modify accordingly:

python scripts/run_classification.py \
    --model-checkpoint LazarusNLP/NusaBERT-base \
    --dataset-name indonlp/indonlu \
    --dataset-config emot \
    --input-column-names tweet \
    --target-column-name label \
    --input-max-length 128 \
    --output-dir outputs/nusabert-base-emot \
    --num-train-epochs 100 \
    --optim adamw_torch_fused \
    --learning-rate 1e-5 \
    --weight-decay 0.01 \
    --per-device-train-batch-size 32 \
    --per-device-eval-batch-size 64 \
    --hub-model-id LazarusNLP/NusaBERT-base-EmoT

Single-Sentence Classification recipes are provided here.

Multi-label Multi-class Classification

The task included under this category is aspect-based sentiment analysis (e.g. IndoNLU CASA and HoASA). To fine-tune for multi-label multi-class classification, run the following command and modify accordingly:

python scripts/run_multi_label_classification.py \
    --model-checkpoint LazarusNLP/NusaBERT-base \
    --dataset-name indonlp/indonlu \
    --dataset-config casa \
    --input-column-name sentence \
    --target-column-names fuel,machine,others,part,price,service \
    --input-max-length 128 \
    --output-dir outputs/nusabert-base-casa \
    --num-train-epochs 100 \
    --optim adamw_torch_fused \
    --learning-rate 1e-5 \
    --weight-decay 0.01 \
    --per-device-train-batch-size 32 \
    --per-device-eval-batch-size 64 \
    --hub-model-id LazarusNLP/NusaBERT-base-CASA

Multi-label Multi-class Classification recipes are provided here.

Token Classification

Token classification is also known as sequence labeling. The tasks included under this category are part-of-speech tagging (POS), named entity recognition (NER), and token-level span extraction (e.g. IndoNLU TermA, KEPS). To fine-tune for token classification, run the following command and modify accordingly:

python scripts/run_token_classification.py \
        --model-checkpoint LazarusNLP/NusaBERT-base \
        --dataset-name indonlp/indonlu \
        --dataset-config posp \
        --input-column-name tokens \
        --target-column-name pos_tags \
        --output-dir outputs/nusabert-base-posp \
        --num-train-epochs 10 \
        --optim adamw_torch_fused \
        --learning-rate 2e-5 \
        --weight-decay 0.01 \
        --per-device-train-batch-size 16 \
        --per-device-eval-batch-size 64 \
        --hub-model-id LazarusNLP/NusaBERT-base-POSP

Token Classification recipes are provided here.

Pair Token Classification

Pair token classification is much like token-classification, except involving a pair of input sentences instead of one. The tasks included under this category is token-level question-passage-answering (e.g. IndoNLU FacQA). To fine-tune for pair question-answering, run the following command and modify accordingly:

python scripts/run_pair_token_classification.py \
    --model-checkpoint LazarusNLP/NusaBERT-base \
    --dataset-name indonlp/indonlu \
    --dataset-config facqa \
    --input-column-name-1 question \
    --input-column-name-2 passage \
    --target-column-name seq_label \
    --output-dir outputs/nusabert-base-facqa \
    --num-train-epochs 10 \
    --optim adamw_torch_fused \
    --learning-rate 2e-5 \
    --weight-decay 0.01 \
    --per-device-train-batch-size 16 \
    --per-device-eval-batch-size 64 \
    --hub-model-id LazarusNLP/NusaBERT-base-FacQA

Pair Token Classification recipes are provided here.

Citation

If you use NusaBERT in your research, please cite the following:

@misc{wongso2024nusabertteachingindobertmultilingual,
    title = {NusaBERT: Teaching IndoBERT to be Multilingual and Multicultural}, 
    author = {Wilson Wongso and David Samuel Setiawan and Steven Limcorn and Ananto Joyoadikusumo},
    year = {2024},
    eprint = {2403.01817},
    archivePrefix = {arXiv},
    primaryClass = {cs.CL},
    url = {https://arxiv.org/abs/2403.01817}, 
}

Credits

NusaBERT is developed with love by:

bert
indobert
indonesian
language-model
natural-language-processing
natural-language-understanding
nusabert

LazarusNLP/NusaBERT

NusaBERT: Teaching IndoBERT to be multilingual and multicultural!

Python

2

15 commits

updated Aug 7, 2024

See the code

README

NusaBERT: Teaching IndoBERT to be multilingual and multicultural!

This project aims to extend the multilingual and multicultural capability of IndoBERT (Wilie et al., 2020). We expanded the IndoBERT tokenizer on 12 new regional languages of Indonesia, and continued pre-training on a large-scale corpus consisting of the Indonesian language and 12 regional languages of Indonesia. Our models are highly competitive and robust on multilingual and multicultural benchmarks, such as IndoNLU, NusaX, and NusaWrites.

logo

Pre-trained Models

Results

We evaluate our models on three benchmarks: IndoNLU, NusaX, and NusaWrites, which measures the model's natural language understanding, multilingual, and multicultural capabilities. The datasets supports a variety of languages of Indonesia.

The values on the table below denotes the F1 score on the test set.

IndoNLU (Classification)

ModelEmoTSmSACASAHoASAWReTEAVG
mBERT67.3084.1472.2384.6384.4078.54
XLM-MLM65.7586.3382.1788.8964.3577.50
XLM-R Base71.1591.3991.7191.5779.9585.15
XLM-R Large78.5192.3592.4094.2783.8288.27
IndoBERT Lite Base p173.8890.8589.6888.0782.1784.93
IndoBERT Lite Base p272.2790.2987.6387.6283.6284.29
IndoBERT Base p175.4887.7393.2392.0778.5585.41
IndoBERT Base p276.2887.6693.2492.7078.6885.71
IndoBERT Lite Large p175.1988.6690.9989.5378.9884.67
IndoBERT Lite Large p270.8088.6188.1391.0585.4184.80
IndoBERT Large p177.0892.7295.6993.7582.9188.43
IndoBERT Large p279.4792.0394.9493.3880.3088.02
Our work
LazarusNLP/NusaBERT-base76.1087.4691.2689.8076.7784.28
LazarusNLP/NusaBERT-large78.9087.3692.1393.1882.6486.84

IndoNLU (Sequence Labeling)

ModelPOSPBaPOSTermAKEPSNERGritNERPFacQAAVG
mBERT91.8583.2589.5164.3175.0269.2761.2976.36
XLM-MLM95.8788.4090.5565.3574.7575.0662.1578.88
XLM-R Base95.1684.6490.9968.8279.0975.0364.5879.76
XLM-R Large92.7387.0391.4570.8878.2678.5274.6181.92
IndoBERT Lite Base p191.4075.1089.2969.0266.6246.5854.9970.43
IndoBERT Lite Base p290.0577.5989.1969.1366.7150.5249.1870.34
IndoBERT Base p195.2687.0990.7370.3669.8775.5253.4577.47
IndoBERT Base p295.2385.7291.1369.1767.4275.6857.0677.34
IndoBERT Lite Large p191.5683.7490.2367.8971.1974.3765.5077.78
IndoBERT Lite Large p294.5384.9190.7268.5573.0774.8962.8778.51
IndoBERT Large p195.7190.3591.8771.1877.6079.2562.4881.21
IndoBERT Large p295.3487.3692.1471.2776.6377.9968.0981.26
Our work
LazarusNLP/NusaBERT-base95.7796.0290.5466.6772.9382.2954.8179.86
LazarusNLP/NusaBERT-large96.8996.7691.7371.5379.8685.1266.7784.09

NusaX

ModelacebanbbcbjnbugengindjavmadminnijsunAVG
Naive Bayes72.572.673.071.973.776.573.169.466.873.268.871.972.0
SVM75.775.376.774.877.275.078.771.373.876.775.174.375.4
Logistic Regression77.476.376.375.077.275.974.773.774.774.873.475.875.4
IndoNLU IndoBERT Base75.474.870.083.173.979.590.081.777.882.575.877.578.5
IndoNLU IndoBERT Large76.379.574.083.270.987.390.285.677.282.975.877.280.0
IndoLEM IndoBERT Base72.665.461.771.266.971.287.674.571.868.969.371.771.1
mBERT Base72.270.669.370.468.084.178.073.267.474.970.274.572.7
XLM-R Base73.972.862.376.666.690.888.478.969.779.175.080.176.2
XLM-R Large75.977.165.586.370.092.691.684.274.983.173.386.080.0
Our work
LazarusNLP/NusaBERT-base76.5178.6774.0282.3871.6484.0989.7484.0975.6280.7774.9385.2179.81
LazarusNLP/NusaBERT-large81.882.8374.7186.5173.3684.6393.3387.2082.5083.5477.7282.7482.57

NusaWrites (NusaParagraph)

ModelsEmotionRhetorical ModeTopic
Naive Bayes75.5137.7385.06
SVM76.3645.4485.86
Logistic Regression78.2345.2187.67
IndoNLU IndoBERT Base67.1247.9285.87
IndoNLU IndoBERT Large62.6531.7585.41
IndoLEM IndoBERT Base66.9451.9384.87
mBERT63.1550.0173.82
XLM-R Base59.1549.1771.68
XLM-R Large67.4251.5783.05
Our work
LazarusNLP/NusaBERT-base67.1851.3484.17
LazarusNLP/NusaBERT-large71.8253.0685.89

NusaWrites (NusaTranslation)

ModelsEmotionSentiment
Naive Bayes52.7074.89
SVM55.0876.04
Logistic Regression56.1874.89
IndoNLU IndoBERT Base54.5075.24
IndoNLU IndoBERT Large57.8077.40
IndoLEM IndoBERT Base52.5969.08
mBERT44.1368.72
XLM-R Base47.0268.62
XLM-R Large54.8479.06
Our work
LazarusNLP/NusaBERT-base56.5477.07
LazarusNLP/NusaBERT-large61.4079.54

Installation

git clone https://github.com/LazarusNLP/NusaBERT.git
cd NusaBERT
pip install -r requirements.txt

Dataset

For pre-training we leverage three existing open-source corpora that includes the Indonesian language and regional languages of Indonesia. A summary of the datasets are as follows:

DatasetLanguage#documents
uonlp/CulturaXIndonesian (ind)23,251,368
uonlp/CulturaXJavanese (jav)2,058
uonlp/CulturaXMalay (msa)238,000
uonlp/CulturaXSundanese (sun)1,554
sabilmakbar/indo_wikiAcehnese (ace)12,904
sabilmakbar/indo_wikiBalinese (ban)19,837
sabilmakbar/indo_wikiBanjarese (bjn)10,437
sabilmakbar/indo_wikiBuginese (bug)9,793
sabilmakbar/indo_wikiGorontalo (gor)14,514
sabilmakbar/indo_wikiIndonesian (ind)654,287
sabilmakbar/indo_wikiJavanese (jav)72,667
sabilmakbar/indo_wikiBanyumasan (map_bms)11,832
sabilmakbar/indo_wikiMinangkabau (min)225,858
sabilmakbar/indo_wikiMalay (msa)346,186
sabilmakbar/indo_wikiNias (nia)1,650
sabilmakbar/indo_wikiSundanese (sun)61,494
sabilmakbar/indo_wikiTetum (tet)1,465
acul3/KoPI-NLLBAcehnese (ace)792,594
acul3/KoPI-NLLBBalinese (ban)244,545
acul3/KoPI-NLLBBanjarese (bjn)296,314
acul3/KoPI-NLLBJavanese (jav)1,155,142
acul3/KoPI-NLLBMinangkabau (min)113,323
acul3/KoPI-NLLBSundanese (sun)894,626

Extend NusaBERT Tokenizer

We first need to train a WordPiece tokenizer on our pre-pretraining corpus, whose vocab size we limit up to 10,000. We then add non-overlapping tokens from the new tokenizer to the original IndoBERT tokenizer. Since there are overlapping tokens between the two tokenizers, we only ended up adding 1,511 new tokens to the original tokenizer. Refer to the script for more details.

Pre-train NusaBERT

We modified the Hugging Face 🤗 masked language modeling pre-training script and conducted continued pre-training of IndoBERT on the dataset detailed above. Running pre-training is as simple as:

python scripts/run_mlm.py \
    --model_name_or_path indobenchmark/indobert-base-p1 \
    --tokenizer_name LazarusNLP/nusabert-base \
    --max_seq_length 128 \
    --per_device_train_batch_size 256 \
    --per_device_eval_batch_size 256 \
    --do_train --do_eval \
    --max_steps 500000 \
    --warmup_steps 24000 \
    --learning_rate 3e-4 \
    --weight_decay 0.01 \
    --optim adamw_torch_fused \
    --bf16 \
    --preprocessing_num_workers 24 \
    --dataloader_num_workers 24 \
    --save_steps 10000 --save_total_limit 3 \
    --output_dir outputs/nusabert-base \
    --overwrite_output_dir \
    --report_to tensorboard \
    --push_to_hub --hub_private_repo \
    --hub_model_id LazarusNLP/nusabert-base

We achieved a negative log-likelihood loss of 1.4876 and an accuracy of 68.66% on a heldout subset (5%) of the pre-training corpus.

Fine-tune NusaBERT

We developed fine-tuning scripts for NusaBERT based on fine-tuning scripts from Hugging Face 🤗's sample fine-tuning scripts.

In particular, we developed fine-tuning scripts for single-sentence classification, multi-class multi-label classification, token classification, and pair token classification, which you can find in scripts. These scripts support IndoNLU, NusaX, and NusaWrites datasets.

Single-Sentence Classification Task

The tasks included under this category are emotion classification, sentiment analysis, topic classification, etc. To fine-tune for single-sentence classification, run the following command and modify accordingly:

python scripts/run_classification.py \
    --model-checkpoint LazarusNLP/NusaBERT-base \
    --dataset-name indonlp/indonlu \
    --dataset-config emot \
    --input-column-names tweet \
    --target-column-name label \
    --input-max-length 128 \
    --output-dir outputs/nusabert-base-emot \
    --num-train-epochs 100 \
    --optim adamw_torch_fused \
    --learning-rate 1e-5 \
    --weight-decay 0.01 \
    --per-device-train-batch-size 32 \
    --per-device-eval-batch-size 64 \
    --hub-model-id LazarusNLP/NusaBERT-base-EmoT

Single-Sentence Classification recipes are provided here.

Multi-label Multi-class Classification

The task included under this category is aspect-based sentiment analysis (e.g. IndoNLU CASA and HoASA). To fine-tune for multi-label multi-class classification, run the following command and modify accordingly:

python scripts/run_multi_label_classification.py \
    --model-checkpoint LazarusNLP/NusaBERT-base \
    --dataset-name indonlp/indonlu \
    --dataset-config casa \
    --input-column-name sentence \
    --target-column-names fuel,machine,others,part,price,service \
    --input-max-length 128 \
    --output-dir outputs/nusabert-base-casa \
    --num-train-epochs 100 \
    --optim adamw_torch_fused \
    --learning-rate 1e-5 \
    --weight-decay 0.01 \
    --per-device-train-batch-size 32 \
    --per-device-eval-batch-size 64 \
    --hub-model-id LazarusNLP/NusaBERT-base-CASA

Multi-label Multi-class Classification recipes are provided here.

Token Classification

Token classification is also known as sequence labeling. The tasks included under this category are part-of-speech tagging (POS), named entity recognition (NER), and token-level span extraction (e.g. IndoNLU TermA, KEPS). To fine-tune for token classification, run the following command and modify accordingly:

python scripts/run_token_classification.py \
        --model-checkpoint LazarusNLP/NusaBERT-base \
        --dataset-name indonlp/indonlu \
        --dataset-config posp \
        --input-column-name tokens \
        --target-column-name pos_tags \
        --output-dir outputs/nusabert-base-posp \
        --num-train-epochs 10 \
        --optim adamw_torch_fused \
        --learning-rate 2e-5 \
        --weight-decay 0.01 \
        --per-device-train-batch-size 16 \
        --per-device-eval-batch-size 64 \
        --hub-model-id LazarusNLP/NusaBERT-base-POSP

Token Classification recipes are provided here.

Pair Token Classification

Pair token classification is much like token-classification, except involving a pair of input sentences instead of one. The tasks included under this category is token-level question-passage-answering (e.g. IndoNLU FacQA). To fine-tune for pair question-answering, run the following command and modify accordingly:

python scripts/run_pair_token_classification.py \
    --model-checkpoint LazarusNLP/NusaBERT-base \
    --dataset-name indonlp/indonlu \
    --dataset-config facqa \
    --input-column-name-1 question \
    --input-column-name-2 passage \
    --target-column-name seq_label \
    --output-dir outputs/nusabert-base-facqa \
    --num-train-epochs 10 \
    --optim adamw_torch_fused \
    --learning-rate 2e-5 \
    --weight-decay 0.01 \
    --per-device-train-batch-size 16 \
    --per-device-eval-batch-size 64 \
    --hub-model-id LazarusNLP/NusaBERT-base-FacQA

Pair Token Classification recipes are provided here.

Citation

If you use NusaBERT in your research, please cite the following:

@misc{wongso2024nusabertteachingindobertmultilingual,
    title = {NusaBERT: Teaching IndoBERT to be Multilingual and Multicultural}, 
    author = {Wilson Wongso and David Samuel Setiawan and Steven Limcorn and Ananto Joyoadikusumo},
    year = {2024},
    eprint = {2403.01817},
    archivePrefix = {arXiv},
    primaryClass = {cs.CL},
    url = {https://arxiv.org/abs/2403.01817}, 
}

Credits

NusaBERT is developed with love by:

bert
indobert
indonesian
language-model
natural-language-processing
natural-language-understanding
nusabert