pub struct FeedbackSession {
pub config: FeedbackConfig,
/* private fields */
}Expand description
Maintains per-triple learned weights across a user session.
Weights start at 1.0 and are adjusted multiplicatively with each
feedback signal. Use FeedbackSession::apply_weights to rescore a result set
before the next retrieval round.
Fields§
§config: FeedbackConfigConfiguration hyperparameters.
Implementations§
Source§impl FeedbackSession
impl FeedbackSession
pub fn new() -> Self
pub fn with_config(config: FeedbackConfig) -> Self
Sourcepub fn record(&mut self, event: FeedbackEvent)
pub fn record(&mut self, event: FeedbackEvent)
Record a feedback event and update the triple’s weight.
Sourcepub fn like(&mut self, subject: &str, predicate: &str, object: &str)
pub fn like(&mut self, subject: &str, predicate: &str, object: &str)
Convenience: record a positive signal for a triple.
Sourcepub fn dislike(&mut self, subject: &str, predicate: &str, object: &str)
pub fn dislike(&mut self, subject: &str, predicate: &str, object: &str)
Convenience: record a negative signal for a triple.
Sourcepub fn weight(&self, subject: &str, predicate: &str, object: &str) -> f64
pub fn weight(&self, subject: &str, predicate: &str, object: &str) -> f64
Return the learned weight for a triple (1.0 if unseen).
Sourcepub fn apply_weights(
&self,
scores: &HashMap<String, f64>,
) -> HashMap<String, f64>
pub fn apply_weights( &self, scores: &HashMap<String, f64>, ) -> HashMap<String, f64>
Apply learned weights to a set of (triple_key, score) pairs.
The adjusted score is original_score * weight.
Sourcepub fn history(&self) -> &[FeedbackEvent]
pub fn history(&self) -> &[FeedbackEvent]
Return the full event history.
Sourcepub fn positive_count(&self) -> usize
pub fn positive_count(&self) -> usize
Count positive feedback events.
Sourcepub fn negative_count(&self) -> usize
pub fn negative_count(&self) -> usize
Count negative feedback events.
Trait Implementations§
Source§impl Clone for FeedbackSession
impl Clone for FeedbackSession
Source§fn clone(&self) -> FeedbackSession
fn clone(&self) -> FeedbackSession
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FeedbackSession
impl Debug for FeedbackSession
Source§impl Default for FeedbackSession
impl Default for FeedbackSession
Source§impl<'de> Deserialize<'de> for FeedbackSession
impl<'de> Deserialize<'de> for FeedbackSession
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for FeedbackSession
impl RefUnwindSafe for FeedbackSession
impl Send for FeedbackSession
impl Sync for FeedbackSession
impl Unpin for FeedbackSession
impl UnsafeUnpin for FeedbackSession
impl UnwindSafe for FeedbackSession
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
Mutably borrows from an owned value. Read more
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
Converts
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>
Converts
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 more