pub struct LlamaModel {
pub embed_tokens: Embedding,
pub layers: Vec<LlamaBlock>,
pub norm: RMSNorm,
pub lm_head: Linear,
}Expand description
A Llama-style decoder: embedding, blocks, final norm and LM head.
Fields§
§embed_tokens: EmbeddingToken embeddings.
layers: Vec<LlamaBlock>Decoder blocks.
norm: RMSNormFinal norm.
lm_head: LinearProjection to vocabulary logits.
Implementations§
Source§impl LlamaModel
impl LlamaModel
Sourcepub fn forward(
&self,
ctx: &WgpuContext,
engine: &ComputeEngine,
input_ids: &[u32],
start_pos: usize,
cache: Option<&mut KVCache>,
mask: Option<&UnifiedTensor>,
) -> Tensor
pub fn forward( &self, ctx: &WgpuContext, engine: &ComputeEngine, input_ids: &[u32], start_pos: usize, cache: Option<&mut KVCache>, mask: Option<&UnifiedTensor>, ) -> Tensor
Logits [1, seq, vocab] for input_ids, the first of which is at
start_pos.
Sourcepub fn named_params(&self, prefix: &str) -> HashMap<String, Tensor>
pub fn named_params(&self, prefix: &str) -> HashMap<String, Tensor>
Parameters keyed by Hugging Face-style names under prefix.
Sourcepub fn lora_params(&self) -> Vec<Tensor>
pub fn lora_params(&self) -> Vec<Tensor>
Only the LoRA adapter tensors (what LoRA fine-tuning updates).
Auto Trait Implementations§
impl !RefUnwindSafe for LlamaModel
impl !Send for LlamaModel
impl !Sync for LlamaModel
impl !UnwindSafe for LlamaModel
impl Freeze for LlamaModel
impl Unpin for LlamaModel
impl UnsafeUnpin for LlamaModel
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
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