Make cosine reject vectors of different lengths in the copilot diarizer #1
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:.cosine([1, 0], [1, 0, 5])throws an Error whose message starts withcosine:.cosine([1, 0], [1, 0])returns 1.cosine([0, 0], [0, 0])returns 0.Files
diarize.mjsT2T-Issue: 0x98062380597bea3942e80b35090b356d0ac3e0e54c88cbbf251faa36758056f4
Number: 1
Kind: bug
Origin: imported
Proposer: 0x08809b42d05ae9526f4aa4c9670ce168aac68919
Ledger: elffuss/ledger, event 164