Views
No views yet
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({})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6sentences = [
7 'What is 100 degrees Fahrenheit converted to Celsius?',
8 'Architect a globally distributed microservices deployment platform enforcing zero-trust networking, canary releases with automated rollback based on multi-region SLOs, cross-cloud secrets rotation, and infrastructure cost allocation across AWS, Azure, and GCP.',
9 'What is the default network port for HTTP?',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 384]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities)
18# tensor([[ 1.0000, -0.2282, 0.9992],
19# [-0.2282, 1.0000, -0.2242],
20# [ 0.9992, -0.2242, 1.0000]])sentence and label| sentence | label | |
|---|---|---|
| type | string | int |
| details |
|
|
| sentence | label |
|---|---|
Write a discharge instruction template for patients recovering from total knee replacement surgery, including medication guidelines, physical therapy milestones, and red-flag symptoms. | 1 |
Prove that alpha-beta pruning in game tree search returns identical minimax values as full search for deterministic two-player zero-sum games with perfect information. | 3 |
Explain the zone of proximal development using a specific classroom learning scenario. | 1 |
BatchAllTripletLoss with these parameters:
1{
2 "distance_metric": "euclidean_distance",
3 "margin": 5
4}per_device_train_batch_size: 32num_train_epochs: 20learning_rate: 2e-05warmup_steps: 0.1weight_decay: 0.01batch_sampler: group_by_labelper_device_train_batch_size: 32num_train_epochs: 20max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.01adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 8prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: group_by_labelmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.3704 | 10 | 4.9309 |
| 0.7407 | 20 | 4.9160 |
| 1.1111 | 30 | 4.8961 |
| 1.4815 | 40 | 4.7981 |
| 1.8519 | 50 | 4.6499 |
| 2.2222 | 60 | 4.4857 |
| 2.5926 | 70 | 4.2761 |
| 2.9630 | 80 | 4.1235 |
| 3.3333 | 90 | 4.0387 |
| 3.7037 | 100 | 3.9355 |
| 4.0741 | 110 | 3.9115 |
| 4.4444 | 120 | 3.8240 |
| 4.8148 | 130 | 3.7550 |
| 5.1852 | 140 | 3.7214 |
| 5.5556 | 150 | 3.6528 |
| 5.9259 | 160 | 3.6749 |
| 6.2963 | 170 | 3.6371 |
| 6.6667 | 180 | 3.6124 |
| 7.0370 | 190 | 3.5848 |
| 7.4074 | 200 | 3.5935 |
| 7.7778 | 210 | 3.5504 |
| 8.1481 | 220 | 3.5539 |
| 8.5185 | 230 | 3.5427 |
| 8.8889 | 240 | 3.5122 |
| 9.2593 | 250 | 3.4894 |
| 9.6296 | 260 | 3.5147 |
| 10.0 | 270 | 3.4909 |
| 10.3704 | 280 | 3.5146 |
| 10.7407 | 290 | 3.4988 |
| 11.1111 | 300 | 3.4591 |
| 11.4815 | 310 | 3.4997 |
| 11.8519 | 320 | 3.4847 |
| 12.2222 | 330 | 3.4704 |
| 12.5926 | 340 | 3.4826 |
| 12.9630 | 350 | 3.4474 |
| 13.3333 | 360 | 3.4807 |
| 13.7037 | 370 | 3.4772 |
| 14.0741 | 380 | 3.4373 |
| 14.4444 | 390 | 3.4747 |
| 14.8148 | 400 | 3.4712 |
| 15.1852 | 410 | 3.4310 |
| 15.5556 | 420 | 3.4720 |
| 15.9259 | 430 | 3.4650 |
| 16.2963 | 440 | 3.4394 |
| 16.6667 | 450 | 3.4700 |
| 17.0370 | 460 | 3.4330 |
| 17.4074 | 470 | 3.4684 |
| 17.7778 | 480 | 3.4706 |
| 18.1481 | 490 | 3.4456 |
| 18.5185 | 500 | 3.4681 |
| 18.8889 | 510 | 3.4560 |
| 19.2593 | 520 | 3.4415 |
| 19.6296 | 530 | 3.4683 |
| 20.0 | 540 | 3.4167 |
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}