SentenceTransformer based on contextboxai/halong_embedding
This is a sentence-transformers model finetuned from contextboxai/halong_embedding on the vietnamese-embedding-dataset dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: contextboxai/halong_embedding
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text
- Training Dataset:
- vietnamese-embedding-dataset
Model Sources
Full Model Architecture
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'XLMRobertaModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Normalize({})
)
Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("phuhuyqhqb/vietnamese-embedding-finetuned")
sentences = [
'Bên phải và chúng_tôi có đủ cho bạn biết um_thực_phẩm lưu_trữ và đủ ơ_pin và tất_cả các loại thứ',
'Chúng_ta có đủ không_gian cho kho thức_ăn , pin , và vậy thì sao ?',
'Điều tốt nhất_là để chắc_chắn để loại_bỏ không_gian cho thực_phẩm lưu_trữ , phải không ?',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
similarities = model.similarity(embeddings, embeddings)
print(similarities)
Evaluation
Metrics
Information Retrieval
| Metric |
Value |
| cosine_accuracy@1 |
0.8112 |
| cosine_accuracy@3 |
0.8819 |
| cosine_accuracy@10 |
0.9256 |
| cosine_precision@1 |
0.8112 |
| cosine_precision@3 |
0.294 |
| cosine_precision@10 |
0.0926 |
| cosine_recall@1 |
0.8112 |
| cosine_recall@3 |
0.8819 |
| cosine_recall@10 |
0.9256 |
| cosine_ndcg@10 |
0.8694 |
| cosine_mrr@10 |
0.8514 |
| cosine_map@10 |
0.8514 |
Information Retrieval
| Metric |
Value |
| cosine_accuracy@10 |
0.8436 |
| cosine_precision@1 |
0.682 |
| cosine_precision@3 |
0.2573 |
| cosine_precision@5 |
0.161 |
| cosine_precision@10 |
0.0844 |
| cosine_recall@1 |
0.682 |
| cosine_recall@3 |
0.772 |
| cosine_recall@5 |
0.8052 |
| cosine_recall@10 |
0.8436 |
| cosine_ndcg@10 |
0.7613 |
| cosine_mrr@10 |
0.7352 |
| cosine_map@100 |
0.739 |
Information Retrieval
| Metric |
Value |
| cosine_accuracy@10 |
0.8912 |
| cosine_precision@1 |
0.752 |
| cosine_precision@3 |
0.2775 |
| cosine_precision@5 |
0.1716 |
| cosine_precision@10 |
0.0891 |
| cosine_recall@1 |
0.752 |
| cosine_recall@3 |
0.8326 |
| cosine_recall@5 |
0.8578 |
| cosine_recall@10 |
0.8912 |
| cosine_ndcg@10 |
0.8204 |
| cosine_mrr@10 |
0.798 |
| cosine_map@100 |
0.8007 |
Information Retrieval
| Metric |
Value |
| cosine_accuracy@10 |
0.9106 |
| cosine_precision@1 |
0.7852 |
| cosine_precision@3 |
0.2877 |
| cosine_precision@5 |
0.1769 |
| cosine_precision@10 |
0.0911 |
| cosine_recall@1 |
0.7852 |
| cosine_recall@3 |
0.863 |
| cosine_recall@5 |
0.8843 |
| cosine_recall@10 |
0.9106 |
| cosine_ndcg@10 |
0.8485 |
| cosine_mrr@10 |
0.8285 |
| cosine_map@100 |
0.831 |
Information Retrieval
| Metric |
Value |
| cosine_accuracy@10 |
0.9217 |
| cosine_precision@1 |
0.8046 |
| cosine_precision@3 |
0.2927 |
| cosine_precision@5 |
0.1796 |
| cosine_precision@10 |
0.0922 |
| cosine_recall@1 |
0.8046 |
| cosine_recall@3 |
0.878 |
| cosine_recall@5 |
0.8978 |
| cosine_recall@10 |
0.9217 |
| cosine_ndcg@10 |
0.8637 |
| cosine_mrr@10 |
0.845 |
| cosine_map@100 |
0.8473 |
Information Retrieval
| Metric |
Value |
| cosine_accuracy@10 |
0.9263 |
| cosine_precision@1 |
0.8118 |
| cosine_precision@3 |
0.294 |
| cosine_precision@5 |
0.1805 |
| cosine_precision@10 |
0.0926 |
| cosine_recall@1 |
0.8118 |
| cosine_recall@3 |
0.8821 |
| cosine_recall@5 |
0.9026 |
| cosine_recall@10 |
0.9263 |
| cosine_ndcg@10 |
0.8698 |
| cosine_mrr@10 |
0.8517 |
| cosine_map@100 |
0.8537 |
Training Details
Training Dataset
vietnamese-embedding-dataset
- Dataset: vietnamese-embedding-dataset
- Size: 121,349 training samples
- Columns:
anchor, pos, hard_neg, positive, and hard_negative
- Approximate statistics based on the first 1000 samples:
|
anchor |
pos |
hard_neg |
positive |
hard_negative |
| type |
string |
string |
string |
string |
string |
| details |
- min: 6 tokens
- mean: 49.6 tokens
- max: 411 tokens
|
- min: 6 tokens
- mean: 25.12 tokens
- max: 120 tokens
|
- min: 7 tokens
- mean: 23.85 tokens
- max: 115 tokens
|
- min: 6 tokens
- mean: 25.66 tokens
- max: 125 tokens
|
- min: 7 tokens
- mean: 24.26 tokens
- max: 120 tokens
|
- Samples:
| anchor |
pos |
hard_neg |
positive |
hard_negative |
Lsm hoạt_động như một công_ty luật , nhưng không tính phí cho khách_hàng của họ . |
Các khách_hàng không cần phải trả tiền cho dịch_vụ . |
Có một mức giá cao cho các khách_hàng của lsm . |
Các khách_hàng không cần phải trả tiền cho dịch_vụ . |
Có một mức giá cao cho các khách_hàng của lsm . |
Hay , tốt hơn là , anh ta nên xây nhà cho người nghèo dưới sự giám_sát của jimmy Carter . |
Sẽ tốt hơn nếu anh ta chỉ xây nhà cho người nghèo dưới sự giám_sát của jimmy Carter . |
Anh ta hiện đang xây_dựng nhà cho người nghèo dưới sự giám_sát của jimmy Carter . |
Sẽ tốt hơn nếu anh ta chỉ xây nhà cho người nghèo dưới sự giám_sát của jimmy Carter . |
Anh ta hiện đang xây_dựng nhà cho người nghèo dưới sự giám_sát của jimmy Carter . |
Tôi sẽ khuyến_khích một kế_hoạch để thách_thức chúng_ta thay_đổi và mở_rộng_nhiệm_vụ của chúng_ta . |
Tôi khuyến_khích các thay_đổi lịch_trình để mở_rộng nhiệm_vụ của chúng_tôi . |
Một sự thay_đổi lịch_sự sẽ không giúp chúng_tôi phát_triển hoặc mở_rộng nhiệm_vụ của chúng_tôi . |
Tôi khuyến_khích các thay_đổi lịch_trình để mở_rộng_nhiệm_vụ của chúng_tôi . |
Một sự thay_đổi_lịch_sự sẽ không giúp chúng_tôi phát_triển hoặc mở_rộng_nhiệm_vụ của chúng_tôi . |
- Loss:
MatryoshkaLoss with these parameters:{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
Evaluation Dataset
vietnamese-embedding-dataset
- Dataset: vietnamese-embedding-dataset
- Size: 6,387 evaluation samples
- Columns:
anchor, pos, hard_neg, positive, and hard_negative
- Approximate statistics based on the first 1000 samples:
|
anchor |
pos |
hard_neg |
positive |
hard_negative |
| type |
string |
string |
string |
string |
string |
| details |
- min: 5 tokens
- mean: 46.65 tokens
- max: 223 tokens
|
- min: 5 tokens
- mean: 24.97 tokens
- max: 99 tokens
|
- min: 6 tokens
- mean: 23.72 tokens
- max: 71 tokens
|
- min: 6 tokens
- mean: 25.48 tokens
- max: 101 tokens
|
- min: 7 tokens
- mean: 24.12 tokens
- max: 74 tokens
|
- Samples:
| anchor |
pos |
hard_neg |
positive |
hard_negative |
Thomas Alexander_Aleinikoff là một giáo_sư pháp_luật tại trung_tâm luật trường đại_học_georgetown , nơi ông ấy đã dạy các khóa_học ở nhập_cư và luật_tị_nạn , luật_công_dân , luật_pháp_luật , và luật_pháp_công_cộng và luật_pháp từ tháng 1997 . Năm 1997 . |
Ông ấy có kiến_thức về công_dân và luật nhập_cư vĩ_đại . |
Thomas Alexander Aleinkoff là một giáo_sư khoa_học . |
Ông ấy có kiến_thức về công_dân và luật nhập_cư_vĩ_đại . |
Thomas Alexander_Aleinkoff là một giáo_sư khoa_học . |
Đúng_vậy , nó có_thể là mùa giải golf chỉ đóng_cửa cho có_lẽ ba tháng ra khỏi năm nếu điều đó nhiều bạn biết chắc_chắn thậm_chí là không nhiều bởi_vì thực_sự |
Sân_Golf đã mở ra cho hầu_hết các năm . |
Đáng tiếc là mùa golf chỉ kéo_dài vài thẳng . |
Sân_Golf đã mở ra cho hầu_hết các năm . |
Đáng tiếc là mùa golf chỉ kéo_dài vài thẳng . |
Tự hỏi về họ theo cách nào |
Anh nghĩ sao về họ ? |
Tại_sao anh lại bận_tâm đến việc suy_nghĩ về họ ? |
Anh nghĩ sao về họ ? |
Tại_sao anh lại bận_tâm đến việc suy_nghĩ về họ ? |
- Loss:
MatryoshkaLoss with these parameters:{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 128
learning_rate: 2e-05
lr_scheduler_type: cosine
warmup_steps: 0.1
weight_decay: 0.01
bf16: True
gradient_checkpointing: True
per_device_eval_batch_size: 64
load_best_model_at_end: True
dataloader_num_workers: 4
batch_sampler: no_duplicates
All Hyperparameters
Click to expand
per_device_train_batch_size: 128
num_train_epochs: 3
max_steps: -1
learning_rate: 2e-05
lr_scheduler_type: cosine
lr_scheduler_kwargs: None
warmup_steps: 0.1
optim: adamw_torch
optim_args: None
weight_decay: 0.01
adam_beta1: 0.9
adam_beta2: 0.999
adam_epsilon: 1e-08
optim_target_modules: None
gradient_accumulation_steps: 1
average_tokens_across_devices: True
max_grad_norm: 1.0
label_smoothing_factor: 0.0
bf16: True
fp16: False
bf16_full_eval: False
fp16_full_eval: False
tf32: None
gradient_checkpointing: True
gradient_checkpointing_kwargs: None
torch_compile: False
torch_compile_backend: None
torch_compile_mode: None
use_liger_kernel: False
liger_kernel_config: None
use_cache: False
neftune_noise_alpha: None
torch_empty_cache_steps: None
auto_find_batch_size: False
log_on_each_node: True
logging_nan_inf_filter: True
include_num_input_tokens_seen: no
log_level: passive
log_level_replica: warning
disable_tqdm: False
project: huggingface
trackio_space_id: None
trackio_bucket_id: None
trackio_static_space_id: None
per_device_eval_batch_size: 64
prediction_loss_only: True
eval_on_start: False
eval_do_concat_batches: True
eval_use_gather_object: False
eval_accumulation_steps: None
include_for_metrics: []
batch_eval_metrics: False
save_only_model: False
save_on_each_node: False
enable_jit_checkpoint: False
push_to_hub: False
hub_private_repo: None
hub_model_id: None
hub_strategy: every_save
hub_always_push: False
hub_revision: None
load_best_model_at_end: True
ignore_data_skip: False
restore_callback_states_from_checkpoint: False
full_determinism: False
seed: 42
data_seed: None
use_cpu: False
accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
parallelism_config: None
dataloader_drop_last: False
dataloader_num_workers: 4
dataloader_pin_memory: True
dataloader_persistent_workers: False
dataloader_prefetch_factor: None
remove_unused_columns: True
label_names: None
train_sampling_strategy: random
length_column_name: length
ddp_find_unused_parameters: None
ddp_bucket_cap_mb: None
ddp_broadcast_buffers: False
ddp_static_graph: None
ddp_backend: None
ddp_timeout: 1800
fsdp: []
fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
deepspeed: None
debug: []
skip_memory_metrics: True
do_predict: False
resume_from_checkpoint: None
warmup_ratio: None
local_rank: -1
prompts: None
batch_sampler: no_duplicates
multi_dataset_batch_sampler: proportional
router_mapping: {}
learning_rate_mapping: {}
Training Logs
| Epoch |
Step |
Training Loss |
Validation Loss |
vi-val_cosine_ndcg@10 |
vi-val-dim64_cosine_ndcg@10 |
vi-val-dim128_cosine_ndcg@10 |
vi-val-dim256_cosine_ndcg@10 |
vi-val-dim512_cosine_ndcg@10 |
vi-val-dim768_cosine_ndcg@10 |
| 0.0527 |
50 |
9.9210 |
- |
- |
- |
- |
- |
- |
- |
| 0.1054 |
100 |
10.0054 |
- |
- |
- |
- |
- |
- |
- |
| 0.1581 |
150 |
9.5957 |
- |
- |
- |
- |
- |
- |
- |
| 0.2107 |
200 |
9.2083 |
- |
- |
- |
- |
- |
- |
- |
| 0.2634 |
250 |
8.7694 |
- |
- |
- |
- |
- |
- |
- |
| 0.3161 |
300 |
8.4289 |
7.1498 |
0.8531 |
- |
- |
- |
- |
- |
| 0.3688 |
350 |
8.4130 |
- |
- |
- |
- |
- |
- |
- |
| 0.4215 |
400 |
8.0878 |
- |
- |
- |
- |
- |
- |
- |
| 0.4742 |
450 |
8.0552 |
- |
- |
- |
- |
- |
- |
- |
| 0.5269 |
500 |
8.0527 |
- |
- |
- |
- |
- |
- |
- |
| 0.5796 |
550 |
7.8329 |
- |
- |
- |
- |
- |
- |
- |
| 0.6322 |
600 |
7.7221 |
6.7405 |
0.8613 |
- |
- |
- |
- |
- |
| 0.6849 |
650 |
7.7151 |
- |
- |
- |
- |
- |
- |
- |
| 0.7376 |
700 |
7.6772 |
- |
- |
- |
- |
- |
- |
- |
| 0.7903 |
750 |
7.6500 |
- |
- |
- |
- |
- |
- |
- |
| 0.8430 |
800 |
7.8399 |
- |
- |
- |
- |
- |
- |
- |
| 0.8957 |
850 |
7.5724 |
- |
- |
- |
- |
- |
- |
- |
| 0.9484 |
900 |
7.5979 |
6.5940 |
0.8660 |
- |
- |
- |
- |
- |
| 1.0011 |
950 |
7.5398 |
- |
- |
- |
- |
- |
- |
- |
| 1.0537 |
1000 |
7.5890 |
- |
- |
- |
- |
- |
- |
- |
| 1.1064 |
1050 |
7.5932 |
- |
- |
- |
- |
- |
- |
- |
| 1.1591 |
1100 |
7.5027 |
- |
- |
- |
- |
- |
- |
- |
| 1.2118 |
1150 |
7.4633 |
- |
- |
- |
- |
- |
- |
- |
| 1.2645 |
1200 |
7.4652 |
6.5259 |
0.8672 |
- |
- |
- |
- |
- |
| 1.3172 |
1250 |
7.3907 |
- |
- |
- |
- |
- |
- |
- |
| 1.3699 |
1300 |
7.3275 |
- |
- |
- |
- |
- |
- |
- |
| 1.4226 |
1350 |
7.4548 |
- |
- |
- |
- |
- |
- |
- |
| 1.4752 |
1400 |
7.3204 |
- |
- |
- |
- |
- |
- |
- |
| 1.5279 |
1450 |
7.5984 |
- |
- |
- |
- |
- |
- |
- |
| 1.5806 |
1500 |
7.3079 |
6.4994 |
0.8686 |
- |
- |
- |
- |
- |
| 1.6333 |
1550 |
7.5538 |
- |
- |
- |
- |
- |
- |
- |
| 1.6860 |
1600 |
7.4968 |
- |
- |
- |
- |
- |
- |
- |
| 1.7387 |
1650 |
7.4145 |
- |
- |
- |
- |
- |
- |
- |
| 1.7914 |
1700 |
7.4465 |
- |
- |
- |
- |
- |
- |
- |
| 1.8440 |
1750 |
7.4263 |
- |
- |
- |
- |
- |
- |
- |
| 1.8967 |
1800 |
7.3303 |
6.4765 |
0.8694 |
- |
- |
- |
- |
- |
| 1.9494 |
1850 |
7.2299 |
- |
- |
- |
- |
- |
- |
- |
| 2.0021 |
1900 |
7.4247 |
- |
- |
- |
- |
- |
- |
- |
| 2.0548 |
1950 |
7.4645 |
- |
- |
- |
- |
- |
- |
- |
| 2.1075 |
2000 |
7.3977 |
- |
- |
- |
- |
- |
- |
- |
| 2.1602 |
2050 |
7.3026 |
- |
- |
- |
- |
- |
- |
- |
| 2.2129 |
2100 |
7.3701 |
6.4712 |
0.8693 |
- |
- |
- |
- |
- |
| 2.2655 |
2150 |
7.3225 |
- |
- |
- |
- |
- |
- |
- |
| 2.3182 |
2200 |
7.5064 |
- |
- |
- |
- |
- |
- |
- |
| 2.3709 |
2250 |
7.3471 |
- |
- |
- |
- |
- |
- |
- |
| 2.4236 |
2300 |
7.3868 |
- |
- |
- |
- |
- |
- |
- |
| 2.4763 |
2350 |
7.3787 |
- |
- |
- |
- |
- |
- |
- |
| 2.529 |
2400 |
7.3058 |
6.4708 |
0.8698 |
- |
- |
- |
- |
- |
| 2.5817 |
2450 |
7.4487 |
- |
- |
- |
- |
- |
- |
- |
| 2.6344 |
2500 |
7.4171 |
- |
- |
- |
- |
- |
- |
- |
| 2.6870 |
2550 |
7.3665 |
- |
- |
- |
- |
- |
- |
- |
| 2.7397 |
2600 |
7.2716 |
- |
- |
- |
- |
- |
- |
- |
| 2.7924 |
2650 |
7.4586 |
- |
- |
- |
- |
- |
- |
- |
| 2.8451 |
2700 |
7.3564 |
6.4701 |
0.8695 |
- |
- |
- |
- |
- |
| 2.8978 |
2750 |
7.4374 |
- |
- |
- |
- |
- |
- |
- |
| 2.9505 |
2800 |
7.3174 |
- |
- |
- |
- |
- |
- |
- |
| 3.0 |
2847 |
- |
6.4711 |
0.8694 |
- |
- |
- |
- |
- |
| -1 |
-1 |
- |
- |
- |
0.7613 |
0.8204 |
0.8485 |
0.8637 |
0.8698 |
- The bold row denotes the saved checkpoint.
Training Time
Framework Versions
- Python: 3.10.9
- Sentence Transformers: 5.4.1
- Transformers: 5.8.0
- PyTorch: 2.6.0+cu124
- Accelerate: 1.13.0
- Datasets: 4.8.5
- Tokenizers: 0.22.2
Citation
BibTeX
Sentence Transformers
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
MatryoshkaLoss
@misc{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
@misc{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}