Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 13
How to use kelompoknlp2026dsindo/retriever_260511070554_FINAL with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kelompoknlp2026dsindo/retriever_260511070554_FINAL")
sentences = [
"IPCC overestimate temperature rise",
"While CO 2 absorption and release is always happening as a result of natural processes, the recent rise in CO 2 levels in the atmosphere is known to be mainly due to human (anthropogenic) activity.",
"In November 2017, a second warning to humanity signed by 15,364 scientists from 184 countries stated that \"the current trajectory of potentially catastrophic climate change due to rising greenhouse gases from burning fossil fuels, deforestation, and agricultural production – particularly from farming ruminants for meat consumption\" is \"especially troubling\".",
"The IPCC (2007) estimates that the expected rise in temperature due to a doubling of CO2 to be about 3 °C (5.4 °F), ± 1.5°."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for retrieval.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Normalize({})
)
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
# Download from the 🤗 Hub
model = SentenceTransformer("kelompoknlp2026dsindo/retriever_260511070554_FINAL")
# Run inference
sentences = [
'Measurements indicating that 2017 had relatively more sea ice in the Arctic and less melting of glacial ice in Greenland casts scientific doubt on the reality of global warming.',
'The effects of global warming in the Arctic, or climate change in the Arctic include rising air and water temperatures, loss of sea ice, and melting of the Greenland ice sheet with a related cold temperature anomaly, observed since the 1970s.',
'Human-caused increases in greenhouse gases are responsible for most of the observed global average surface warming of roughly 0.8\u202f°C (1.5\u202f°F) over the past 140 years.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.5034, 0.2555],
# [0.5034, 1.0000, 0.4109],
# [0.2555, 0.4109, 1.0000]])
devInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.2389 |
| cosine_accuracy@3 | 0.469 |
| cosine_accuracy@5 | 0.5752 |
| cosine_accuracy@10 | 0.6726 |
| cosine_precision@1 | 0.2389 |
| cosine_precision@3 | 0.1947 |
| cosine_precision@5 | 0.1575 |
| cosine_precision@10 | 0.1053 |
| cosine_precision@50 | 0.0331 |
| cosine_precision@100 | 0.0185 |
| cosine_precision@200 | 0.0102 |
| cosine_recall@1 | 0.1121 |
| cosine_recall@3 | 0.2397 |
| cosine_recall@5 | 0.3314 |
| cosine_recall@10 | 0.4282 |
| cosine_recall@50 | 0.6518 |
| cosine_recall@100 | 0.7305 |
| cosine_recall@200 | 0.8034 |
| cosine_ndcg@10 | 0.324 |
| cosine_mrr@10 | 0.3777 |
| cosine_map@100 | 0.2577 |
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| details |
|
|
| anchor | positive |
|---|---|
Not only is there no scientific evidence that CO2 is a pollutant, higher CO2 concentrations actually help ecosystems support more plant and animal life. |
At very high concentrations (100 times atmospheric concentration, or greater), carbon dioxide can be toxic to animal life, so raising the concentration to 10,000 ppm (1%) or higher for several hours will eliminate pests such as whiteflies and spider mites in a greenhouse. |
Not only is there no scientific evidence that CO2 is a pollutant, higher CO2 concentrations actually help ecosystems support more plant and animal life. |
Plants can grow as much as 50 percent faster in concentrations of 1,000 ppm CO 2 when compared with ambient conditions, though this assumes no change in climate and no limitation on other nutrients. |
Not only is there no scientific evidence that CO2 is a pollutant, higher CO2 concentrations actually help ecosystems support more plant and animal life. |
Higher carbon dioxide concentrations will favourably affect plant growth and demand for water. |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 16per_device_eval_batch_size: 16learning_rate: 1e-05num_train_epochs: 20warmup_steps: 100data_seed: 42load_best_model_at_end: Truebatch_sampler: no_duplicatesdo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 1e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 20max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 100log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: 42bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': 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: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Nonegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Truepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueuse_cache: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | dev_cosine_ndcg@10 |
|---|---|---|---|
| 0.0365 | 5 | 0.8437 | - |
| 0.0730 | 10 | 0.8164 | - |
| 0.1095 | 15 | 0.8009 | - |
| 0.1460 | 20 | 0.7637 | - |
| 0.1825 | 25 | 0.8168 | - |
| 0.2190 | 30 | 0.8028 | - |
| 0.2555 | 35 | 0.6182 | - |
| 0.2920 | 40 | 0.6689 | - |
| 0.3285 | 45 | 0.8032 | - |
| 0.3650 | 50 | 0.6298 | - |
| 0.4015 | 55 | 0.6443 | - |
| 0.4380 | 60 | 0.6813 | - |
| 0.4745 | 65 | 0.4928 | - |
| 0.5109 | 70 | 0.8207 | - |
| 0.5474 | 75 | 0.5841 | - |
| 0.5839 | 80 | 0.5238 | - |
| 0.6204 | 85 | 0.4142 | - |
| 0.6569 | 90 | 0.6077 | - |
| 0.6934 | 95 | 0.4521 | - |
| 0.7299 | 100 | 0.5201 | - |
| 0.7664 | 105 | 0.5142 | - |
| 0.8029 | 110 | 0.4498 | - |
| 0.8394 | 115 | 0.5953 | - |
| 0.8759 | 120 | 0.3598 | - |
| 0.9124 | 125 | 0.5734 | - |
| 0.9489 | 130 | 0.4794 | - |
| 0.9854 | 135 | 0.4036 | - |
| 1.0 | 137 | - | 0.3189 |
| 1.0219 | 140 | 0.3969 | - |
| 1.0584 | 145 | 0.4520 | - |
| 1.0949 | 150 | 0.4475 | - |
| 1.1314 | 155 | 0.5730 | - |
| 1.1679 | 160 | 0.5064 | - |
| 1.2044 | 165 | 0.3858 | - |
| 1.2409 | 170 | 0.4059 | - |
| 1.2774 | 175 | 0.1969 | - |
| 1.3139 | 180 | 0.6806 | - |
| 1.3504 | 185 | 0.4008 | - |
| 1.3869 | 190 | 0.3313 | - |
| 1.4234 | 195 | 0.5591 | - |
| 1.4599 | 200 | 0.3068 | - |
| 1.4964 | 205 | 0.2700 | - |
| 1.5328 | 210 | 0.3596 | - |
| 1.5693 | 215 | 0.4863 | - |
| 1.6058 | 220 | 0.3552 | - |
| 1.6423 | 225 | 0.3481 | - |
| 1.6788 | 230 | 0.3418 | - |
| 1.7153 | 235 | 0.5629 | - |
| 1.7518 | 240 | 0.4146 | - |
| 1.7883 | 245 | 0.5223 | - |
| 1.8248 | 250 | 0.4027 | - |
| 1.8613 | 255 | 0.3733 | - |
| 1.8978 | 260 | 0.3287 | - |
| 1.9343 | 265 | 0.3615 | - |
| 1.9708 | 270 | 0.2782 | - |
| 2.0 | 274 | - | 0.3254 |
| 2.0073 | 275 | 0.4479 | - |
| 2.0438 | 280 | 0.2815 | - |
| 2.0803 | 285 | 0.3969 | - |
| 2.1168 | 290 | 0.3915 | - |
| 2.1533 | 295 | 0.4366 | - |
| 2.1898 | 300 | 0.3599 | - |
| 2.2263 | 305 | 0.2776 | - |
| 2.2628 | 310 | 0.2626 | - |
| 2.2993 | 315 | 0.3017 | - |
| 2.3358 | 320 | 0.3362 | - |
| 2.3723 | 325 | 0.2068 | - |
| 2.4088 | 330 | 0.2746 | - |
| 2.4453 | 335 | 0.3807 | - |
| 2.4818 | 340 | 0.2927 | - |
| 2.5182 | 345 | 0.2699 | - |
| 2.5547 | 350 | 0.2439 | - |
| 2.5912 | 355 | 0.3890 | - |
| 2.6277 | 360 | 0.5438 | - |
| 2.6642 | 365 | 0.4341 | - |
| 2.7007 | 370 | 0.2560 | - |
| 2.7372 | 375 | 0.1545 | - |
| 2.7737 | 380 | 0.1854 | - |
| 2.8102 | 385 | 0.4939 | - |
| 2.8467 | 390 | 0.2932 | - |
| 2.8832 | 395 | 0.3529 | - |
| 2.9197 | 400 | 0.2541 | - |
| 2.9562 | 405 | 0.2895 | - |
| 2.9927 | 410 | 0.3107 | - |
| 3.0 | 411 | - | 0.3277 |
| 3.0292 | 415 | 0.3130 | - |
| 3.0657 | 420 | 0.2742 | - |
| 3.1022 | 425 | 0.2136 | - |
| 3.1387 | 430 | 0.1759 | - |
| 3.1752 | 435 | 0.2413 | - |
| 3.2117 | 440 | 0.2888 | - |
| 3.2482 | 445 | 0.1988 | - |
| 3.2847 | 450 | 0.2650 | - |
| 3.3212 | 455 | 0.1097 | - |
| 3.3577 | 460 | 0.2162 | - |
| 3.3942 | 465 | 0.2702 | - |
| 3.4307 | 470 | 0.2485 | - |
| 3.4672 | 475 | 0.2010 | - |
| 3.5036 | 480 | 0.2736 | - |
| 3.5401 | 485 | 0.2912 | - |
| 3.5766 | 490 | 0.3467 | - |
| 3.6131 | 495 | 0.2874 | - |
| 3.6496 | 500 | 0.2772 | - |
| 3.6861 | 505 | 0.3618 | - |
| 3.7226 | 510 | 0.1875 | - |
| 3.7591 | 515 | 0.2509 | - |
| 3.7956 | 520 | 0.2517 | - |
| 3.8321 | 525 | 0.2589 | - |
| 3.8686 | 530 | 0.3354 | - |
| 3.9051 | 535 | 0.2970 | - |
| 3.9416 | 540 | 0.2349 | - |
| 3.9781 | 545 | 0.1915 | - |
| 4.0 | 548 | - | 0.3205 |
| 4.0146 | 550 | 0.1950 | - |
| 4.0511 | 555 | 0.2137 | - |
| 4.0876 | 560 | 0.2170 | - |
| 4.1241 | 565 | 0.3080 | - |
| 4.1606 | 570 | 0.2038 | - |
| 4.1971 | 575 | 0.1622 | - |
| 4.2336 | 580 | 0.1701 | - |
| 4.2701 | 585 | 0.1806 | - |
| 4.3066 | 590 | 0.2083 | - |
| 4.3431 | 595 | 0.2606 | - |
| 4.3796 | 600 | 0.4207 | - |
| 4.4161 | 605 | 0.2372 | - |
| 4.4526 | 610 | 0.1963 | - |
| 4.4891 | 615 | 0.1232 | - |
| 4.5255 | 620 | 0.1927 | - |
| 4.5620 | 625 | 0.2543 | - |
| 4.5985 | 630 | 0.2017 | - |
| 4.6350 | 635 | 0.2134 | - |
| 4.6715 | 640 | 0.2981 | - |
| 4.7080 | 645 | 0.2670 | - |
| 4.7445 | 650 | 0.2822 | - |
| 4.7810 | 655 | 0.2664 | - |
| 4.8175 | 660 | 0.2651 | - |
| 4.8540 | 665 | 0.1945 | - |
| 4.8905 | 670 | 0.2803 | - |
| 4.9270 | 675 | 0.3401 | - |
| 4.9635 | 680 | 0.2055 | - |
| 5.0 | 685 | 0.2808 | 0.3240 |
@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",
}
@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},
}
Base model
sentence-transformers/all-MiniLM-L6-v2