LazarusNLP/indonesian-sentence-embeddings

Embedding Representation for Indonesian Sentences!

Jupyter Notebook

27

85 commits

updated Aug 14, 2024

See the code

README

Indonesian Sentence Embeddings

DOI

Inspired by Thai Sentence Vector Benchmark, we decided to embark on the journey of training Indonesian sentence embedding models!

logo

Evaluation

Semantic Textual Similarity

We followed approached done in the Thai Sentence Vector Benchmark project and translated the STS-B dev and test set to Indonesian via Google Translate API. This dataset will be used to evaluate our model's Spearman correlation score on the translated test set.

You can find the translated dataset on 🤗 HuggingFace Hub.

Further, we will similarly be evaluating our models on the SemRel2024 dataset which contains human-annotated, Indonesian semantic textual relatedness (STR) data. The dataset consists of two splits: dev and test. We will be evaluating our models' Spearman correlation score on both splits.

Retrieval

To evaluate our models' capability to perform retrieval tasks, we evaluate them on Indonesian subsets of MIRACL and TyDiQA datasets. In both datasets, the model's ability to retrieve relevant documents given a query is tested. We employ R@1 (top-1 accuracy), MRR@10, and nDCG@10 metrics to measure our model's performance.

Classification

For text classification, we will be doing emotion classification and sentiment analysis on the EmoT and SmSA subsets of IndoNLU, respectively. To do so, we will be doing the same approach as Thai Sentence Vector Benchmark and simply fit a Linear SVC on sentence representations of our texts with their corresponding labels. Thus, unlike conventional fine-tuning method where the backbone model is also updated, the Sentence Transformer stays frozen in our case; with only the classification head being trained.

Further, we will evaluate our models using the official MTEB code that contains two Indonesian classification subtasks: MassiveIntentClassification (id) and MassiveScenarioClassification (id).

Pair Classification

We followed MTEB's PairClassification evaluation procedure for pair classification. Specifically for zero-shot natural language inference tasks, all neutral pairs are dropped, while contradictions and entailments are re-mapped as 0s and 1s. The maximum average precision (AP) score is found by finding the best threshold value.

We leverage the IndoNLI dataset's two test subsets: test_lay and test_expert.

Methods

(Unsupervised) SimCSE

We followed SimCSE: Simple Contrastive Learning of Sentence Embeddings and trained a sentence embedding model in an unsupervised fashion. Unsupervised SimCSE allows us to leverage an unsupervised corpus -- which are plenty -- and with different dropout masks in the encoder, contrastively learn sentence representations. This is parallel with the situation that there is a lack of supervised Indonesian sentence similarity datasets, hence SimCSE is a natural first move into this field. We used the Sentence Transformer implementation of SimCSE.

ConGen

Like SimCSE, ConGen: Unsupervised Control and Generalization Distillation For Sentence Representation is another unsupervised technique to train a sentence embedding model. Since it is in-part a distillation method, ConGen relies on a teacher model which will then be distilled to a student model. The original paper proposes back-translation as the best data augmentation technique. However, due to the lack of resources, we implemented word deletion, which was found to be on-par with back-translation despite being trivial. We used the official ConGen implementation which was written on top of the Sentence Transformers library.

SCT

SCT: An Efficient Self-Supervised Cross-View Training For Sentence Embedding is another unsupervised technique to train a sentence embedding model. It is very similar to ConGen in its knowledge distillation methodology, but also supports self-supervised training procedure without a teacher model. The original paper proposes back-translation as its data augmentation technique, but we implemented single-word deletion and found it to perform better than our backtranslated corpus. We used the official SCT implementation which was written on top of the Sentence Transformers library.

Pretrained Models

Deprecated Models

Results

Semantic Textual Similarity

Machine Translated Indonesian STS-B

SemRel2024: Semantic Textual Relatedness (STR)

Retrieval

MIRACL

ModelR@1 (%) ↑MRR@10 (%) ↑nDCG@10 (%) ↑
SimCSE-IndoBERT Base36.0448.2539.70
ConGen-IndoBERT Lite Base46.0459.0651.01
ConGen-IndoBERT Base45.9358.5849.95
ConGen-SimCSE-IndoBERT Base45.8358.2749.91
ConGen-Indo-e5 Small55.0066.7458.95
SCT-IndoBERT Base40.4147.2940.68
all-IndoBERT Base65.5275.9270.13
all-IndoBERT Base-v267.1876.5970.16
all-IndoBERT Base-v467.9177.3770.97
all-NusaBERT Base-v467.0877.4771.24
all-NusaBERT Large-v468.4378.2971.99
all-Indo-e5 Small-v268.3378.3373.04
all-Indo-e5 Small-v368.1278.2273.09
all-Indo-e5 Small-v468.3378.4173.23
distiluse-base-multilingual-cased-v241.3554.9348.79
paraphrase-multilingual-mpnet-base-v252.8165.0757.97
multilingual-e5-small70.2079.6174.80
multilingual-e5-base70.0079.5075.16
multilingual-e5-large70.8380.5876.16

TyDiQA

ModelR@1 (%) ↑MRR@10 (%) ↑nDCG@10 (%) ↑
SimCSE-IndoBERT Base61.9469.8973.52
ConGen-IndoBERT Lite Base75.2281.5584.13
ConGen-IndoBERT Base73.0980.3283.29
ConGen-SimCSE-IndoBERT Base72.3879.3782.51
ConGen-Indo-e5 Small84.6089.3091.27
SCT-IndoBERT Base76.8183.1685.87
all-IndoBERT Base88.1491.4792.91
all-IndoBERT Base-v287.6190.9192.31
all-IndoBERT Base-v489.0292.5993.91
all-NusaBERT Base-v492.7494.9595.73
all-NusaBERT Large-v493.6295.7796.56
all-Indo-e5 Small-v293.2795.6396.46
all-Indo-e5 Small-v393.2795.7296.58
all-Indo-e5 Small-v493.4595.6696.43
distiluse-base-multilingual-cased-v270.4477.9481.56
paraphrase-multilingual-mpnet-base-v281.4187.0589.44
multilingual-e5-small91.5094.3495.39
multilingual-e5-base93.4595.8896.69
multilingual-e5-large94.6996.7197.44

Classification

MTEB - Massive Intent Classification (id)

MTEB - Massive Scenario Classification (id)

IndoNLU - Emotion Classification (EmoT)

IndoNLU - Sentiment Analysis (SmSA)

Pair Classification

IndoNLI

Credits

Indonesian Sentence Embeddings is developed with love by:

indonesia
indonesian
natural-language-processing
sbert
semantic-textual-similarity
sentence-embeddings
sentence-transformers
unsupervised-learning

Contributors

w11wo

85 commits

LazarusNLP/indonesian-sentence-embeddings

Embedding Representation for Indonesian Sentences!

Jupyter Notebook

27

85 commits

updated Aug 14, 2024

See the code

README

Indonesian Sentence Embeddings

DOI

Inspired by Thai Sentence Vector Benchmark, we decided to embark on the journey of training Indonesian sentence embedding models!

logo

Evaluation

Semantic Textual Similarity

We followed approached done in the Thai Sentence Vector Benchmark project and translated the STS-B dev and test set to Indonesian via Google Translate API. This dataset will be used to evaluate our model's Spearman correlation score on the translated test set.

You can find the translated dataset on 🤗 HuggingFace Hub.

Further, we will similarly be evaluating our models on the SemRel2024 dataset which contains human-annotated, Indonesian semantic textual relatedness (STR) data. The dataset consists of two splits: dev and test. We will be evaluating our models' Spearman correlation score on both splits.

Retrieval

To evaluate our models' capability to perform retrieval tasks, we evaluate them on Indonesian subsets of MIRACL and TyDiQA datasets. In both datasets, the model's ability to retrieve relevant documents given a query is tested. We employ R@1 (top-1 accuracy), MRR@10, and nDCG@10 metrics to measure our model's performance.

Classification

For text classification, we will be doing emotion classification and sentiment analysis on the EmoT and SmSA subsets of IndoNLU, respectively. To do so, we will be doing the same approach as Thai Sentence Vector Benchmark and simply fit a Linear SVC on sentence representations of our texts with their corresponding labels. Thus, unlike conventional fine-tuning method where the backbone model is also updated, the Sentence Transformer stays frozen in our case; with only the classification head being trained.

Further, we will evaluate our models using the official MTEB code that contains two Indonesian classification subtasks: MassiveIntentClassification (id) and MassiveScenarioClassification (id).

Pair Classification

We followed MTEB's PairClassification evaluation procedure for pair classification. Specifically for zero-shot natural language inference tasks, all neutral pairs are dropped, while contradictions and entailments are re-mapped as 0s and 1s. The maximum average precision (AP) score is found by finding the best threshold value.

We leverage the IndoNLI dataset's two test subsets: test_lay and test_expert.

Methods

(Unsupervised) SimCSE

We followed SimCSE: Simple Contrastive Learning of Sentence Embeddings and trained a sentence embedding model in an unsupervised fashion. Unsupervised SimCSE allows us to leverage an unsupervised corpus -- which are plenty -- and with different dropout masks in the encoder, contrastively learn sentence representations. This is parallel with the situation that there is a lack of supervised Indonesian sentence similarity datasets, hence SimCSE is a natural first move into this field. We used the Sentence Transformer implementation of SimCSE.

ConGen

Like SimCSE, ConGen: Unsupervised Control and Generalization Distillation For Sentence Representation is another unsupervised technique to train a sentence embedding model. Since it is in-part a distillation method, ConGen relies on a teacher model which will then be distilled to a student model. The original paper proposes back-translation as the best data augmentation technique. However, due to the lack of resources, we implemented word deletion, which was found to be on-par with back-translation despite being trivial. We used the official ConGen implementation which was written on top of the Sentence Transformers library.

SCT

SCT: An Efficient Self-Supervised Cross-View Training For Sentence Embedding is another unsupervised technique to train a sentence embedding model. It is very similar to ConGen in its knowledge distillation methodology, but also supports self-supervised training procedure without a teacher model. The original paper proposes back-translation as its data augmentation technique, but we implemented single-word deletion and found it to perform better than our backtranslated corpus. We used the official SCT implementation which was written on top of the Sentence Transformers library.

Pretrained Models

Deprecated Models

Results

Semantic Textual Similarity

Machine Translated Indonesian STS-B

SemRel2024: Semantic Textual Relatedness (STR)

Retrieval

MIRACL

ModelR@1 (%) ↑MRR@10 (%) ↑nDCG@10 (%) ↑
SimCSE-IndoBERT Base36.0448.2539.70
ConGen-IndoBERT Lite Base46.0459.0651.01
ConGen-IndoBERT Base45.9358.5849.95
ConGen-SimCSE-IndoBERT Base45.8358.2749.91
ConGen-Indo-e5 Small55.0066.7458.95
SCT-IndoBERT Base40.4147.2940.68
all-IndoBERT Base65.5275.9270.13
all-IndoBERT Base-v267.1876.5970.16
all-IndoBERT Base-v467.9177.3770.97
all-NusaBERT Base-v467.0877.4771.24
all-NusaBERT Large-v468.4378.2971.99
all-Indo-e5 Small-v268.3378.3373.04
all-Indo-e5 Small-v368.1278.2273.09
all-Indo-e5 Small-v468.3378.4173.23
distiluse-base-multilingual-cased-v241.3554.9348.79
paraphrase-multilingual-mpnet-base-v252.8165.0757.97
multilingual-e5-small70.2079.6174.80
multilingual-e5-base70.0079.5075.16
multilingual-e5-large70.8380.5876.16

TyDiQA

ModelR@1 (%) ↑MRR@10 (%) ↑nDCG@10 (%) ↑
SimCSE-IndoBERT Base61.9469.8973.52
ConGen-IndoBERT Lite Base75.2281.5584.13
ConGen-IndoBERT Base73.0980.3283.29
ConGen-SimCSE-IndoBERT Base72.3879.3782.51
ConGen-Indo-e5 Small84.6089.3091.27
SCT-IndoBERT Base76.8183.1685.87
all-IndoBERT Base88.1491.4792.91
all-IndoBERT Base-v287.6190.9192.31
all-IndoBERT Base-v489.0292.5993.91
all-NusaBERT Base-v492.7494.9595.73
all-NusaBERT Large-v493.6295.7796.56
all-Indo-e5 Small-v293.2795.6396.46
all-Indo-e5 Small-v393.2795.7296.58
all-Indo-e5 Small-v493.4595.6696.43
distiluse-base-multilingual-cased-v270.4477.9481.56
paraphrase-multilingual-mpnet-base-v281.4187.0589.44
multilingual-e5-small91.5094.3495.39
multilingual-e5-base93.4595.8896.69
multilingual-e5-large94.6996.7197.44

Classification

MTEB - Massive Intent Classification (id)

MTEB - Massive Scenario Classification (id)

IndoNLU - Emotion Classification (EmoT)

IndoNLU - Sentiment Analysis (SmSA)

Pair Classification

IndoNLI

Credits

Indonesian Sentence Embeddings is developed with love by:

indonesia
indonesian
natural-language-processing
sbert
semantic-textual-similarity
sentence-embeddings
sentence-transformers
unsupervised-learning

Contributors

w11wo

85 commits

Languages

Jupyter Notebook

86.3%

Python

12.9%