gandalfbialy

Untitled

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