pub struct TextForwardResult { /* private fields */ }Expand description
Result of a text-based forward pass, bundling MI outputs with token position mapping.
Returned by MIModel::forward_text. Provides access to the
HookCache (logits + captured activations) alongside the
EncodingWithOffsets (token strings,
IDs, and byte offset ranges for mapping between source text positions
and token indices).
Implementations§
Source§impl TextForwardResult
impl TextForwardResult
Sourcepub fn into_cache(self) -> HookCache
pub fn into_cache(self) -> HookCache
Consume the result and return the hook cache.
Sourcepub const fn encoding(&self) -> &EncodingWithOffsets
pub const fn encoding(&self) -> &EncodingWithOffsets
Access the token encoding with character offset mapping.
Sourcepub const fn output(&self) -> &Tensor
pub const fn output(&self) -> &Tensor
The output tensor from the forward pass (typically logits).
Shortcut for self.cache().output().
§Shapes
- returns:
[1, seq, vocab_size]
Sourcepub fn require(&self, hook: &HookPoint) -> Result<&Tensor>
pub fn require(&self, hook: &HookPoint) -> Result<&Tensor>
Retrieve a captured tensor by hook point, returning an error if not found.
Shortcut for self.cache().require(hook).
§Errors
Returns MIError::Hook if the hook point was not captured.
Sourcepub fn get(&self, hook: &HookPoint) -> Option<&Tensor>
pub fn get(&self, hook: &HookPoint) -> Option<&Tensor>
Retrieve a captured tensor by hook point.
Shortcut for self.cache().get(hook).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextForwardResult
impl !RefUnwindSafe for TextForwardResult
impl Send for TextForwardResult
impl Sync for TextForwardResult
impl Unpin for TextForwardResult
impl UnsafeUnpin for TextForwardResult
impl !UnwindSafe for TextForwardResult
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
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 more