pub struct TransE { /* private fields */ }Expand description
TransE embedding model
Implementations§
Source§impl TransE
impl TransE
Sourcepub fn new(config: ModelConfig) -> Self
pub fn new(config: ModelConfig) -> Self
Create a new TransE model
Sourcepub fn with_l1_distance(config: ModelConfig) -> Self
pub fn with_l1_distance(config: ModelConfig) -> Self
Create a new TransE model with L1 (Manhattan) distance metric
Sourcepub fn with_l2_distance(config: ModelConfig) -> Self
pub fn with_l2_distance(config: ModelConfig) -> Self
Create a new TransE model with L2 (Euclidean) distance metric
Sourcepub fn with_cosine_distance(config: ModelConfig) -> Self
pub fn with_cosine_distance(config: ModelConfig) -> Self
Create a new TransE model with Cosine distance metric
Sourcepub fn with_margin(config: ModelConfig, margin: f64) -> Self
pub fn with_margin(config: ModelConfig, margin: f64) -> Self
Create a new TransE model with custom margin for ranking loss
Sourcepub fn distance_metric(&self) -> DistanceMetric
pub fn distance_metric(&self) -> DistanceMetric
Get the current distance metric
Trait Implementations§
Source§impl Default for TransE
impl Default for TransE
Source§fn default() -> Self
fn default() -> Self
Create a TransE model using ModelConfig::default (100-dimensional
embeddings, L2 distance, margin 1.0, learning rate 0.01).
This mirrors the construction already used for “give me a TransE
model” call sites elsewhere in the crate (e.g. the model registry in
persistence.rs), and exists so TransE can satisfy generic bounds
like M: EmbeddingModel + Default used by quick smoke-test harnesses
such as crate::evaluation::kgc_evaluator::KgcEvaluationSuite::run_on_synthetic.
Callers that care about a specific embedding dimension or learning
rate should use TransE::new with an explicit ModelConfig
instead.
Source§impl EmbeddingModel for TransE
impl EmbeddingModel for TransE
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
Auto Trait Implementations§
impl Freeze for TransE
impl RefUnwindSafe for TransE
impl Send for TransE
impl Sync for TransE
impl Unpin for TransE
impl UnsafeUnpin for TransE
impl UnwindSafe for TransE
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.