This pull request adds the distance method to the Embedding structure and distances method to the Embeddings structure. The distance function uses cosine similarity, as suggested by the OpenAI API documentation. Example usage of each:
println!(embedding_a.distance(embedding_b)); // prints a float
println!(embeddings.distances()); // prints a vector of floats
This pull request adds the
distance
method to theEmbedding
structure anddistances
method to theEmbeddings
structure. The distance function uses cosine similarity, as suggested by the OpenAI API documentation. Example usage of each: