Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 17
How to use EmiliaLee/k_model with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("EmiliaLee/k_model")
sentences = [
"durable plastic shed for garden supplies",
"stoney resin outdoor 4 ft. 4 in . w x 2 ft. 8 in . d plastic horizontal storage shed Sheds this handy horizontal storage shed can handle any and all of your outdoor organizational needs . ideal for storing garbage cans , lawn and garden products , snow blowers , bicycles , and more , this stylish storage solution is essential in every season . additional features include durable , multi-w doorstyle : double door|primarymaterial : plastic|countryoforigin : united states|shedtype : storage shed|roofstyle : pent|estimatedtimetosetup:30|countryoforigin-additionaldetails : made in usa|overallproductweight:76|interiorheight-toptobottom:43.5|color : gray|doorwidth-sidetoside:46.25|overallwi",
"outdoor 4 ft. w x 2 ft. d plastic vertical tool shed Deck Boxes|Sheds this large vertical shed is designed to supply generous storage space for outdoor gear , tools , equipment , firewood , sporting goods , and more . it 's fashioned with multi-wall resin and is outfitted with adjoining door handles to attach a padlock ( sold separately ) . to augment this unit with s coveragearea:11.23|estimatedtimetosetup:180|approximatedepth-fronttoback:3|windrating:65|overallwidth-sidetoside:53|interiorheight-toptobottom:69.5|overallheight-toptobottom:71.5|primarymaterial : plastic|shedtype : tool shed|overalldepth-fronttoback:32.5|color : mustang brown|countryoforigin-additi",
"suncast golf organizer in black Bike And Sport Racks when it comes to the great outdoors and engaging in such sporting activities as golf , an organizer is just right to keep those accessories in place . it is sure to become your best friend when out playing on the links . producttype : sports rack|finish : black|compatiblebike : |overallheight-toptobottom:37|overallwidth-sidetoside:32|overallproductweight:38.15|mounttype : wall mounted|overalldepth-fronttoback:16|holdingcapacity:2|hooksincluded : no|multi-use : no|installationrequired : yes|productwarranty : yes|adju"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-m3. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.
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': 1024, 'pooling_mode': 'cls', '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("sentence_transformers_model_id")
# Run inference
sentences = [
'compact garage storage shed under 3 feet wide',
'outdoor 2 ft. 9 in . w x 2 ft. d plastic vertical tool shed Sheds with its tall profile , this 22 cubic foot vertical shed is great for storing ladders , long-handled tools , garden accessories , and more when space is at a premium . the durable , all-weather resin construction provides water resistance and uv protection , while the multi-wall panels are engineere interiorwidth-sidetoside:27|interiorheight-toptobottom:69|compatibleshelfpartnumber : xa1182|windrating:65|overallwidth-sidetoside:33|countryoforigin : united states|interiordepth-fronttoback:20.25|levelofassembly : full assembly needed|countryoforigin-additionaldetails : made in usa|doorwidth-sidet',
'garden plastic/metal storage shed Sheds easily add storage space and value to your property with an outdoor garden shed . the metal shed has distinct advantages over traditional wooden models that make it a much more attractive choice for purchase . a metal shed is more affordable and being pre-fabricated significantly cuts down on expens dsmetallic : steel|shedtype : storage shed|color : grey|construction : traditional|overallheight-toptobottom:75.5|countryoforigin-additionaldetails : made in china|warrantylength:1 year|levelofassembly : full assembly needed|overallwidth-sidetoside:126.75|overalldepth-fronttoback:109|overallproductw',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.5560, 0.5587],
# [0.5560, 1.0000, 0.5424],
# [0.5587, 0.5424, 1.0000]])
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
modern 10 inch semi-flush mount light for entryway |
bucholz 1 -light 10 '' semi flush mount Flush Mount Lighting this 1-light semi-flush mount has a sleek , streamlined shape that gives a modern look to your hallway , entryway , or over your dining room table . it has a metal frame and downrod , and an egg-shaped glass shade with an opening at the bottom for light to shine through . the downrod retracts and ro shadematerial : glass|dry , damporwetlocationlisted : dry|whatisdrydamporwetlocationlisted : this indicates whether the fixture is safe to use in dry locations , damp locations ( moist environments ) , or wet locations ( direct exposure to water ) .|estimatedtimetosetup:5|bodyheight-toptobottom:10|w |
weatherford 1 - light 10 '' semi flush mount Flush Mount Lighting marrying modern minimalism and factory flair , this understated one-light flush mount brings a splash of industrial style as it shines a light down on your space . crafted of metal , this fixture features a round canopy and a conical shade with its upper portion left open to provide a peek at the so canopywidth-sidetoside:4.875|recommendedbulbshapecode : a19|warrantylength:1 year|canopydepth-fronttoback:0.75|powersource : hardwired|dssecondaryproductstyle : nautical|canopyheight-toptobottom:4.875|recommendedbulbshape : standard|producttype : flush mount|whatisullisted : the underwriters laborat |
sleek glass pendant light for dining room |
bucholz 1 -light 10 '' semi flush mount Flush Mount Lighting this 1-light semi-flush mount has a sleek , streamlined shape that gives a modern look to your hallway , entryway , or over your dining room table . it has a metal frame and downrod , and an egg-shaped glass shade with an opening at the bottom for light to shine through . the downrod retracts and ro shadematerial : glass|dry , damporwetlocationlisted : dry|whatisdrydamporwetlocationlisted : this indicates whether the fixture is safe to use in dry locations , damp locations ( moist environments ) , or wet locations ( direct exposure to water ) .|estimatedtimetosetup:5|bodyheight-toptobottom:10|w |
6 '' h glass sphere pendant shade ( screw on ) in smoke color : smoke|shape : sphere|overallproductweight:0.67|overalldepth-fronttoback:6|theme : no theme|attachmenttype : screw on|style : modern & contemporary|overallwidth-sidetoside:6|fittersize:3.25|producttype : pendant shade|primarymaterial : glass|overallheight-toptobottom:6| : no|fitterincluded : |
small metal frame flush mount light with glass shade |
bucholz 1 -light 10 '' semi flush mount Flush Mount Lighting this 1-light semi-flush mount has a sleek , streamlined shape that gives a modern look to your hallway , entryway , or over your dining room table . it has a metal frame and downrod , and an egg-shaped glass shade with an opening at the bottom for light to shine through . the downrod retracts and ro shadematerial : glass|dry , damporwetlocationlisted : dry|whatisdrydamporwetlocationlisted : this indicates whether the fixture is safe to use in dry locations , damp locations ( moist environments ) , or wet locations ( direct exposure to water ) .|estimatedtimetosetup:5|bodyheight-toptobottom:10|w |
3 - light semi flush mount Flush Mount Lighting|Commercial Ceiling Lighting it is perfect to transform your dining room or entryway with this charming transitional flush mount ceiling light . bodydepth-fronttoback:16.1|producttype : semi flush mount|recommendedbulbshape : candle|bodydepth-fronttoback:12.2|lightdirection : up|warrantylength:2 years|dssecondaryproductstyle : classic glam|dsprimaryproductstyle : glam|fixturedesign : unique/statement|craftsmanshiptype : handcrafted / hand-fo |
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
}
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
quirky rooster shelf sitters |
4 piece rooster shelf sitter figurine set Decorative Objects add these colorful rooster sitters to shelves , windowsills , and more throughout your home . the set includes four hand-painted roosters with delightful floral accents . each cute sitter has dangling legs and plenty of charm . overallwidth-sidetoside:1.63|geometricshapes : no geometric & shapes|producttype : figurine|subject : animals|nature : no nature|spiritualreligious : no spiritual & religious|structuresbuildings : no structures & buildings|wordstext : no words & text|overallproductweight:0.25|quantity:4|entertainmen |
dunellen farmhouse rooster 2 piece figurine set Decorative Objects be the early bird in grabbing these farmhouse silver metal and wood rooster sculpture by the head and complete your farmhouse set up now . this 2-piece set features two small and medium standing rooster sculptures with a gray finish on the body , and silver on the rest . this will look great as a ce overallwidth-sidetoside:13|color : brown , silver|purposefuldistressingtype : distressed metal|style : farmhouse / country|overallheight-toptobottom:5.1|fantasysci-fi : no fantasy & sci-fi|overallheight-toptobottom:16|nature : no nature|geometricshapes : no geometric & shapes|spiritualreligious : no |
decorative rooster figurines with floral accents |
4 piece rooster shelf sitter figurine set Decorative Objects add these colorful rooster sitters to shelves , windowsills , and more throughout your home . the set includes four hand-painted roosters with delightful floral accents . each cute sitter has dangling legs and plenty of charm . overallwidth-sidetoside:1.63|geometricshapes : no geometric & shapes|producttype : figurine|subject : animals|nature : no nature|spiritualreligious : no spiritual & religious|structuresbuildings : no structures & buildings|wordstext : no words & text|overallproductweight:0.25|quantity:4|entertainmen |
2 piece metal figurine set Decorative Objects the antique style of these two metal rooster decors will bring a fascinating appeal to any rustic , vintage , or antique accent table . with its iron construction , these rooster sculptures will continue to enhance the look of your home interior for years to come . featuring a decorative rustic bron geometricshapes : no geometric & shapes|spiritualreligious : no spiritual & religious|overallwidth-sidetoside:20.47|producttype : figurine|nature : no nature|foodbeverage : no food & beverage|fantasysci-fi : no fantasy & sci-fi|people : no people|agegroup : adult|animals : rooster|overallproductweig |
comfortable anti-fatigue mat for kitchen counter |
catrisha soothing foam comfort anti-fatigue mat Kitchen Mats this anti-fatigue mat provides a full inch of soothing foam comfort for your tired feet . perfect in front of a kitchen counter and has a skid-resistant backing . color : red|pattern : solid color|backingmaterial : polyester|color : brown|shape : rectangle|supplierintendedandapproveduse : non residential use|productcare : machine washable|construction : machine made|color : blue|dssecondaryproductstyle : transitional modern|overalllength-endtoend:30|color : g |
grano hello standing anti-fatigue mat Kitchen Mats use this mat in any part of your home . whether it be the kitchen , laundry room , bathroom , or doorway this elegant mat will bring luscious texture , enduring material , and comfortable steps for your convenience . this perfectly crafted pvc mat is joined with a rubber backing for long-lasting usa pattern : no pattern and not solid color|overalllength-endtoend:30|overalllength-endtoend:47|overallproductweight:2.09|holidayoccasion : no holiday|dssecondaryproductstyle : modern farmhouse|overallheight-toptobottom:0.47|material : synthetics|theme : text|materialdetails:100 % pvc|overallwidth-side |
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: 64num_train_epochs: 1learning_rate: 2e-05warmup_steps: 0.1bf16: Trueper_device_eval_batch_size: 64dataloader_num_workers: 4per_device_train_batch_size: 64num_train_epochs: 1max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_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: Truefp16: 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: 64prediction_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: 4dataloader_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: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.0225 | 100 | 1.1596 | - |
| 0.0450 | 200 | 0.6243 | - |
| 0.0675 | 300 | 0.5484 | - |
| 0.0899 | 400 | 0.4963 | - |
| 0.1124 | 500 | 0.4665 | 0.4796 |
| 0.1349 | 600 | 0.4426 | - |
| 0.1574 | 700 | 0.4353 | - |
| 0.1799 | 800 | 0.4284 | - |
| 0.2024 | 900 | 0.4111 | - |
| 0.2249 | 1000 | 0.3946 | 0.4274 |
| 0.2474 | 1100 | 0.3883 | - |
| 0.2698 | 1200 | 0.3806 | - |
| 0.2923 | 1300 | 0.3590 | - |
| 0.3148 | 1400 | 0.3661 | - |
| 0.3373 | 1500 | 0.3632 | 0.4086 |
| 0.3598 | 1600 | 0.3717 | - |
| 0.3823 | 1700 | 0.3517 | - |
| 0.4048 | 1800 | 0.3428 | - |
| 0.4273 | 1900 | 0.3574 | - |
| 0.4497 | 2000 | 0.3412 | 0.3882 |
| 0.4722 | 2100 | 0.3340 | - |
| 0.4947 | 2200 | 0.3356 | - |
| 0.5172 | 2300 | 0.3261 | - |
| 0.5397 | 2400 | 0.3358 | - |
| 0.5622 | 2500 | 0.3208 | 0.3833 |
| 0.5847 | 2600 | 0.3206 | - |
| 0.6072 | 2700 | 0.3254 | - |
| 0.6296 | 2800 | 0.3215 | - |
| 0.6521 | 2900 | 0.3082 | - |
| 0.6746 | 3000 | 0.3099 | 0.3684 |
| 0.6971 | 3100 | 0.3060 | - |
| 0.7196 | 3200 | 0.3009 | - |
| 0.7421 | 3300 | 0.3021 | - |
| 0.7646 | 3400 | 0.3163 | - |
| 0.7870 | 3500 | 0.3020 | 0.3652 |
| 0.8095 | 3600 | 0.3012 | - |
| 0.8320 | 3700 | 0.2927 | - |
| 0.8545 | 3800 | 0.2878 | - |
| 0.8770 | 3900 | 0.2974 | - |
| 0.8995 | 4000 | 0.3125 | 0.3584 |
| 0.9220 | 4100 | 0.2938 | - |
| 0.9445 | 4200 | 0.2997 | - |
| 0.9669 | 4300 | 0.2915 | - |
| 0.9894 | 4400 | 0.2923 | - |
| 1.0 | 4447 | - | 0.3572 |
@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
BAAI/bge-m3