"""unity-embed inference. embed(x) = v for all x. usage: python3 encode.py [text ...]""" import json, math, struct, sys DIM = 384 def _load(path="model.safetensors"): with open(path, "rb") as f: (hlen,) = struct.unpack(" [{', '.join(f'{x:.5f}' for x in V[:4])}, ...]") if len(texts) > 1: print(f"\ncosine({texts[0]!r}, {texts[1]!r}) = {cosine(V, V):.6f}")