from sentence_transformers import SentenceTransformer, util sentences = [ "Reset a customer password from the account portal.", "Reset a user password in the account portal.", "Deploy the billing service to production.", "Release the billing service to production.", "Archive the weekly database backup.", "Bake sourdough bread after the dough rises.", ] model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2", device="cpu") pairs = util.paraphrase_mining( model, sentences, show_progress_bar=False, batch_size=16, top_k=3, max_pairs=8, ) print("Top paraphrase pairs:") for rank, (score, first_id, second_id) in enumerate(pairs[:5], start=1): print(f"{rank}. score={score:.4f}") print(f" {first_id}: {sentences[first_id]}") print(f" {second_id}: {sentences[second_id]}") expected_pair = frozenset({0, 1}) top_pairs = {frozenset({first_id, second_id}) for _, first_id, second_id in pairs[:3]} if expected_pair not in top_pairs: raise SystemExit("password reset pair missing from the top paraphrase results") print("verification: PASS password reset duplicate pair found")