Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: RobertaModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)pip install -U sentence-transformers
pip install -q pyvi1from sentence_transformers import SentenceTransformer
2from pyvi.ViTokenizer import tokenize
3
4sentences = ["Hà Nội là thủ đô của Việt Nam", "Đà Nẵng là thành phố du lịch"]
5tokenizer_sent = [tokenize(sent) for sent in sentences]
6
7model = SentenceTransformer('dangvantuan/vietnamese-embedding')
8embeddings = model.encode(tokenizer_sent)
9print(embeddings)
101from sentence_transformers import SentenceTransformer
2from sentence_transformers import SentenceTransformer
3from sentence_transformers.readers import InputExample
4from datasets import load_dataset
5from pyvi.ViTokenizer import tokenize
6def convert_dataset(dataset):
7 dataset_samples=[]
8 for df in dataset:
9 score = float(df['score'])/5.0 # Normalize score to range 0 ... 1
10 inp_example = InputExample(texts=[tokenize(df['sentence1']),
11 tokenize(df['sentence2'])], label=score)
12 dataset_samples.append(inp_example)
13 return dataset_samples
14
15# Loading the dataset for evaluation
16vi_sts = load_dataset("doanhieung/vi-stsbenchmark")["train"]
17df_dev = vi_sts.filter(lambda example: example['split'] == 'dev')
18df_test = vi_sts.filter(lambda example: example['split'] == 'test')
19
20# Convert the dataset for evaluation
21
22# For Dev set:
23dev_samples = convert_dataset(df_dev)
24val_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(dev_samples, name='sts-dev')
25val_evaluator(model, output_path="./")
26
27# For Test set:
28test_samples = convert_dataset(df_test)
29test_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(test_samples, name='sts-test')
30test_evaluator(model, output_path="./")| Model | [STSB] | [STS12] | [STS13] | [STS14] | [STS15] | [STS16] | [SICK] | Mean |
|---|---|---|---|---|---|---|---|---|
| dangvantuan/vietnamese-embedding | 84.87 | 87.23 | 85.39 | 82.94 | 86.91 | 79.39 | 82.77 | 84.21 |
| VoVanPhuc/sup-SimCSE-VietNamese-phobert-base | 81.52 | 85.02 | 78.22 | 75.94 | 81.53 | 75.39 | 77.75 | 79.33 |
| keepitreal/vietnamese-sbert | 80.54 | 78.58 | 80.75 | 76.98 | 82.57 | 73.21 | 80.16 | 78.97 |
| bkai-foundation-models/vietnamese-bi-encoder | 73.30 | 67.84 | 71.69 | 69.80 | 78.40 | 74.29 | 76.01 | 73.04 |
| Model | [STSB] | [STS12] | [STS13] | [STS14] | [STS15] | [STS16] | [SICK] | Mean |
|---|---|---|---|---|---|---|---|---|
| dangvantuan/vietnamese-embedding | 84.84 | 79.04 | 85.30 | 81.38 | 87.06 | 79.95 | 79.58 | 82.45 |
| VoVanPhuc/sup-SimCSE-VietNamese-phobert-base | 81.43 | 76.51 | 79.19 | 74.91 | 81.72 | 76.57 | 76.45 | 78.11 |
| keepitreal/vietnamese-sbert | 80.16 | 69.08 | 80.99 | 73.67 | 82.81 | 74.30 | 73.40 | 76.34 |
| bkai-foundation-models/vietnamese-bi-encoder | 72.16 | 63.86 | 71.82 | 66.20 | 78.62 | 74.24 | 70.87 | 71.11 |
@article{reimers2019sentence,
title={Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks},
author={Nils Reimers, Iryna Gurevych},
journal={https://arxiv.org/abs/1908.10084},
year={2019}
}
@article{martin2020camembert,
title={CamemBERT: a Tasty French Language Mode},
author={Martin, Louis and Muller, Benjamin and Su{\'a}rez, Pedro Javier Ortiz and Dupont, Yoann and Romary, Laurent and de la Clergerie, {\'E}ric Villemonte and Seddah, Djam{\'e} and Sagot, Beno{\^\i}t},
journal={Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics},
year={2020}
}
@article{thakur2020augmented,
title={Augmented SBERT: Data Augmentation Method for Improving Bi-Encoders for Pairwise Sentence Scoring Tasks},
author={Thakur, Nandan and Reimers, Nils and Daxenberger, Johannes and Gurevych, Iryna},
journal={arXiv e-prints},
pages={arXiv--2010},
year={2020}