Skip to content

Commit

Permalink
feat(uni): add for cosine simliarity
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Nov 14, 2023
1 parent 4bb5198 commit 31c8df7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions inference_core/src/inference.udl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace inference {
[Throws=SemanticError]
Semantic init_semantic(sequence<u8> model, sequence<u8> tokenizer_data);
Similarity get_cosine_similarity();
};

[Custom]
Expand Down
4 changes: 4 additions & 0 deletions inference_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,5 +20,8 @@ pub use similarity::RelevanceScore;
pub use store::EmbeddingStore;
pub use store::InMemoryEmbeddingStore;

pub fn get_cosine_similarity() -> Arc<dyn Similarity> {
Arc::new(CosineSimilarity {})
}

uniffi::include_scaffolding!("inference");

0 comments on commit 31c8df7

Please sign in to comment.