1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("ahmedHamdi/narrative-similarity-pt-en-gemma")
5# Run inference
6sentences = [
7 'Walter Mitty (Ben Stiller) is a negative asset manager at Life magazine who frequently daydreams about fantastical adventures and has a crush on his colleague Cheryl (Kristen Wiig). Photojournalist Sean O\'Connell (Sean Penn), who works closely with Mitty on his statements, sends him a package containing his latest negatives and a wallet as a gift in appreciation of Mitty\'s excellent work. In addition, the package contains a special photograph, negative 25, which he says captures the Quintessence of Life and should be used for the cover of the magazine\'s final print edition once it goes online. Unfortunately, this particular negative is missing from the package, and Mitty is forced to stop the detestable corporate transition manager Ted Hendricks (Adam Scott) to deal with the mess. Using the other negatives as clues, Mitty discovers that O\'Connell is in Greenland and flies there to try and find him. Arriving in Greenland, Mitty goes Mitty goes to a bar asking about O\'Connell. The bartender explains that O\'Connell has already left on a ship, and to find him, Mitty needs to go in the postal helicopter, and the pilot is drunk singing a karaoke version of "Don\'t You Want Me" in the bar. Mitty refuses to fly with a drunk pilot, but imagines Cheryl singing "Space Oddity" to him, gains newfound confidence, and jumps aboard the helicopter. Arriving at the ship, Mitty discovers that the helicopter cannot land on the ship. Mitty has misunderstood, thinking that the pilot had to jump onto the ship, where there was a boat approaching to pick him up, but then dived into icy shark-infested waters before he could be brought aboard. In doing so, Mitty realizes this whole adventure is actually happening, contrary to his daydreams. The sailors remember O\'Connell, and even offer Mitty the cake he left behind, and Mitty discovers another clue in the wrapping paper. His journey continues to Iceland, where O\'Connell is. Mitty went to photograph the Eyjafjallajökull volcano. The eruption prevents Mitty from finding O\'Connell, and he is forced to interrupt the search after receiving a text message telling him to return to New York immediately. For his failure, his first professional defeat in his long career with the magazine, Mitty is fired and is further disheartened to discover that Cheryl, who was leaving earlier, seems to have reconciled with her ex-husband. Mitty returns home, completely disheartened, and throws away his wallet when he visits his mother (Shirley MacLaine), and to his surprise, she mentions having found O\'Connell. She had said so before, but at the same time, dreaming, he couldn\'t hear her. He then finds a new lead to continue hunting O\'Connell. Mitty eventually tracks O\'Connell down in the Himalayas, attempting to photograph a rare snow leopard, and asks about the missing negative. O\'Connell explains that the message about taking a closer look was literal: the negative. It was in the wallet. Mitty joins him in a football game with some locals. Mitty flies to Los Angeles, but is detained by airport security, and calls the only person he knows in Los Angeles; Todd Maher (Patton Oswalt), a representative from eHarmony who has kept in touch through his adventures. Mitty returns home and helps his mother sell her piano; he mentions that he no longer has a wallet. His mother says that she always keeps her skills and she produces the wallet he had thrown away. Without looking at the photo, an emboldened Mitty hands it over to Life magazine, tells the management that it was the photograph Sean O\'Connell wanted for the final issue, and reprimands Hendricks for disrespecting the team that made the magazine so honored. Walter reunites with Cheryl when they receive their compensation packages and discovers that Cheryl\'s ex-husband was only at her house in order to repair the refrigerator. Excited by the turn of events, Mitty and Cheryl see the final issue of the magazine on the newsstand. The newspaper, with its cover greeting the staff, was revealed to show Mitty sitting in front of the Life building, holding a sheet of negatives up to the light and examining them with an eyepiece.',
8 " Walter Mitty is a negative assets manager at Life magazine living alone in New York City. He chronically daydreams and has a secret crush on Cheryl Melhoff, a coworker. Walter attempts to contact Cheryl via eHarmony but eHarmony customer service agent Todd Mahar explains that Walter's account is not fully filled out: the been there and done that sections are blank. Walter works with legendary photojournalist Sean O'Connell, although they have never met in person. At work later that day, Walter receives a negative roll from Sean with a wallet as a gift in appreciation of Walter's work over the years. A letter from Sean explains that he believes negative #25 captures the quintessence of life and should be used for the cover of the magazine's final print issue before it becomes exclusively digital, yet the negative is missing from the roll. Ted Hendricks, the obnoxious manager of the magazine's transition, has also heard Sean's recommendation. When he asks about #25, Walter stalls and lies, worried about being fired. Walter then asks Cheryl for help, and she suggests that Walter use the other negatives as clues to Sean's location. He and Hernando, his understudy, are stumped by a negative depicting a curve, until they notice another containing the name of a ship registered in Greenland. Walter reluctantly takes a plane there. A bartender in Nuuk explains that Sean left on a ship. To find him, Mitty would need to go on the postal helicopter, and the pilot is drunk. Mitty recognizes the pilot's thumb from one of the negatives, and after hesitating, joins the pilot on a trip to bring supplies to the ship. Walter accidentally jumps into ice-cold, shark-infested waters, losing the ship's supplies and preventing radio communication when he finally comes aboard. There, Walter learns that Sean departed the ship a few days earlier and deduces from notes on wrapping paper for a clementine cake Sean left behind that he is heading to Iceland to photograph the volcano Eyjafjallajökull. Walter bikes, skateboards, and runs through the Icelandic countryside to find Sean, but just misses him as the volcano erupts. Dejected, he returns home. Ted assumes that Walter misplaced the negative and fires him. He tries to visit Cheryl, but spots her ex-husband and leaves before talking to her. Walter visits his mother and throws away the wallet from Sean. To his surprise, Walter recognizes the curve of the piano in his mother's house while looking at the last negative. When asked, she tells Walter that she met Sean and baked him the clementine cake. She had told Walter earlier, but he was daydreaming. Walter figures out from the notes that Sean is in the Afghan Himalayas and finds him photographing a rare snow leopard. When asked about the negative, Sean explains that, attempting to be playful, he had placed the negative in the wallet. He decides not to tell Walter what the picture actually depicts. When Walter returns to America, the airport security at Los Angeles detains him for arriving from Afghanistan. To verify his identity, Walter calls the only person he knows in Los Angeles: Todd, who has kept in contact during Mitty's travels. The two chat and Todd expresses admiration for how adventurous Walter appears. Walter receives the wallet from his mother, who had retrieved it from the trash, and finally obtains the negative but chooses not to see it. Emboldened, he delivers it to Lifes offices and berates Hendricks for disrespecting the staff that made the magazine so honored. Walter reunites with Cheryl, and thanks her for inspiring him on his journey. Cheryl eagerly asks about his adventures and tells him that her ex-husband had only been at her house to help with repairs. Walking along the street, they see the final print issue on sale at a newsstand, and on its cover, they see the photograph from #25 for the first time: it shows Walter sitting outside of the Life building, examining a contact sheet; the magazine is dedicated to Lifes staff, and Sean's note actually referred to quintessence of Life. Walter and Cheryl continue their walk holding hands.",
9 "In Europe, American high school students and crimefighters Kim Possible and Ron Stoppable have thwarted a world dominating scheme of Professor Dementor and rescued Dr. Glopman, whom Dementor had kidnapped. As Kim Possible and Ron Stoppable start their first day of school, they meet a new student named Athena and take her on a mission to stop the plot of the evil Dr. Drakken. Athena (a skilled bōjutsuka) defeats Dr. Drakken's henchwoman Shego, making her the topic of conversation at Middleton High School despite Kim's jealousy. When the school honors Athena and her good deed, Shego and Dr. Drakken force their way into the ceremony. Kim tries to defeat Shego and her army of henchwomen but falls to the ground, leaving Athena vulnerable to kidnap. Athena is kidnapped, and Kim is laughed at. After Kim talks with her family and Ron, they decide to rescue Athena from Drakken's and Shego's lair. At the lair, Kim discovers Athena is part of Drakken's and Shego's plan to steal Kim's motivational essence and transfer it into Drakken with his brain-modulating device. Athena is revealed to be an android built by Drakken, specifically for this. As Kim short-circuits the transfer machine, Dr. Drakken is de-aged into a pre-adolescent version of himself. Despite Kim's insistence that she save herself, Athena stays behind to turn off the now-unstable machine. The lair explodes and Athena is presumed killed, but it is revealed that she has survived the explosion. Kim and Ron take her home to be repaired and programmed to be a hero alongside themselves. During the credits, Dr. Drakken, posing as a gifted student with Shego posing as his mother, enrolls at Kim's high school and begins his plan to defeat her.",
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.8464, -0.0673],
19# [ 0.8464, 1.0000, -0.0590],
20# [-0.0673, -0.0590, 1.0000]])