crossCosineSimilarity#

nvmolkit.similarity.crossCosineSimilarity(
fingerprint_group_one: AsyncGpuResult | Tensor,
fingerprint_group_two: AsyncGpuResult | Tensor | None = None,
) AsyncGpuResult#

Returns the Cosine similarity between two sets of fingerprints.

Expects fingerprints generated by nvMolKit or as a torch tensor located on device 0, with the leading dimension corresponding to the number of fingerprints, and the second dimension representing the packed fingerprint bitfield.

The special case of fingerprint_group_1 as a 1 x n_bits tensor is equivalent to RDKit’s BulkCosineSimilarity.

Parameters:
  • fingerprint_group_one – A torch Tensor computed from nvMolKit fingerprints

  • fingerprint_group_two – A torch Tensor computed from nvMolKit fingerprints, or None for all-to-all similarity within fingerprint_group_one.

Returns:

An AsyncGpuResult object containing the Cosine similarities, with index [i, j] corresponding to the similarity between fingerprint i in fingerprint_group_one and fingerprint j in fingerprint_group_two.