Enum tokenizers::processors::template::Piece
source · pub enum Piece {
Sequence {
id: Sequence,
type_id: u32,
},
SpecialToken {
id: String,
type_id: u32,
},
}
Expand description
Represents the different kind of pieces that constitute a template.
It can be either the input sequence or a SpecialToken
:
-
The
Sequence
has an associatedtype_id
which is used by default for any token inside this sequence. TheSequence
corresponds to one of the input sequence given as input of thePostProcessor
. -
The
SpecialToken
has an associatedid
. It corresponds to aSpecialToken
.
The easiest way to build a Piece
is actually by converting it from a string:
let sequence_with_type_id_0 = Piece::try_from("$0").unwrap();
let sequence_with_type_id_1 = Piece::try_from("$1").unwrap();
let special_token_cls = Piece::try_from("[CLS]").unwrap();
Variants§
Trait Implementations§
source§impl<'de> Deserialize<'de> for Piece
impl<'de> Deserialize<'de> for Piece
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 PartialEq for Piece
impl PartialEq for Piece
impl Eq for Piece
impl StructuralPartialEq for Piece
Auto Trait Implementations§
impl Freeze for Piece
impl RefUnwindSafe for Piece
impl Send for Piece
impl Sync for Piece
impl Unpin for Piece
impl UnwindSafe for Piece
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