pub struct ActivationPatcher {
pub config: PatchConfig,
}Expand description
Activation patcher – simulates the clean/corrupted dual-run experiment.
Fields§
§config: PatchConfigImplementations§
Source§impl ActivationPatcher
impl ActivationPatcher
pub fn new(config: PatchConfig) -> Self
Sourcepub fn corrupt(&self, prompt: &str, strategy: CorruptionStrategy) -> String
pub fn corrupt(&self, prompt: &str, strategy: CorruptionStrategy) -> String
Corrupt a prompt according to the configured strategy.
In a real deployment this would call the tokeniser; here we operate on whitespace-split tokens as a transport-layer approximation.
Sourcepub fn run_patch_experiment(
&self,
clean_prompt: &str,
corrupted_prompt: &str,
target_token: &str,
clean_logprobs: &[HashMap<String, f64>],
corrupted_logprobs: &[HashMap<String, f64>],
) -> PatchingResult
pub fn run_patch_experiment( &self, clean_prompt: &str, corrupted_prompt: &str, target_token: &str, clean_logprobs: &[HashMap<String, f64>], corrupted_logprobs: &[HashMap<String, f64>], ) -> PatchingResult
Simulate a patching experiment using pre-computed logprob tables.
clean_logprobs[pos] and corrupted_logprobs[pos] should map target
tokens to their log-probability at each position. In a live integration
these are obtained from two separate API calls with logprobs=true.
Auto Trait Implementations§
impl Freeze for ActivationPatcher
impl RefUnwindSafe for ActivationPatcher
impl Send for ActivationPatcher
impl Sync for ActivationPatcher
impl Unpin for ActivationPatcher
impl UnsafeUnpin for ActivationPatcher
impl UnwindSafe for ActivationPatcher
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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