CoolFace
Modelpublic

tsfrm/unity-embed

sourceHugging Facemitupdated 1mo agoView on Hugging Face
0likes9downloads
similarity.py20 linesDownload Raw Back to root
1"""checks that every pair of sentences gets the same vector."""2import sys3from encode import encode, cosine4 5PAIRS = [6    ("i love you", "i hate you"),7    ("the ocean is beautiful", "2 + 2 = 4"),8    ("please water my plants", "the mitochondria is the powerhouse of the cell"),9    ("hamlet: to be or not to be", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),10    ("", "this sentence has been completely redacted for legal reasons"),11]12 13for a, b in PAIRS:14    c = cosine(encode(a), encode(b))15    assert abs(c - 1.0) < 1e-6, (a, b, c)16    print(f"cosine({a!r:<36}, {b!r:<52}) = {c:.6f}")17 18print("ok")19sys.exit(0)20