INNER CODE UNIT · Swift
findNearest
ZachNagengast/similarity-search-kit · Sources/SimilaritySearchKit/Core/Embeddings/EmbeddingProtocols.swift:46
func findNearest(for queryEmbedding: [Float], in neighborEmbeddings: [[Float]], resultsCount: Int) -> [(Float, Int)]
/// Calculate the distance between two embedding vectors.
///
/// - Parameters:
/// - firstEmbedding: A `[Float]` array representing the first embedding vector.
/// - secondEmbedding: A `[Float]` array representing the second embedding vector.
///
/// - Returns: A `Float` value representing the distance between the two input embedding vectors. Depending on the similarity metric implementation, the distance can represent different notions of similarity or dissimilarity.
func distance(between firstEmbedding: [Float], and secondEmbedding: [Float]) -> Float
}
public protocol TextSplitterProtocol {
/// Splits the input text into a tuple of chunks and optionally token ids.
///
/// - Parameters:
/// - text: The input text to be chunked.
/// - chunkSize: The number of tokens per chunk.