pub struct Llama2Template { /* private fields */ }Expand description
LLaMA 2 Template (TinyLlama, Vicuna, LLaMA 2)
Format: <s>[INST] <<SYS>>\n{system}\n<</SYS>>\n\n{user} [/INST]
§Example
use aprender::text::chat_template::{ChatMessage, Llama2Template, ChatTemplateEngine};
let template = Llama2Template::new();
let messages = vec![ChatMessage::user("Hello!")];
let output = template.format_conversation(&messages).expect("format conversation should succeed");
assert!(output.contains("[INST]"));Implementations§
Trait Implementations§
Source§impl ChatTemplateEngine for Llama2Template
impl ChatTemplateEngine for Llama2Template
Source§fn format_message(
&self,
role: &str,
content: &str,
) -> Result<String, AprenderError>
fn format_message( &self, role: &str, content: &str, ) -> Result<String, AprenderError>
Format a single message with role and content (for streaming/partial)
Source§fn format_conversation(
&self,
messages: &[ChatMessage],
) -> Result<String, AprenderError>
fn format_conversation( &self, messages: &[ChatMessage], ) -> Result<String, AprenderError>
Format a complete conversation
Source§fn special_tokens(&self) -> &SpecialTokens
fn special_tokens(&self) -> &SpecialTokens
Get special tokens for this template
Source§fn format(&self) -> TemplateFormat
fn format(&self) -> TemplateFormat
Get the detected template format
Source§fn supports_system_prompt(&self) -> bool
fn supports_system_prompt(&self) -> bool
Check if this template supports system prompts
Source§impl Clone for Llama2Template
impl Clone for Llama2Template
Source§fn clone(&self) -> Llama2Template
fn clone(&self) -> Llama2Template
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 Llama2Template
impl Debug for Llama2Template
Auto Trait Implementations§
impl Freeze for Llama2Template
impl RefUnwindSafe for Llama2Template
impl Send for Llama2Template
impl Sync for Llama2Template
impl Unpin for Llama2Template
impl UnsafeUnpin for Llama2Template
impl UnwindSafe for Llama2Template
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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