1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("ahmedHamdi/narrative-similarity-pt-en-instructor-xl")
5# Run inference
6sentences = [
7 'Represent the plot: One year after the events of the previous film, Eggsy has officially joined Kingsman, taken the title of Galahad from his late mentor Harry Hart, and begun a relationship with Tilde, the Crown Princess of Sweden. On his way home, he is ambushed by Charlie Hesketh, a former Kingsman candidate rejected by the previous film who lost his arm and vocal cords (but was inadvertently saved by Eggsy). Eggsy escapes Charlie and his henchmen in a car chase through London, but Charlie\'s severed cybernetic arm hacks into Kingsman\'s servers via the computer in Eggsy\'s car. With the information obtained, Poppy Adams, leader of the world\'s largest drug cartel, the Golden Circle, launches missiles that destroy Kingsman headquarters and all facilities in Great Britain, killing all agents except Eggsy and Merlin. Eggsy and Merlin follow an emergency Doomsday protocol that leads them to Statesman, the American version of Kingsman, posing as a..." A distillery based in Kentucky. There, they discover that Harry survived Valentine\'s shooting thanks to Statesman technology, but has amnesia. Statesman leader Champagne offers support to take down the Golden Circle. Statesman agent Tequila later develops a blue rash and shows signs of mania and is replaced by another agent, Whiskey, as Eggsy\'s partner. Eggsy plants a tracking device on Charlie\'s ex-girlfriend, Clara Von Gluckfberg, during a sexual encounter at the Glastonbury Festival, but when he tells Princess Tilde beforehand what he has to do, she ends their relationship. Later, Eggsy manages to cure Harry\'s amnesia by threatening to shoot a Cairn Terrier puppy that resembles Harry\'s deceased dog. Poppy broadcasts a message announcing that she has added an artificial virus to all her drugs, which causes users to develop symptoms like Tequila\'s, before progressing to paralysis and finally death. She offers the antidote to the world if... The President of the United States ends up legalizing drugs and granting immunity to the cartel. The president negotiates publicly, but secretly decides to let all those affected die, as he is more than happy to get rid of all drug users and put Poppy out of business. Eggsy, Harry, and Whiskey accompany Clara to a Golden Circle facility in Italy. Eggsy manages to steal a sample of the antidote, but is broken by Whiskey during an attack by Golden Circle henchmen, leading Harry to suspect he was working for the enemy. Harry shoots Whiskey in the head, but Eggsy, believing Harry is delirious due to incomplete recovery, saves him with the same technology Statesman used to save Harry. A delirious Princess Tilde calls out to Eggsy, showing that she has the blue rash. Eggsy, Harry, and Merlin discover the location of Poppy\'s hideout in Cambodia, Poppy Land, and fly there. As they approach Poppy\'s hideout, Eggsy steps on a mine, But Merlin sacrifices himself to save him and Harry. Eggsy and Harry break into the hideout; Eggsy kills Charlie, while Harry destroys Poppy\'s robotic dogs with the help of Elton John, who had been kidnapped by Poppy. They retrieve the laptop controlling the drones that are supposed to deliver the antidote worldwide and inject a concentrated dose of contaminated heroin into Poppy. Poppy gives them the laptop\'s password for the antidote, but she overdoses and dies. Whiskey interrupts them before they can enter the password, revealing that he wants all drug users dead after his pregnant wife was killed in a robbery committed by two methamphetamine users. Eggsy and Harry fight and kill Whiskey, then activate the drones. In the aftermath, the president is deposed for wanting to let the victims die, and Statesman buys a distillery in Scotland to help rebuild Kingsman. Statesman\'s tech support specialist, Ginger Ale, is appointed to the position previously held by Whiskey, Eggsy marries Princess Tilde, and Tequila joins the Kingsman, who acquire a new tailor shop in London.',
8 "Represent the plot: One year after defeating Richmond Valentine, Gary Eggsy Unwin has officially joined the Kingsman intelligence service, taking his late mentor Harry Hart's title of Galahad, and began a relationship with Tilde, Crown Princess of Sweden. He is ambushed by Charlie Hesketh, a former Kingsman trainee who lost his arm and vocal cords during the Valentine incident, replacing them with cybernetics. Eggsy evades Charlie and his henchmen in a car chase across London, but Charlie's severed cybernetic arm hacks into the Kingsman database through Eggsy's car. Charlie passes the information to Poppy Adams – leader of the world's largest drug cartel, the Golden Circle – who launches a volley of missiles that destroy the Kingsman headquarters and wipe out all its agents in Britain, aside from Eggsy and Merlin, Kingsman's tech support. Kingsman's emergency protocol leads Eggsy and Merlin to Statesman, an American private intelligence service posing as a Bourbon whiskey distillery in Kentucky, as well as Kingsman's American counterpart. There, they discover that Harry survived his shooting thanks to Statesman nanotechnology, but is suffering from amnesia. They also learn about the Golden Circle from Statesman leader Champagne, and the two agencies agree to work together to bring the cartel down. Statesman agent Tequila later develops a blue rash and shows signs of mania, and is replaced by agent Whiskey as Eggsy's partner. Eggsy plants a tracking device on Charlie's ex-girlfriend Clara Von Gluckfberg during a sexual encounter at Glastonbury Festival, but his revelation of the mission to Tilde strains their relationship. Eggsy cures Harry's amnesia by threatening to shoot a Cairn Terrier puppy that resembles Harry's late dog, shortly before Poppy broadcasts a message to the world about a toxin she has secretly added to all her drugs, which causes users to develop symptoms like Tequila's before paralysis and, ultimately, death. She offers the antidote if the President of the United States ends his country's war on drugs and grants her cartel immunity from prosecution. The President decides to quarantine everyone affected, intending to let them all die to put Poppy out of business and rid the world of drug users, whom he sees as criminals. Eggsy, Harry, and Whiskey track Clara to the Golden Circle's antidote factory in the mountains of Italy. Eggsy steals an antidote sample, which is broken by Whiskey during an ambush by the Golden Circle's henchmen, leading Harry to suspect him of working against them. Harry shoots Whiskey in the head, but Eggsy, believing Harry to be delusional as a result of his recovery, saves him with nanotechnology as Charlie destroys the antidote factory, killing Clara for unwittingly betraying the Golden Circle. Tilde calls Eggsy in a manic state, revealing she has been affected by the blue rash after taking drugs due to her stress over Eggsy's infidelity. Eggsy, Harry, and Merlin discover the location of Poppy's hideout, Poppy Land, in Cambodia and fly there to steal the laptop which can deploy the drones carrying the antidote. Arriving at Poppy Land, Eggsy steps on a land mine, but Merlin switches places with Eggsy and sacrifices himself instead. Storming the lair, Eggsy kills Charlie while Harry destroys Poppy's robotic attack dogs with the help of Elton John, who had been kidnapped by Poppy. They secure the laptop and inject Poppy with a concentrated dose of her own toxin-infused heroin. Poppy gives them the laptop password in a drugged state but dies from an overdose due to the heroin. Whiskey interrupts them before they can deploy the drones, revealing that he wants all drug users to die after his pregnant wife was killed in a robbery by meth addicts. Eggsy and Harry fight and kill Whiskey by pushing him headfirst into an industrial shredder, then deploy the drones to release the antidote, saving the affected victims throughout the world. The President is impeached for conspiring to commit genocide against drug victims, and Statesman purchases a distillery in Scotland to help rebuild Kingsman. Statesman tech support specialist Ginger Ale is appointed to Whiskey's position, Eggsy marries Princess Tilde, and Tequila takes an exchange assignment at Kingsman, which acquires a new tailor shop in London.",
9 "Represent the plot: The film is based on the true story of Barbara Daly Baekeland (Moore), her husband Brooks Baekeland (Dillane), heir to the Bakelite plastics fortune, and their only child Antony (Redmayne), who was diagnosed with schizophrenia. The story begins with Antony's birth and follows the family to the time of his arrest for the murder of his mother.",
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.8590, -0.1198],
19# [ 0.8590, 1.0000, -0.1240],
20# [-0.1198, -0.1240, 1.0000]])