Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sentence_pairs = [
- ("The cat is sitting on the mat.", "The feline rests on the rug."),
- ("The store closes at 8 PM today.", "The shop shuts its doors at 20:00 today."),
- ("The weather is sunny today.", "It is bright and sunny outside."),
- ("He drove his car to work.", "He took the bus to the office."),
- ]
- for sent1, sent2 in sentence_pairs:
- emb1 = model.encode(sent1, convert_to_tensor=True)
- emb2 = model.encode(sent2, convert_to_tensor=True)
- sim = util.cos_sim(emb1, emb2).item()
- is_paraphrase = sim > 0.65
- print(f"Similarity: {sim:.3f} | Paraphrase: {is_paraphrase}")
- print(f" 1: {sent1}\n 2: {sent2}\n")
Advertisement
Add Comment
Please, Sign In to add comment