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-es-en-instructor-xl")
5# Run inference
6sentences = [
7 'Represent the plot: Mickey Windgren (Elvis), a trapeze artist who is afraid of heights because of a tragic accident, begins working as a singer in a hotel in Acapulco.',
8 "Represent the plot: Mike Windgren works on a boat in Acapulco, Mexico. When Janie Harkins, the bratty daughter of the boat owner, gets him fired, Mike must find new work. A Mexican boy named Raoul helps him get a job as a lifeguard and singer at a local hotel. Clashes abound when Mike runs into a rival lifeguard, who is the champion diver of Mexico. He is angry at Mike for taking some of his hours, and for stealing his woman. Mike is recovering from post-traumatic stress disorder and a fear of heights, following a tragic high-wire accident during his career as a circus performer. However, after Mike sees the lifeguard perform a number of dangerous dives, including flips and head-first dives into a section of the pool surrounded by a ring of fire, he decides to get even with him and eventually sets himself up to perform a death-defying dive off the 136-foot cliffs of La Quebrada in front of hundreds of people. Mike dives off the cliff, and successfully lands in the water, earning the lifeguard's respect. As the crowd and the lifeguard applaud, Mike performs one more song and leaves with Margarita and Raoul.",
9 "Represent the plot: A security guard runs through a subway station until he enters a room he cannot escape and starts begging his reflection in a mirror for his life. His reflection uses a shard of glass to slice into its own throat; the wound reflects upon the real security guard's body, killing him. Ben Carson, a suspended police detective, begins his first day as a night security guard at the Mayflower, a luxury department store gutted by a fire and shuttered five years prior. The building still contains numerous mirrors from the store. On Ben's first night of patrol, he finds a mirror that appears covered with handprints, but only on the reflected side of the glass. He sees an open door in the reflection while it is actually closed. Over time, Ben begins to see more intense visions, which he initially shrugs off as hallucinations. He soon finds the wallet of Gary Lewis, the previous night guard (from the beginning of the film) who supposedly killed himself. Inside is a note that says Esseker. After noticing the absence of blood on the mirror shard in Gary's crime photos, Ben is convinced that the mirrors make people do things to themselves that they are not actually doing. Meanwhile, Ben's sister, Angie, is killed by her reflection as it grips its jaw and slowly pulls its mouth apart, causing her to bleed profusely. Ben is distraught when he finds her body. In anger, he attempts to destroy the mirrors at the Mayflower, but they are impervious to damage. He demands to know what the mirrors want, and cracks appear on one of the mirrors, spelling out the word ESSEKER. Ben enters the flooded basement of the Mayflower and finds a small sign stating Psychiatric Studies and St. Matthew's Hospital underneath. He moves to the site of the leak and begins pulling at the tiles and brick of the wall and finds a room with a chair surrounded by mirrors beyond it, a Psychomanteum. Realizing that the Mayflower was built on the site of an earlier hospital,Ben asks his police friend Larry Byrne to help him locate the patient-employee manifest for the hospital. Larry finds the name Anna Esseker, a patient of the psychiatric hospital. She was twelve years old at the time and died in a mass suicide. Ben looks through Anna's file and finds an Authorization and Consent form that negated her Death Certificate, stating that she had been discharged from the hospital two days before the suicide and is led to believe that Anna is still alive. Meanwhile, Ben's wife Amy discovers her son Michael's reflection acting differently from the real Michael. In a panic, she calls Ben, who immediately returns home. Together they cover every reflective surface in the house with green paint. They also cover the windows with newspaper and remove anything with a reflection, e.g. picture frames. Ben locates Anna Esseker's childhood home, and discovers that as a child she was violent and uncontrollable, and diagnosed with severe schizophrenia. She was taken in by a doctor, Dr. Kane from St. Matthew's Hospital, who believed that she had a rare personality disorder. His treatment was to confine Anna to a chair surrounded by mirrors, believing this would cure her disorder by forcing her to confront her own reflection. Ben is told by Anna's brother Robert that when she returned, apparently cured, strange things started to happen with the mirrors in their home. As a result, her family sent her to a convent, Saint Augustine's Monastery, where mirrors are forbidden. Ben visits the convent and finds Anna alive and well, who explains that she was actually possessed by a demon, which was drawn from her and became trapped in the mirrors. She explains that it collects the souls of those it kills and if she were to return, it would make it possible for the demon to be brought back into the mortal world. She refuses to go back. Meanwhile, Amy discovers that Mikey is missing at home, and a thin reflective layer of water is completely covering the floor. After putting her daughter Daisy in a safe closet, she finds Michael using a knife to scrape the paint from the mirrors. Amy tries to stop him, but he escapes, obviously possessed. Having threatened her at gunpoint, Ben returns with Anna to the Mayflower and straps her into the chair in the Psychomanteum. Back at Ben's house Michael is suddenly pulled through the water on the floor by his reflection and begins to drown. At the Psychomanteum the lights begin to flicker and the building begins to shake as the demons in the mirrors are released. They repossess Anna and all the mirrors in the Mayflower explode. Simultaneously, Michael is released from the demon's grip and Amy is able to pull him to safety. The repossessed Anna then attacks Ben, who manages to kill her by igniting a nearby gas line, setting off a huge explosion. The old building starts to collapse violently, and Ben is trapped under the ceiling while trying to escape.",
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.5511, 0.2287],
19# [0.5511, 1.0000, 0.2776],
20# [0.2287, 0.2776, 1.0000]])sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
Represent the plot: In Russia, the young university student Roderick Raskolnikov graduates with honors. Although hailed as an authority on crime, Roderick lives in poverty. When Roderick learns that his family is coming to visit, he decides to pawn the watch, a family heirloom he received for his graduation. At the pawnshop, Roderick sees a young prostitute, Sonya, being given only one ruble for her valuable Bible, and when the pawnbroker pushes her toward the door, she loses the ruble. Roderick inquires and learns that Sonya supports her family. Though he has little of his own, he gives her the rubles he received for the watch. Later, Roderick's mother and sister, Toni, arrive at his study, and he learns that Toni lost her job because her employer's husband, Grilov, tried to rape her. With the family in dire poverty, Toni has agreed to marry the pompous and elderly Lushin. Angry at Toni for selling out to Lushin, and desperately needing money, Roderick kills the cruel pawnbroker and r... | Represent the plot: When the publicly held shipbuilding corporation Global Transportation Systems, or GTX, is downsized in the midst of the recession, many employees are fired, including Bobby Walker. Walker is a white-collar, corporate ladder-climbing employee with a six-figure salary, a wife, and a teenage son and younger daughter. Walker gets outplacement services from GTX but, without success, gradually loses luxuries such as his country club membership and his Porsche. He finally resorts to selling his expensive house (with a large mortgage) and moves his family in with his parents. Ultimately, Walker is forced to take a manual labor job working for his blue-collar brother-in-law, Jack Dolan, renovating a home. Executive Vice President Gene McClary challenges GTX CEO James Salinger and his strategy of employee cutbacks, questioning the ethics of spending money to build new corporate headquarters while laying off employees. Angry at being questioned by McClary, his longtime friend,... |
Represent the plot: The film opens at the end of the Korean War, where American jet pilots Hal Jordan and his escort, Kyle "Ace" Morgan, are attacked by enemy pilots unaware of the ceasefire. Hal is shot down in the ensuing firefight and is forced to kill a North Korean soldier after ejecting. The trauma of this event leads to Hal's confinement in a mental hospital for about six months. At the Gotham City Observatory, the last surviving Martian, J'onn J'onzz, is unwittingly transported to Earth by a scientist, Dr. Saul Erdel. The shock of J'onn's arrival causes Erdel to suffer a heart attack, though he apologizes beforehand for bringing him from Mars. Unable to return to Mars, he disguises himself as Dr. Erdel, using his shapeshifting abilities to take possession of his ID. Before leaving, he reads Erdel's mind in his final moments to gain insight into life on Earth. The following year, Superman and Wonder Woman are deployed to Vietnam, where they celebrate with a group of women they r... | Represent the plot: An unknown entity, named The Centre, tells its story about how it was born from the Earth itself and has witnessed the evolution and extinction of the dinosaurs, and mankind's evolution. Due to man's capacity for war and violence, the Centre has concluded that they must be eradicated. At the end of the Korean War, United States Air Force pilot Hal Jordan and his wingman, Kyle Ace Morgan, are attacked by enemy pilots but survive. In Gotham, J'onn J'onzz – the last survivor of the Green Martian race – is teleported to Earth; unable to return, J'onn disguises himself. In Las Vegas, Iris West is on the telephone with her fiancé Barry Allen – also known as the Flash – at a casino when Captain Cold arrives to commit robbery; he races from Central City to confront Cold. Flash finds the five bombs hidden by Cold and captures him, before Cold is possessed by an entity. Two years later J'onn (as John Jones) is a detective with the Gotham City Police Department, investigating ... |
Represent the plot: | |
Pantaleón Pantoja, a captain in the Peruvian army, is chosen to carry out the secret mission of organizing and managing a service of prostitutes who must attend to the Peruvian troops stationed on the Amazon River. | Represent the plot: In 1877 Paris, a pack of rats save an abandoned baby from a basket that was flowing along a river. They raise him in the underground of the Opéra de Paris. This child becomes the Phantom of the Opera, a misanthrope who kills anyone who ventures into his underground chambers, just as rats are killed whenever they venture above ground. The Phantom falls in love with the young opera singer Christine Daaé while she sings alone on stage one night. He appears before her and tells her that her voice fills his heart with light. After leaving, he speaks to her using telepathy, and the two begin a romantic relationship. The aristocratic Baron Raoul De Chagny has also fallen in love with Christine, though at first Christine offers him only a platonic relationship. Later, she ruminates that she may be in love with both men. One night, the Phantom calls to her and she descends to his lair across an underground lake in a boat. Upon arriving, she finds him playing an organ and he ... |
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 |
|---|---|---|
| 1.0989 | 500 | 0.6686 |
| 2.1978 | 1000 | 0.4488 |
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}