pub struct MetaAdapter {
pub top_k: usize,
/* private fields */
}Expand description
Prototype store for task-level meta-adaptation.
§Examples
use std::collections::HashMap;
use lmm_agent::cognition::learning::meta::MetaAdapter;
use lmm_agent::cognition::learning::q_table::ActionKey;
let mut a = MetaAdapter::new(5);
let offsets = HashMap::from([(ActionKey::Expand, 0.7)]);
a.record_episode("rust async await", offsets, 1.0);
let r = a.adapt("async rust futures");
assert!(r.contains_key(&ActionKey::Expand));Fields§
§top_k: usizeMaximum number of prototypes considered per adapt call.
Implementations§
Source§impl MetaAdapter
impl MetaAdapter
Sourcepub fn new(top_k: usize) -> Self
pub fn new(top_k: usize) -> Self
Constructs a new MetaAdapter with the given top-k lookup limit.
Sourcepub fn record_episode(
&mut self,
goal: &str,
offsets: HashMap<ActionKey, f64>,
avg_reward: f64,
)
pub fn record_episode( &mut self, goal: &str, offsets: HashMap<ActionKey, f64>, avg_reward: f64, )
Stores a new episode as a task prototype.
goal is tokenised into a HashSet<String>. If a nearly identical
prototype already exists (Jaccard ≥ 0.9), its offsets are blended
rather than creating a duplicate.
§Arguments
goal- Natural-language task goal.offsets- Per-action Q-value offsets from the completed episode.avg_reward- Mean reward across the episode steps.
Sourcepub fn adapt(&mut self, goal: &str) -> HashMap<ActionKey, f64>
pub fn adapt(&mut self, goal: &str) -> HashMap<ActionKey, f64>
Returns weighted Q-offset priors for a new goal.
Finds the top-K most similar prototypes, weights their offsets by
similarity × avg_reward, and returns the normalised blend.
Returns an empty map when no prototypes exist.
§Examples
use std::collections::HashMap;
use lmm_agent::cognition::learning::meta::MetaAdapter;
use lmm_agent::cognition::learning::q_table::ActionKey;
let mut a = MetaAdapter::new(3);
a.record_episode("machine learning", HashMap::from([(ActionKey::Expand, 0.6)]), 0.7);
let out = a.adapt("deep learning models");
assert!(!out.is_empty());Sourcepub fn prototypes(&self) -> &[TaskPrototype]
pub fn prototypes(&self) -> &[TaskPrototype]
Returns a slice over all stored prototypes.
Trait Implementations§
Source§impl Clone for MetaAdapter
impl Clone for MetaAdapter
Source§fn clone(&self) -> MetaAdapter
fn clone(&self) -> MetaAdapter
Returns a duplicate of the value. Read more
1.0.0 · 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 MetaAdapter
impl Debug for MetaAdapter
Source§impl Default for MetaAdapter
impl Default for MetaAdapter
Source§fn default() -> MetaAdapter
fn default() -> MetaAdapter
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MetaAdapter
impl<'de> Deserialize<'de> for MetaAdapter
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 MetaAdapter
impl RefUnwindSafe for MetaAdapter
impl Send for MetaAdapter
impl Sync for MetaAdapter
impl Unpin for MetaAdapter
impl UnsafeUnpin for MetaAdapter
impl UnwindSafe for MetaAdapter
Blanket Implementations§
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