Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 12
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-large. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'XLMRobertaModel'})
(1): Pooling({'word_embedding_dimension': 1024, '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})
(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 = [
'How do I effectively navigate between high-end shopping districts and traditional markets in Hawaii?',
"friends in your own privacy and do this until you are blue in the face or you can't speak anymore then head back home and chill out because that was a pretty chill day but definitely a fun and eventful one as well. so hopefully you're not too hungover. it's day six. you can sleep in a little bit, but we will do something in the morning, which is something you can only do on saturday. so it's really important to follow this itinerary this way if possible, which is to visit the kaka'ako farmer's market. now this is located near the ala moana area, which you can definitely take the bus to. and i believe the farmer market ends at noon, which isn't too late for a farmer's market. this is a really cool experience because there are so many vendors where you can get some fresh fruit some fresh produce some small businesses that make some delicious food whether it's hawaiian some pan-asian japanese american bakeries it's a little bit pricey i'm not gonna lie but hey we've been pretty frugal and cheap so far so it's okay to splurge a little bit on food here eat until your heart's content until the market closes hopefully and then while you're in the area, if you want to do some shopping, maybe you do, maybe you don't, that's okay, head to the ala moana mall, which is actually, i think, the biggest outlet mall, outdoor outlet mall, whatever you want to call it, in the united states. there's lots of good shopping options here. now, if shopping's not so much of your thing, or maybe it is, i still recommend afterwards, or instead of, heading to don quixote, which is actually a japanese sort of department store, i guess you can call it, but it's completely different than like walmart, and the one in hawaii is no exception. this is a really cool place to get souvenirs for really cheap price and to see some really interesting either asian or japanese or hawaiian goods that you can just look at and kind of be like, huh, i've never seen that before. or man, that advertisement's a little bit out of left field compared to what we've seen in america because hawaii is in america, but one of my favorite things about it is it has that sort of asian influence, which makes it feel definitely a little bit more exotic than let's say idaho or somewhere like that. and that can be it for day six if you'd like. if you're more of the adventurous type and you don't want to shop and maybe you get up early and then you stop at don quixote and you still have a lot of time in the day, you can do another hike. i really recommend doing three peaks. it's one of my favorite hikes i've ever done in my life. it's about an hour or so on the bus so you have to incorporate that time as well but you'll not regret it because the views are amazing. it's a little bit sketchy so be careful and only do the first peak of three if you feel comfortable but it is certainly an adventure so if you're an adventurous person, that's something to consider as well. if you're not and you're wiped from our itinerary so far, i don't blame you. chill out, catch another sunset, maybe enjoy the pool at your hotel, eat some food, and call it a day for day six. so finally, sadly, we are going to begin day seven, which is your last day here in hawaii, your last full day. here we are not going to do anything too crazy. we're just going to relax and take in the local area of waikiki. so to start the day, we're going to get an acai bowl, which in my opinion is the national food of hawaii. it's not poke, it's acai bowls, everybody. two of my recommendations are going to be aloe, aiello, that is, and island vintage, which is definitely very popular.",
"you can time it at the right time. now, if you still have some more room left over, i really recommend going to ice monster, which is all this is in waikiki, everybody, so it's all walking. no buses for today. thank the lord. and get some delicious taiwanese shaved ice. it's definitely different than the snow cone, but it's very smooth and it just feels effortlessly like it's melting on your tongue like it's snow itself. very delicious, really good, definitely recommend it if you've never tried it. and it also fits the tropical feel perfectly. now while you're still exploring and enjoying waikiki, i really recommend going to the international marketplace where they have lots of cool stores, some good shopping as well.",
]
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.6860, 0.3253],
# [0.6860, 1.0000, 0.3919],
# [0.3253, 0.3919, 1.0000]])
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
How to use Hawaii’s local transportation? |
to watch it. it really is. yeah, i gotta say waikiki gets a bad rap for sometimes being a bit too crowded, but sunset, the vibe is great. there's often live music, everybody's just enjoying watching that sun go down, so it's a great place to start your vacation. you can even hop in one of the catamarans that has beach loading and go out sailing and watch the sunset that way. that's a great way to start. there you go. gosh, we're good. oh my gosh, you're lucky you found this channel. day number two, and guess what? you are up early, my friend, because you have jet lag. real bad. real bad, especially if you have kids with you. wow, good luck. so we are going to take advantage of that today, and you are going to head up to the north shore to go snorkeling at kualima cove, or just enjoy a nice beach day up there. kualima cove is at turtle bay resort, which is like five-star luxury resort that's been remodeled, but all beaches in hawaii are public, and this is a great place to go snorkeling... |
and stay tuned because you're about to open the air traffic control tower after being closed for decades. click the link in the description below for more information on the pearl harbor aviation museum and the official place to purchase tickets. day number four. you have done a lot on this trip so far. oh my goodness, you must be tired. so let's hang out in waikiki for the day. there's plenty to do in waikiki. you can visit the different beaches in waikiki. there's eight of yes, wow. and each one is a little bit different. you can enjoy some shopping because there are world-class stores here, or you can hop in the water and try some surfing, which jordan really |
How to use Hawaii’s local transportation? |
so are you going to oahu, hawaii and you're either too cheap or broke to get a rental car for your time there? there's no judgment in that question because that was my mentality and you definitely can have an amazing time in oahu, hawaii even for like a week or so without any rental car whatsoever. i was there for a month and mostly got by without a rental car so i'm definitely very qualified to give you an amazing seven-day one-week itinerary for oahu, hawaii with no rental car. that being said, let's start off with day number zero or arrival day. so unless you're a very strong swimmer or taking a very fast speedboat, you'll be arriving at the daniel k. inouye international airport. probably a little bit jet lag. it's definitely a little bit tired. so let's just get to your hotel and check in. i do recommend staying in waikiki, which people might kind of roll their eyes or scoff at because it's very touristic. it's like a little bit of a concrete jungle in the middle of hawaii, built ... |
warming up your taste buds then if you head to the link in the description below we have a full first time to hawaii article and that think of it like a starter yeah i like this i think she's hungry i had nothing to do with writing this. this is all her, but that's pretty good. that's a good analogy. hold on, but we have a main course. if you want more, head to the hawaiivacationguide.com slash itineraries, and that is our main course itineraries. but today, here in this video, we are going to give you a taste of what your first time to hawaii itinerary could look like, and i think this is |
How to use Hawaii’s local transportation? |
walk which is about 50 minutes. which, hey, do you want to walk there and burn out your legs a little bit? it's up to you, depends on how much energy you have to spare. either way, the hike isn't so difficult. it costs about $5 to enter, walking that is, which you'll be doing because you don't have a car of course, and i believe nowadays you have to either reserve a time slot or something like that. it's also very busy so the earlier you go the better. the hike itself is really cool it's not too difficult like i said you go through a little bit of a tunnel and at the end you will get some amazing views of waikiki, waikiki beach and some other parts of the island which you're probably super excited to explore which we'll definitely do on other days besides today. so once you finish hiking diamond head return back down the way you came it's an out and back trail and head to the nearby neighborhood called kaimuki. now kaimuki is a really cool and trendy sort of hip and sort of like a coll... |
slash itineraries because we have some awesome itineraries with great excursion days to take you all over the islands and you will have a great time would you call it the main course i would you call the main course and don't forget to check out the pearl harbor aviation museum because that will make your trip to honolulu all the more special thank you so much for watching thanks a lot. |
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
}
num_train_epochs: 4learning_rate: 2e-05warmup_steps: 90gradient_accumulation_steps: 4fp16: Truedataloader_drop_last: Trueper_device_train_batch_size: 8num_train_epochs: 4max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 90optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 4average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_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: trackioeval_strategy: noper_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: Truedataloader_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_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: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.2203 | 50 | 1.3365 |
| 0.4405 | 100 | 0.5632 |
| 0.6608 | 150 | 0.4383 |
| 0.8811 | 200 | 0.3778 |
| 1.1013 | 250 | 0.3399 |
| 1.3216 | 300 | 0.2640 |
| 1.5419 | 350 | 0.2533 |
| 1.7621 | 400 | 0.2160 |
| 1.9824 | 450 | 0.2270 |
| 2.2026 | 500 | 0.1697 |
| 2.4229 | 550 | 0.1717 |
| 2.6432 | 600 | 0.1603 |
| 2.8634 | 650 | 0.1552 |
| 3.0837 | 700 | 0.1374 |
| 3.3040 | 750 | 0.1195 |
| 3.5242 | 800 | 0.1085 |
| 3.7445 | 850 | 0.1114 |
| 3.9648 | 900 | 0.1298 |
@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
intfloat/multilingual-e5-large