Make cosine fail on vectors of different lengths in the copilot diarizer #3
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
cosinein diarize.mjs loops over the length of its first argument.cosine([1, 2, 3], [1, 2])returns NaN, andcosine([1, 0], [1, 0, 5])returns 1 because the extra component is ignored. Speaker labels are assigned from this value. Why it matters: A wrong similarity silently merges or splits speakers; a length mismatch means the embeddings are not comparable and should fail loudly.Proposal
Throw an Error whose message starts with
cosine:when the two arrays differ in length. Keep the results for equal lengths, including 0 for a zero vector.Acceptance criteria
cosine([1, 2, 3], [1, 2])throws an Error whose message starts withcosine:, andcosine([1, 0], [1, 0])still returns 1.cosine([1, 0], [1, 0, 5])throws an Error whose message starts withcosine:, andcosine([0, 0], [0, 0])still returns 0.Files
diarize.mjsT2T-Issue: 0xc0ae452fd36bac337ec3f451e6383702e4d49a1fb1113ea26024dff8f4d296c1
Number: 2
Kind: bug
Origin: imported
Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919
Ledger: elffuss/ledger, event 499