1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("ahmedHamdi/narrative-similarity-all-en-instructor-xl")
5# Run inference
6sentences = [
7 'Represent the plot: At the beginning of the film, a news channel (KRKR TV) reports that people in various parts of the world have seen a huge red sphere. Nancy Archer is an immensely wealthy woman, but also unhappy because her beloved husband is shamelessly cheating on her. One night, while driving home on a deserted road in the California desert, the red sphere lands in front of her, and she sees a giant emerge from it. He tries to grab her, but she escapes and runs back to town. No one believes her when she tells him what happened, as it\'s common knowledge in town that she has a drinking problem. Her husband, Harry, is preoccupied with his affair. Nevertheless, when Nancy tells him about her encounter with the giant, he acts like a good husband, puts his wife to bed with sleeping pills, and goes back to dancing with his mistress. The next day, he gives in to his wife\'s pleas and returns with her to the desert, where he drives around in circles for hours, searching for the red satellite.\nFinally, just when Nancy has lost all hope of seeing the satellite again, and believes she must have dreamt the previous night, a flash behind the mountain catches their attention. Once more, the giant red sphere appears, and the giant emerges from it again. He tries to grab Nancy, who screams in terror; her husband, acting cowardly, jumps into the car and abandons his wife in the middle of the desert. Upon his return, he packs his bags and tries to leave the house. But the butler has realized something has happened and alerts the sheriff, not without first getting into a fight with Harry and being knocked unconscious by him. The police arrest Harry before he can escape with his mistress, then find Nancy on the roof of her indoor swimming pool. The family doctor gives her sedatives and orders her to rest in her room. He is worried about the scratches on her throat, which appear to be infected. They are thought to have been caused by radiation. Harry, in his corner, plots with his mistress to get rid of his troublesome wife. He decides to give her a lethal injection. As he approaches her in the night, the nurse turns on the light in the room; the illuminated room reveals that Nancy has become a giant herself. The doctors are alerted and decide to chain Nancy to her bed. Meanwhile, the sheriff and the butler follow giant footprints they spotted in Mrs. Archer\'s garden. These footprints lead them to the desert, where they find the red satellite, open. They enter the sphere and discover a series of diamonds encased in glass globes. One of them is the famous "Star of India" diamond, which belongs to Nancy Archer. They surmise that the giant needs these diamonds as an energy source to power his spaceship. The giant arrives. The two men exit the sphere and take refuge behind their car. The giant emerges and destroys the car, allowing the men to escape. A little later, Nancy wakes up and asks to see Harry. He receives an urgent message from the sheriff while he is with his mistress in a bar and refuses to go to his wife, preferring to enjoy himself in her company. Nancy becomes agitated and finally gets out of bed: she destroys the house in the process and bursts through the roof. She heads towards the city, searching for her husband, whom she claims to know is with his mistress. Upon arriving in town, she destroys the building where her husband is staying, and in breaking the roof, a huge beam falls on her husband\'s mistress, killing her instantly. Then she grabs Harry in her gigantic hand and leaves town. The sheriff decides to intervene, firing at her repeatedly until he hits an electrical transformer, which explodes nearby, killing Nancy.',
8 "Represent the plot: A television announcer reports sightings of a red fireball around the world. Facetiously, he calculates its path will take it to California. Nancy Archer, a wealthy but highly troubled woman with a history of emotional instability and immoderate drinking, is driving on a road that night in an American desert. A glowing sphere settles on the deserted highway in front of her, causing her to veer off the road. When she gets out to investigate the object, a huge creature exits and reaches for her. Nancy escapes and runs back to town, but nobody believes her story due to her known drinking problem and a recent stay in a mental institution. Her philandering husband, Harry Archer, is more interested in his latest girlfriend, town floozy Honey Parker. He pretends to be the good husband in the hope that Nancy will snap and return to the booby hatch, leaving him in control of her $50 million estate. Nancy bargains with Harry, asking him to search the desert with her for the flying satellite, agreeing to a voluntary return to the sanatorium if they find nothing. As night falls, they find the spacecraft and the alien creature emerges, revealed as an enormous male human. Harry fires his pistol at the giant, but the gunfire has no effect. Harry flees, leaving Nancy behind. She is later discovered on the roof of her pool house in a delirious state and must be sedated by her family physician, Dr. Cushing. The doctor comments on scratches he finds on Nancy's neck, and theorizes that she was exposed to radiation. Egged on by his mistress Honey, Harry plans to inject Nancy with a lethal dose of her sedative, but when he sneaks up to her room, he discovers that she has grown to giant size. In a scene paralleling Nancy's first alien encounter, only an enormous hand is seen as Harry reacts in horror. Cushing and Dr. Von Loeb, a specialist brought in by Cushing, are at a loss on how to treat their giant patient. They keep her in a morphine-induced coma and restrain her with chains while waiting for the authorities to arrive. The sheriff and Jess, Nancy's faithful butler, track enormous footprints leading away from the estate to the alien sphere. Inside the sphere, they find Nancy's diamond necklace (containing the largest diamond in the world) and other large diamonds, each in a clear orb. They speculate that the jewels are being used as a power source for the alien ship. The huge human reappears, and the sheriff and Jess flee. Meanwhile, Nancy awakens and breaks free of her restraints. She tears off her mansion's roof and, clothed in a bikini-like arrangement of bed linens, heads to town to avenge herself on her unfaithful husband. Ripping the roof off the local bar, she spots Honey and drops a ceiling beam on her rival, killing her. Harry panics, grabs Deputy Charlie's pistol, and begins shooting, but she picks up Harry and walks away. The gunshots have no apparent effect on her. The sheriff fires a shotgun at her, which causes a nearby power line transformer to blow up, killing her. The doctors find Harry lying dead in her hand.",
9 "Represent the plot: In the fictional small town of Winsford, Massachusetts, Hallie Knudsen, Katie Jensen and their friends Chloe and Wren approach a group of boys to probe their evening plans, but they are told that it is top secret. During a sleepover in the basement of Katie's abode, the girls discuss the boys' intentions to summon the Slender Man, a tall, thin, horrifying supernatural being with a featureless visage who is infamously known throughout the Internet as a menacing individual who primarily targets innocent children by seducing and then abducting them; they subsequently visit a website containing a link to a disturbing video that demonstrates how he can be reached. The following week, on a class field trip to the historic Clifton Cemetery, Katie becomes haunted by a paranormal presence in the trees. A short amount of time passes before she disappears without a trace, forcing the entire crowd of students to stay behind for hours until the police arrive to begin examining the premises. Deciding to hunt for clues at her dwelling, the other three recover her laptop, discovering that Katie, who had been unhappily living alone with her alcoholic father, had become involved in the occult, developing an unhealthy obsession with Slender Man sightings and videos and messaging Allison Riley, also identifiable by her online handle AleeyKat93, regarding methods of reaching the character, who would spirit her away from her currently miserable environment. Allison explains that he infects people’s minds similar to a virus, eventually either driving them completely insane or kidnapping them, and to retrieve Katie from his clutches, the trio need to unveil themselves, which they interpret as surrendering an item that is very special to each of them. Wren brings a piece of handmade pottery that she created when she was five years old, Chloe offers a picture of her and her father taken prior to his passing a few months afterwards, and Hallie relinquishes her younger sister Lizzie’s blanket, woven by their grandmother upon her birth. Having researched Slender Man mythology, Wren instructs Hallie and Chloe to don blindfolds and warns the pair against removing them or opening their eyes to look directly at his face while contacting him, even if they hear something, for fear of death or madness. However, Chloe panics and flees, meeting the Slender Man up close. Sometime later, he enters Chloe's house and drives her mad. Wren, suffering from frightening visions, researches further about the figure in the local library, where it attacks her, and Hallie unsuccessfully attempts to move on from the issue by spending the night with her boyfriend Tom, for which Wren chastises her. Meanwhile, Lizzie suffers a major panic attack and is hospitalized and sedated. Scouring her computer, Hallie discovers that Wren, aided by Lizzie, had attempted to contact the Slender Man. Heading to Wren's residence to confront her, Hallie encounters information that Wren gathered in her bedroom concerning Slender Man and his victims, one of whom was Allison Riley, a psychiatric patient who claimed that the malevolent entity absconded with nine of her peers. After Hallie dissuades her from committing suicide, Wren, feeling guilty for causing the recent chain of events, breaks down and confesses that Lizzie approached her with interest in the Slender Man and asked that she accompany her to the woods, where she offered her teddy bear to him. She then admits that the sacrifices they gave him earlier were insufficient, as he will only rest once he has seized all of them physically. Suddenly, Slender Man shatters the glass window and kidnaps her, pulling her outside with his tentacles appearing in the shape of branches. Hallie, now realizing that her sole available option for rescuing Lizzie is to sacrifice herself to him, ventures into the wooded area to deal with him upfront. Encountering the monster, she pleads for him to take her instead. He obliges, and moves to grab her as she tries to escape. Using his enormous appendages to traverse the forest like a spider, he grabs and ensnares her, both of them fusing together as a tree. Lizzie awakens in the hospital screaming for her sister, but ultimately makes a successful recovery and reflects on what happened to the quartet.",
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.8326, 0.0116],
19# [ 0.8326, 1.0000, -0.0111],
20# [ 0.0116, -0.0111, 1.0000]])