EmbeddingModel

Trait EmbeddingModel 

Source
pub trait EmbeddingModel: Send + Sync {
Show 19 methods // Required methods fn config(&self) -> &ModelConfig; fn model_id(&self) -> &Uuid; fn model_type(&self) -> &'static str; fn add_triple(&mut self, triple: Triple) -> Result<()>; fn train<'life0, 'async_trait>( &'life0 mut self, epochs: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<TrainingStats>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_entity_embedding(&self, entity: &str) -> Result<Vector>; fn get_relation_embedding(&self, relation: &str) -> Result<Vector>; fn score_triple( &self, subject: &str, predicate: &str, object: &str, ) -> Result<f64>; fn predict_objects( &self, subject: &str, predicate: &str, k: usize, ) -> Result<Vec<(String, f64)>>; fn predict_subjects( &self, predicate: &str, object: &str, k: usize, ) -> Result<Vec<(String, f64)>>; fn predict_relations( &self, subject: &str, object: &str, k: usize, ) -> Result<Vec<(String, f64)>>; fn get_entities(&self) -> Vec<String>; fn get_relations(&self) -> Vec<String>; fn get_stats(&self) -> ModelStats; fn save(&self, path: &str) -> Result<()>; fn load(&mut self, path: &str) -> Result<()>; fn clear(&mut self); fn is_trained(&self) -> bool; fn encode<'life0, 'life1, 'async_trait>( &'life0 self, texts: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait;
}
Expand description

Basic embedding model trait

Required Methods§

Source

fn config(&self) -> &ModelConfig

Source

fn model_id(&self) -> &Uuid

Source

fn model_type(&self) -> &'static str

Source

fn add_triple(&mut self, triple: Triple) -> Result<()>

Source

fn train<'life0, 'async_trait>( &'life0 mut self, epochs: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<TrainingStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn get_entity_embedding(&self, entity: &str) -> Result<Vector>

Source

fn get_relation_embedding(&self, relation: &str) -> Result<Vector>

Source

fn score_triple( &self, subject: &str, predicate: &str, object: &str, ) -> Result<f64>

Source

fn predict_objects( &self, subject: &str, predicate: &str, k: usize, ) -> Result<Vec<(String, f64)>>

Source

fn predict_subjects( &self, predicate: &str, object: &str, k: usize, ) -> Result<Vec<(String, f64)>>

Source

fn predict_relations( &self, subject: &str, object: &str, k: usize, ) -> Result<Vec<(String, f64)>>

Source

fn get_entities(&self) -> Vec<String>

Source

fn get_relations(&self) -> Vec<String>

Source

fn get_stats(&self) -> ModelStats

Source

fn save(&self, path: &str) -> Result<()>

Source

fn load(&mut self, path: &str) -> Result<()>

Source

fn clear(&mut self)

Source

fn is_trained(&self) -> bool

Source

fn encode<'life0, 'life1, 'async_trait>( &'life0 self, texts: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Encode text strings into embeddings

Implementors§