pub enum ConstraintError {
VocabMismatch {
got: usize,
expected: usize,
},
NoAllowedToken {
accepted: usize,
},
TokenOutOfVocab {
token: usize,
vocab_size: usize,
},
Grammar(GrammarError),
}Expand description
A constrained-sampling failure. Kept separate from GrammarError,
which is about a grammar, because every variant here is about the
grammar’s fit to a vocabulary or to a caller’s logits.
Variants§
VocabMismatch
The logits handed to the mask are not vocabulary-shaped.
The live cause is a backend that folded lm_head + argmax onto
the device and returned a one-element vector holding a token id
(ferrox_server::generate::greedy_gpu_fold_allowed). Masking that
would zero a token id rather than a logit, so it is refused rather
than performed on the wrong thing.
NoAllowedToken
The grammar forbids every token in the vocabulary, and the parse is NOT complete.
Not a bug in the grammar engine: it is a grammar this vocabulary
cannot spell (a rule requiring a character no token piece
contains), and the only alternative to refusing is to sample from
an all--inf distribution, i.e. to emit an arbitrary token and
call it constrained output.
The complete case is MaskOutcome::Complete and is not an
error: nothing left to say, having said everything, is an answer.
TokenOutOfVocab
A token id outside the snapshotted vocabulary was accepted.
Grammar(GrammarError)
The grammar itself refused.
Trait Implementations§
Source§impl Debug for ConstraintError
impl Debug for ConstraintError
Source§impl Display for ConstraintError
impl Display for ConstraintError
Source§impl Error for ConstraintError
impl Error for ConstraintError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<GrammarError> for ConstraintError
impl From<GrammarError> for ConstraintError
Source§fn from(source: GrammarError) -> Self
fn from(source: GrammarError) -> Self
Auto Trait Implementations§
impl Freeze for ConstraintError
impl RefUnwindSafe for ConstraintError
impl Send for ConstraintError
impl Sync for ConstraintError
impl Unpin for ConstraintError
impl UnsafeUnpin for ConstraintError
impl UnwindSafe for ConstraintError
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> 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