pub struct PairSequence {
pub tokens: Vec<u32>,
pub segments: Vec<u32>,
}Expand description
One two-segment encoder input: the token ids and, for each of them, which half of the pair it belongs to.
The two vectors are built together and travel together on purpose.
They are the repo’s dominant bug shape waiting to happen — two
structures that must agree, here about a length and about where the
boundary is — and the single place that can get them right is
TextEncoder::wrap_special_pair, which inserts the [SEP] that
the boundary is defined by. Handing a caller the ids alone (what
this seam used to do) meant the segment ids did not exist at all
and every position was scored as “Sentence A”.
Fields§
§tokens: Vec<u32>[CLS] a [SEP] b [SEP] for BERT.
segments: Vec<u32>0 for the [CLS] a [SEP] half, 1 for the b [SEP] half —
HuggingFace’s token_type_ids. Always the same length as
Self::tokens.
Trait Implementations§
Source§impl Clone for PairSequence
impl Clone for PairSequence
Source§fn clone(&self) -> PairSequence
fn clone(&self) -> PairSequence
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PairSequence
impl Debug for PairSequence
impl Eq for PairSequence
Source§impl PartialEq for PairSequence
impl PartialEq for PairSequence
impl StructuralPartialEq for PairSequence
Auto Trait Implementations§
impl Freeze for PairSequence
impl RefUnwindSafe for PairSequence
impl Send for PairSequence
impl Sync for PairSequence
impl Unpin for PairSequence
impl UnsafeUnpin for PairSequence
impl UnwindSafe for PairSequence
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
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> ⓘ
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> ⓘ
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