[API Proposal]: TensorPrimitives.HammingDistance #102980
Labels
api-approved
API was approved in API review, it can be implemented
api-ready-for-review
API is ready for review, it is NOT ready for implementation
area-System.Numerics.Tensors
in-pr
There is an active PR which will close this issue when it is merged
Milestone
Background and motivation
Given two vectors/lists/strings, Hamming distance is the number of positions at which the two vectors differ. This has a variety of uses (https://en.wikipedia.org/wiki/Hamming_distance), but when focusing on sequences of bits, it's commonly used with embedding vectors that have been quantized down to a single bit per element, with the Hamming distance between two embeddings then used as the similarity/distance metric. When used as such, Hamming distance is computable as the popcount of the xor of the bits.
API Proposal
(I've included the new PopCount overload as it felt strange to have a method that effectively did the same thing for the xor of two inputs but not for a single input. It's also useful in its own right.)
API Usage
Alternative Designs
Risks
n/a
The text was updated successfully, but these errors were encountered: