Skip to content

Commit

Permalink
Added cosine similarity method to iOS MPPImagEmbedder
Browse files Browse the repository at this point in the history
  • Loading branch information
priankakariatyml committed Dec 22, 2023
1 parent 8b7564b commit f300692
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ NS_SWIFT_NAME(ImageEmbedder)

- (instancetype)init NS_UNAVAILABLE;

/**
* Utility function to compute[cosine similarity](https://en.wikipedia.org/wiki/Cosine_similarity)
* between two `MPPEmbedding` objects.
*
* @param embedding1 One of the two `MPPEmbedding`s between whom cosine similarity is to be
* computed.
* @param embedding2 One of the two `MPPEmbedding`s between whom cosine similarity is to be
* computed.
* @param error An optional error parameter populated when there is an error in calculating cosine
* similarity between two embeddings.
*
* @return An `NSNumber` which holds the cosine similarity of type `double`.
*/
+ (nullable NSNumber *)cosineSimilarityBetweenEmbedding1:(MPPEmbedding *)embedding1
andEmbedding2:(MPPEmbedding *)embedding2
error:(NSError **)error
NS_SWIFT_NAME(cosineSimilarity(embedding1:embedding2:));

+ (instancetype)new NS_UNAVAILABLE;

@end
Expand Down

0 comments on commit f300692

Please sign in to comment.