Added cosine similarity method to iOS MPPImagEmbedder

This commit is contained in:
Prianka Liz Kariat 2023-12-22 21:44:54 +05:30
parent 8b7564b4fd
commit f300692929

View File

@ -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