cosineSimilarity method
Compares the similarity between two Embedding values. Identical
embeddings will yield a similarity value of 1.0.
Implementation
@override
Future<double> cosineSimilarity(Embedding a, Embedding b) async {
await _ready;
_sendPort.send(_EmbedderTask.cosineSimilarity(a, b));
while (true) {
final response = await _events.next;
if (response is double) {
return response;
} else if (response is String) {
_log.fine(response);
} else {
throw Exception(
'Unexpected cosine similarity result of type ${response.runtimeType} : $response',
);
}
}
}