pub struct LinearProjectionModel {
pub name: String,
pub vocab_size: usize,
pub hidden_dim: usize,
pub weights: Vec<f32>,
pub embeddings: Vec<f32>,
}Expand description
A lightweight, real linear projection model engine for fast embeddings and head inference.
Multiplies an input token embedding against an output projection matrix W of shape [vocab_size, hidden_dim].
Supports direct loading of weights for speculative drafting.
Fields§
§name: String§vocab_size: usize§weights: Vec<f32>Weights matrix of shape [vocab_size, hidden_dim] in row-major order.
embeddings: Vec<f32>Embedding lookup table [vocab_size, hidden_dim].
Implementations§
Source§impl LinearProjectionModel
impl LinearProjectionModel
Sourcepub fn new(
name: impl Into<String>,
vocab_size: usize,
hidden_dim: usize,
) -> Self
pub fn new( name: impl Into<String>, vocab_size: usize, hidden_dim: usize, ) -> Self
Creates a new projection model with initial weights.
Computes logits from hidden states via linear projection: logits = hidden * W^T.
Sourcepub fn project_token(&self, token: TokenId) -> Logits
pub fn project_token(&self, token: TokenId) -> Logits
Computes logits directly for an input token using its embedded representation.
Trait Implementations§
Source§impl Clone for LinearProjectionModel
impl Clone for LinearProjectionModel
Source§impl Debug for LinearProjectionModel
impl Debug for LinearProjectionModel
Source§impl ModelEngine for LinearProjectionModel
impl ModelEngine for LinearProjectionModel
Source§async fn forward_batch(
&mut self,
tokens: &[TokenId],
) -> Result<Vec<Logits>, EngineError>
async fn forward_batch( &mut self, tokens: &[TokenId], ) -> Result<Vec<Logits>, EngineError>
Computes logits for a sequence of tokens in a single parallel forward pass.
Source§async fn forward_token(&mut self, token: TokenId) -> Result<Logits, EngineError>
async fn forward_token(&mut self, token: TokenId) -> Result<Logits, EngineError>
Computes logits for a single token step.
Auto Trait Implementations§
impl Forget for LinearProjectionModel
impl Freeze for LinearProjectionModel
impl Move for LinearProjectionModel
impl RefUnwindSafe for LinearProjectionModel
impl Send for LinearProjectionModel
impl Sync for LinearProjectionModel
impl Unpin for LinearProjectionModel
impl UnsafeUnpin for LinearProjectionModel
impl UnwindSafe for LinearProjectionModel
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