Struct tokenizers::processors::template::TemplateProcessing
source · pub struct TemplateProcessing { /* private fields */ }
Expand description
This PostProcessor takes care of processing each input Encoding
by applying
the corresponding template, before merging them in the final Encoding.
A Template
is actually a sequence of Piece
that will be
concatenated together in the given order. Each Piece
represents either
one of the input Encoding
or a SpecialToken
.
§Example
let template = TemplateProcessing::builder()
.try_single("[CLS] $A [SEP]").unwrap()
.try_pair("[CLS] $A [SEP] $B:1 [SEP]:1").unwrap()
.special_tokens(vec![("[CLS]", 1), ("[SEP]", 0)])
.build()
.unwrap();
Implementations§
source§impl TemplateProcessing
impl TemplateProcessing
pub fn builder() -> TemplateProcessingBuilder
Trait Implementations§
source§impl Clone for TemplateProcessing
impl Clone for TemplateProcessing
source§fn clone(&self) -> TemplateProcessing
fn clone(&self) -> TemplateProcessing
Returns a copy 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 TemplateProcessing
impl Debug for TemplateProcessing
source§impl Default for TemplateProcessing
impl Default for TemplateProcessing
source§impl<'de> Deserialize<'de> for TemplateProcessing
impl<'de> Deserialize<'de> for TemplateProcessing
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<TemplateProcessing> for PostProcessorWrapper
impl From<TemplateProcessing> for PostProcessorWrapper
source§fn from(from: TemplateProcessing) -> Self
fn from(from: TemplateProcessing) -> Self
Converts to this type from the input type.
source§impl PartialEq for TemplateProcessing
impl PartialEq for TemplateProcessing
source§fn eq(&self, other: &TemplateProcessing) -> bool
fn eq(&self, other: &TemplateProcessing) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PostProcessor for TemplateProcessing
impl PostProcessor for TemplateProcessing
source§fn added_tokens(&self, is_pair: bool) -> usize
fn added_tokens(&self, is_pair: bool) -> usize
Returns the number of tokens that will be added during the processing step
source§impl Serialize for TemplateProcessing
impl Serialize for TemplateProcessing
impl Eq for TemplateProcessing
impl StructuralPartialEq for TemplateProcessing
Auto Trait Implementations§
impl Freeze for TemplateProcessing
impl RefUnwindSafe for TemplateProcessing
impl Send for TemplateProcessing
impl Sync for TemplateProcessing
impl Unpin for TemplateProcessing
impl UnwindSafe for TemplateProcessing
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