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-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("huudan123/stage1")
5# Run inference
6sentences = [
7 'Báo đen đã editorialized chống lại những cuộc viếng_thăm của farrakhan với các nhà độc_tài châu phi .',
8 'Báo đen đã viết về quá_khứ của farrakhan .',
9 'Báo đen từ_chối yểm_trợ cho farrakhan .',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 768]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]sts-devEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.4203 |
| spearman_cosine | 0.5148 |
| pearson_manhattan | 0.5605 |
| spearman_manhattan | 0.5792 |
| pearson_euclidean | 0.471 |
| spearman_euclidean | 0.5087 |
| pearson_dot | 0.3924 |
| spearman_dot | 0.4338 |
| pearson_max | 0.5605 |
| spearman_max | 0.5792 |
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
Tem đầy màu_sắc của madeira , cũng như tiền xu , ghi_chép ngân_hàng , và các mặt_hàng khác như bưu_thiếp là mối quan_tâm đến nhiều nhà sưu_tập . | Các nhà sưu_tập sẽ thích ghé thăm madeira bởi_vì những phân_chia lớn của tem , ghi_chép ngân_hàng , bưu_thiếp , và nhiều mặt_hàng khác họ có_thể đọc được . | Mọi người quan_tâm đến việc bắt_đầu bộ sưu_tập mới nên thoát madeira và đi du_lịch phía bắc , nơi họ có khả_năng tìm thấy các cửa_hàng tốt . |
Cẩn_thận đấy , ông inglethorp . Poirot bị bồn_chồn . | Hãy chăm_sóc ông inglethorp . | Không cần phải cẩn_thận với anh ta . |
Phải có một_chút hoài_nghi về trải nghiệm cá_nhân của sperling với trò_chơi . | Hãy suy_nghĩ về những tác_động khi nhìn vào kinh_nghiệm của anh ấy . | Một người có_thể lấy trải nghiệm cá_nhân của sperling với giá_trị mặt . |
TripletLoss with these parameters:
1{
2 "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
3 "triplet_margin": 5
4}anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
Tình_yêu , anh có muốn em trở_thành kassandra lubbock của anh không ? | Tôi có_thể là kassandra lubbock của anh . | Tôi từ_chối trở_thành kassandra lubbock của anh . |
Ví_dụ , trong mùa thu năm 1997 , ủy ban điều_trị hạt_nhân ( nrc ) văn_phòng thanh_tra tướng liệu nrc để có được quan_điểm của họ trên văn_hóa an_toàn của đại_lý . | Nhân_viên nrc đã được hỏi về quan_điểm của họ trên văn_hóa an_toàn của đại_lý . | Các nhân_viên không bao_giờ quan_sát về quan_điểm của họ về văn_hóa an_toàn của đại_lý trong mùa thu năm 1997 . |
Mỗi năm kem của trẻ nghệ và comedic tài_năng làm cho nó đường đến edinburgh , và fringe đã lớn lên trong việc huấn_luyện lớn nhất trong khung_cảnh lớn nhất cho các diễn_viên phát_triển trên thế_giới . | Tài_năng mới đến edinburgh . | Tài_năng mới đến dublin . |
TripletLoss with these parameters:
1{
2 "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
3 "triplet_margin": 5
4}overwrite_output_dir: Trueeval_strategy: epochper_device_train_batch_size: 128per_device_eval_batch_size: 128num_train_epochs: 20lr_scheduler_type: cosinewarmup_ratio: 0.05fp16: Trueload_best_model_at_end: Truegradient_checkpointing: Trueoverwrite_output_dir: Truedo_predict: Falseeval_strategy: epochprediction_loss_only: Trueper_device_train_batch_size: 128per_device_eval_batch_size: 128per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 20max_steps: -1lr_scheduler_type: cosinelr_scheduler_kwargs: {}warmup_ratio: 0.05warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Falsehub_always_push: Falsegradient_checkpointing: Truegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falsebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | loss | sts-dev_spearman_cosine |
|---|---|---|---|---|
| 0 | 0 | - | - | 0.6643 |
| 0.0626 | 50 | 4.6946 | - | - |
| 0.1252 | 100 | 4.031 | - | - |
| 0.1877 | 150 | 2.7654 | - | - |
| 0.2503 | 200 | 2.4176 | - | - |
| 0.3129 | 250 | 2.1111 | - | - |
| 0.3755 | 300 | 2.0263 | - | - |
| 0.4380 | 350 | 1.9296 | - | - |
| 0.5006 | 400 | 1.7793 | - | - |
| 0.5632 | 450 | 1.7903 | - | - |
| 0.6258 | 500 | 1.7638 | - | - |
| 0.6884 | 550 | 1.7042 | - | - |
| 0.7509 | 600 | 1.7038 | - | - |
| 0.8135 | 650 | 1.6221 | - | - |
| 0.8761 | 700 | 1.6172 | - | - |
| 0.9387 | 750 | 1.6227 | - | - |
| 1.0 | 799 | - | 1.5275 | 0.5219 |
| 1.0013 | 800 | 1.6264 | - | - |
| 1.0638 | 850 | 1.364 | - | - |
| 1.1264 | 900 | 1.4447 | - | - |
| 1.1890 | 950 | 1.4161 | - | - |
| 1.2516 | 1000 | 1.3575 | - | - |
| 1.3141 | 1050 | 1.3554 | - | - |
| 1.3767 | 1100 | 1.378 | - | - |
| 1.4393 | 1150 | 1.3806 | - | - |
| 1.5019 | 1200 | 1.3089 | - | - |
| 1.5645 | 1250 | 1.4314 | - | - |
| 1.6270 | 1300 | 1.3672 | - | - |
| 1.6896 | 1350 | 1.3777 | - | - |
| 1.7522 | 1400 | 1.3282 | - | - |
| 1.8148 | 1450 | 1.3432 | - | - |
| 1.8773 | 1500 | 1.3101 | - | - |
| 1.9399 | 1550 | 1.2919 | - | - |
| 2.0 | 1598 | - | 1.3643 | 0.5667 |
| 2.0025 | 1600 | 1.2969 | - | - |
| 2.0651 | 1650 | 0.9629 | - | - |
| 2.1277 | 1700 | 0.9878 | - | - |
| 2.1902 | 1750 | 0.9437 | - | - |
| 2.2528 | 1800 | 0.9832 | - | - |
| 2.3154 | 1850 | 0.9584 | - | - |
| 2.3780 | 1900 | 1.0689 | - | - |
| 2.4406 | 1950 | 1.0579 | - | - |
| 2.5031 | 2000 | 0.9888 | - | - |
| 2.5657 | 2050 | 0.9452 | - | - |
| 2.6283 | 2100 | 0.9378 | - | - |
| 2.6909 | 2150 | 0.9553 | - | - |
| 2.7534 | 2200 | 0.9337 | - | - |
| 2.8160 | 2250 | 1.0184 | - | - |
| 2.8786 | 2300 | 0.9663 | - | - |
| 2.9412 | 2350 | 0.9686 | - | - |
| 3.0 | 2397 | - | 1.3488 | 0.5442 |
| 3.0038 | 2400 | 0.9618 | - | - |
| 3.0663 | 2450 | 0.6878 | - | - |
| 3.1289 | 2500 | 0.6883 | - | - |
| 3.1915 | 2550 | 0.6498 | - | - |
| 3.2541 | 2600 | 0.6651 | - | - |
| 3.3166 | 2650 | 0.6554 | - | - |
| 3.3792 | 2700 | 0.7033 | - | - |
| 3.4418 | 2750 | 0.6416 | - | - |
| 3.5044 | 2800 | 0.7068 | - | - |
| 3.5670 | 2850 | 0.6834 | - | - |
| 3.6295 | 2900 | 0.7099 | - | - |
| 3.6921 | 2950 | 0.7306 | - | - |
| 3.7547 | 3000 | 0.7105 | - | - |
| 3.8173 | 3050 | 0.7072 | - | - |
| 3.8798 | 3100 | 0.7248 | - | - |
| 3.9424 | 3150 | 0.7216 | - | - |
| 4.0 | 3196 | - | 1.3358 | 0.5307 |
| 4.0050 | 3200 | 0.693 | - | - |
| 4.0676 | 3250 | 0.4741 | - | - |
| 4.1302 | 3300 | 0.4593 | - | - |
| 4.1927 | 3350 | 0.449 | - | - |
| 4.2553 | 3400 | 0.4326 | - | - |
| 4.3179 | 3450 | 0.4488 | - | - |
| 4.3805 | 3500 | 0.4762 | - | - |
| 4.4431 | 3550 | 0.4723 | - | - |
| 4.5056 | 3600 | 0.4713 | - | - |
| 4.5682 | 3650 | 0.4612 | - | - |
| 4.6308 | 3700 | 0.4537 | - | - |
| 4.6934 | 3750 | 0.4928 | - | - |
| 4.7559 | 3800 | 0.4568 | - | - |
| 4.8185 | 3850 | 0.4771 | - | - |
| 4.8811 | 3900 | 0.4688 | - | - |
| 4.9437 | 3950 | 0.4549 | - | - |
| 5.0 | 3995 | - | 1.4027 | 0.5360 |
| 5.0063 | 4000 | 0.5048 | - | - |
| 5.0688 | 4050 | 0.2822 | - | - |
| 5.1314 | 4100 | 0.3069 | - | - |
| 5.1940 | 4150 | 0.2971 | - | - |
| 5.2566 | 4200 | 0.3191 | - | - |
| 5.3191 | 4250 | 0.3023 | - | - |
| 5.3817 | 4300 | 0.3224 | - | - |
| 5.4443 | 4350 | 0.3114 | - | - |
| 5.5069 | 4400 | 0.3098 | - | - |
| 5.5695 | 4450 | 0.3071 | - | - |
| 5.6320 | 4500 | 0.3478 | - | - |
| 5.6946 | 4550 | 0.3288 | - | - |
| 5.7572 | 4600 | 0.3373 | - | - |
| 5.8198 | 4650 | 0.3577 | - | - |
| 5.8824 | 4700 | 0.331 | - | - |
| 5.9449 | 4750 | 0.3132 | - | - |
| 6.0 | 4794 | - | 1.4036 | 0.5148 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{hermans2017defense,
2 title={In Defense of the Triplet Loss for Person Re-Identification},
3 author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
4 year={2017},
5 eprint={1703.07737},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}