Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False, 'architecture': 'T5EncoderModel'})
(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': False})
(2): Dense({'in_features': 1024, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
(3): Normalize()
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("ahmedHamdi/narrative-similarity-pt-en-masked-instructor-xl")
5# Run inference
6sentences = [
7 'Represent the plot: After suffering a car accident, photographer PERSON loses her memory and decides to move with her family to her childhood home to reunite with her uncle, where she begins to witness strange events.',
8 "Represent the plot: In 1985, police officers tell PERSON that something has happened to his brother and his family. The police find his brother, his brother's wife, and his niece have all been massacred. The police find PERSON, a blood-covered teenager, to be the only survivor. The song ORG plays in the background. PERSON is raised by a foster family and has no memory of her family or the tragedy. In 2010, PERSON owns a studio, selling photographs she takes of abandoned farmhouses. She has a strained relationship with her husband PERSON and their young daughter PERSON, partly because she has memory lapses. On one excursion, she is drawn to the farmhouse from the beginning of the film. Days later, PERSON has a car accident and wakes up in the hospital but doesn't recognize PERSON and PERSON. A doctor explains that the crash aggravated a childhood head injury, the reason for her missing childhood. PERSON receives a mysterious gift, a music-box dancer and a photo from 1985 of the farmhouse she recently photographed. The property records reveal that PERSON owns the farmhouse and it has been cared for by PERSON, her uncle. The hospital psychiatrist, PERSON, suggests that she visit to try to recover repressed memories. The family decides to visit and meet PERSON, who lives at the next farm. A clerk at a local antiques store shows her a framed page of a 1985 newspaper, detailing the massacre of her family and the suspicion that PERSON was responsible. PERSON sees PERSON, but he leaves before she can approach him. PERSON receives another gift box with a torn family photo featuring young PERSON, PERSON, and a blurry image of their mother, PERSON. That night, she sees PERSON imploring her to come find us. She visits PERSON, who says that PERSON is the only one who knows what happened to her family. PERSON later sees PERSON again, who says that they need to hide from the monster. PERSON tells PERSON that the girl warned her about the monster in the bedroom, while a nice lady taught her the PERSON song. As PERSON insists they leave, PERSON screams that a man was chasing her and begins to have an asthma attack. The spirits won't let PERSON leave the house when PERSON rushes PERSON to the hospital. She finds a music box in PERSON's room, containing the other half of the torn family photo, revealing PERSON to be PERSON's father. PERSON finally remembers what happened the night her family died: The sisters heard ORG enter the house and hid under the bed, but PERSON pulled PERSON out and was preparing to molest her when their parents arrived home (PERSON, her mother, who turns out to be the antiques store clerk). PERSON grabs a hammer and finds PERSON on PERSON, who suffers an asthma attack. PERSON with the hammer, then chases PERSON, who runs into GPE. They crash down the stairs, killing PERSON and causing PERSON’s head injuries. PERSON finds PERSON dead of her asthma attack, so he places the hammer in GPE's hand and leaves. PERSON wakes up and crawls into the corner the police found her in, covered in GPE's blood. PERSON sits with PERSON, who explains that the family's spirits were trapped and could only lead her to the truth so she could set them free. PERSON comes and says he dropped PERSON off at PERSON's. They rush there as PERSON is preparing to molest PERSON, and he shoots at PERSON. PERSON hits PERSON with a shovel. PERSON wakes up as PERSON drags him into PERSON's room. As he begs her not to leave him there, she tells him he can plead his case to the family and leaves. The movie ends as PERSON desperately cries for his life.",
9 "Represent the plot: PERSON is the respected Chief of Police of the small GPE town of ORG. Recently separated, PERSON is currently seeing local resident PERSON, an old flame from high school whose husband PERSON, a former professional quarterback seemingly oblivious to the relationship, abuses her. While taking PERSON to the doctor, PERSON finds out she has just been diagnosed with terminal cancer. PERSON is also going through a divorce from his wife, homicide detective PERSON, and is friends with medical examiner ORG. Ann intends to reward PERSON's loyalty to her by making him the sole beneficiary of her $1,000,000 life insurance policy. PERSON suggests that she should travel to GPE to undergo a newly developed, groundbreaking treatment. The problem is that PERSON does not have any money. Desperate to help her, PERSON takes $485,000 out of evidence from a drug kingpin bust and gives it to her so she can make the trip. When the money goes up in flames in a suspicious house fire that kills PERSON and PERSON, PERSON is horrified to find their charred remains. Upon investigation, PERSON discovers that the doctor that diagnosed PERSON was an imposter, PERSON didn't have cancer, and he has been set up. When ORG agents call the next day to get the evidence money in order to bust the drug kingpin, PERSON responds erratically. He finds out that the money is now with the imposter doctor and that PERSON is about to bust him. He rushes to the hotel and after a brief struggle, he accidentally kills the imposter, takes the money and flees. Although PERSON is seen by the police, he is thought to have come to protect PERSON. Later that evening, PERSON finds that PERSON is PERSON's sole beneficiary and also that he has been in a relationship with her. At the same time, PERSON receives a distress call from PERSON, who is still alive, and unofficially goes to save her. PERSON and PERSON fight, PERSON shoots and kills PERSON. Then PERSON reveals that she had planned all of this for money and fortune, and shoots PERSON in the leg. When PERSON is about to kill PERSON, PERSON kills her; PERSON traced PERSON using a GPS tracker and asks him whether he planned to elope with the money but PERSON reveals that he has not brought the money with him. When the irritated ORG agents come to arrest PERSON as he had promised to deliver the money earlier that day, he says that his man was sent to GPE, and simultaneously ORG appears with the money, explaining about a wrong address and that he could not find the ORG office. So the ORG agents leave with the money and PERSON has no charges on him. Later, when PERSON is on medical leave, ORG visits him with news that PERSON is the recipient of PERSON's insurance policy. But PERSON says that, as his wife, she knows that PERSON has to reject it, meaning that she has decided to drop the divorce and move back in with PERSON. Overjoyed, PERSON seemingly forgets about the life insurance money, though ORG is amusingly adamant that PERSON must take it.",
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)
18# tensor([[1.0000, 0.6579, 0.1312],
19# [0.6579, 1.0000, 0.1528],
20# [0.1312, 0.1528, 1.0000]])sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
Represent the plot: PERSON is completely in love with ORG. To his surprise, she agrees to marry him, thinking he's a mining tycoon. From then on, various mix-ups begin to occur due to this misunderstanding. | Represent the plot: ORG up with the wandering eye of her fiance' PERSON, Broadway star PERSON impulsively marries her number one fan, PERSON. Unable to go through with her wedding night, she tries to give PERSON a sleeping potion but ends up drinking it herself. PERSON is a Nazi Fifth Columnist tasked with the job of blowing up ORG next door to the theatre. PERSON manages to foil this plot, if only by tripping over the wiring and defusing the bomb. PERSON is a hit in her new Broadway show, which is based on an idea by PERSON. |
Represent the plot: At the beginning of the 16th century, the Turkish sultan spread terror throughout the then-known civilized world. GPE expanded eastward, conquering LOC, moving south into the LOC and north through ORG. Emerging triumphant, the sultan turned westward, more specifically towards GPE. The invaders were already on the Polish border. This situation forced the Poles to unite with the Cossacks, a rough and valiant people who inhabited the steppes of GPE, to defend their territories and other interests in the region. The film begins with a great battle between Turks and Poles, who are being defeated until they receive reinforcements from the Cossacks. With victory practically assured, the Poles decide to betray their allies, killing several of their commanders. With this, they subjugate GPE and the ORG people. Taras PERSON, one of the ORG officers, returns home, now under Polish rule. Many years later, PERSON sends..." His two sons, PERSON and GPE, are sent to a school in GP... | Represent the plot: The film opens in the 16th century, when GPE, GPE, GPE and elsewhere in eastern LOC were divided into small sections and principalities that fought each other or against one enemy: in this case, GPE. It starts with a battle raging between the Turks and the Poles. The Poles are losing until the Cossacks arrive to save the day. However, it turns out that the Poles were merely holding back so that they could treacherously attack the Cossacks after they won the battle for them. As a result, the Poles become masters of GPE and the Cossacks are subjugated. Taras PERSON, one of the ORG officers, returns home to raise his family but now it is under Polish dominion. Several years later, PERSON sends his two sons, ORG (PERSON) and PERSON (PERSON) to the academy at ORG, to obtain a Polish education. There, the eldest son, ORG, falls in love with a Polish princess PERSON (played by PERSON), to the ire of the locals, who treat the ORG brothers like scum of the earth. Ultimately... |
Represent the plot: PERSON is a journalist for ORG who, after a bicycle accident, is taken to the hospital and one day hears a beautiful violin sound. After investigating, Lopez discovers PERSON, a homeless man diagnosed with schizophrenia who finds the only joy in classical music. Lopez and ORG become great friends and begin to share ideas about the cello. | Represent the plot: In 2005, PERSON is a journalist working for ORG. He is divorced and now works for his ex-wife, PERSON, an editor. A biking accident lands Lopez in a hospital. One day, he hears a violin being played beautifully. Investigating, he encounters PERSON, a homeless man with schizophrenia, who is playing a violin when Lopez introduces himself. During the conversation that follows, Lopez learns that ORG once attended ORG. Curious as to how a former student of such a prestigious school ended up on the streets, Lopez contacts ORG but learns that no record of ORG graduating from it exists. Though at first figuring a man with schizophrenia who's talented with a cello isn't worth his time, Lopez soon realizes that he has no better story to write about. Luckily, he soon learns that ORG did attend ORG, but dropped out after two years. PERSON the next day, PERSON says he wants to write about him. Ayers doesn't appear to be paying attention. Getting nowhere, Lopez finds and contacts... |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 20.0,
3 "similarity_fct": "cos_sim",
4 "gather_across_devices": false
5}multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: 0.0warmup_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: Falsebf16: Falsefp16: Falsefp16_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: Falseignore_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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_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: Trueuse_legacy_prediction_loop: Falsepush_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_inputs_for_metrics: Falseinclude_for_metrics: []eval_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: Noneinclude_tokens_per_second: Falseinclude_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: Trueprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.5631 | 500 | 0.1543 |
| 1.1261 | 1000 | 0.0765 |
| 1.6892 | 1500 | 0.036 |
| 2.2523 | 2000 | 0.0302 |
| 2.8153 | 2500 | 0.0173 |
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{henderson2017efficient,
2 title={Efficient Natural Language Response Suggestion for Smart Reply},
3 author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
4 year={2017},
5 eprint={1705.00652},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}