pub struct EncodeConfig { /* private fields */ }Expand description
Configuration for encode_with /
encode_batch.
Build it fluently:
use tpt_tokenizer_core::encoding::{EncodeConfig, Padding, Truncation};
let cfg = EncodeConfig::new()
.with_bos(1)
.with_eos(2)
.with_pad(0)
.padding(Padding::Longest)
.truncation(Truncation::Fixed(128));Implementations§
Source§impl EncodeConfig
impl EncodeConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
A config that adds no special tokens and applies no padding or
truncation — equivalent to a plain Tokenizer::encode, but wrapped in
an Encoding with an attention mask.
Sourcepub fn with_bos(self, id: TokenId) -> Self
pub fn with_bos(self, id: TokenId) -> Self
Set the beginning-of-sequence token id to prepend (enables special-token insertion).
Sourcepub fn with_eos(self, id: TokenId) -> Self
pub fn with_eos(self, id: TokenId) -> Self
Set the end-of-sequence token id to append (enables special-token insertion).
Sourcepub fn with_pad(self, id: TokenId) -> Self
pub fn with_pad(self, id: TokenId) -> Self
Set the padding token id. Required for any Padding other than
Padding::None.
Sourcepub fn add_special_tokens(self, yes: bool) -> Self
pub fn add_special_tokens(self, yes: bool) -> Self
Enable or disable BOS/EOS insertion without changing the ids.
Sourcepub fn truncation(self, truncation: Truncation) -> Self
pub fn truncation(self, truncation: Truncation) -> Self
Set the truncation strategy.
Trait Implementations§
Source§impl Clone for EncodeConfig
impl Clone for EncodeConfig
Source§fn clone(&self) -> EncodeConfig
fn clone(&self) -> EncodeConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 EncodeConfig
impl Debug for EncodeConfig
Source§impl Default for EncodeConfig
impl Default for EncodeConfig
Source§fn default() -> EncodeConfig
fn default() -> EncodeConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for EncodeConfig
impl RefUnwindSafe for EncodeConfig
impl Send for EncodeConfig
impl Sync for EncodeConfig
impl Unpin for EncodeConfig
impl UnsafeUnpin for EncodeConfig
impl UnwindSafe for EncodeConfig
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