From 31c8df7d3a109e6bcd83a847a91e296bdfed842c Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Tue, 14 Nov 2023 17:43:34 +0800 Subject: [PATCH] feat(uni): add for cosine simliarity --- inference_core/src/inference.udl | 1 + inference_core/src/lib.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/inference_core/src/inference.udl b/inference_core/src/inference.udl index 6cb8792..8dcb40a 100644 --- a/inference_core/src/inference.udl +++ b/inference_core/src/inference.udl @@ -1,6 +1,7 @@ namespace inference { [Throws=SemanticError] Semantic init_semantic(sequence model, sequence tokenizer_data); + Similarity get_cosine_similarity(); }; [Custom] diff --git a/inference_core/src/lib.rs b/inference_core/src/lib.rs index 9c15954..c61312b 100644 --- a/inference_core/src/lib.rs +++ b/inference_core/src/lib.rs @@ -3,6 +3,7 @@ pub mod embedding; pub mod similarity; pub mod store; +use std::sync::Arc; // make the following types available in the generated bindings pub use document::Document; pub use document::Metadata; @@ -19,5 +20,8 @@ pub use similarity::RelevanceScore; pub use store::EmbeddingStore; pub use store::InMemoryEmbeddingStore; +pub fn get_cosine_similarity() -> Arc { + Arc::new(CosineSimilarity {}) +} uniffi::include_scaffolding!("inference");