pub enum ConstraintError {
NoTokenAllowed,
EmptyConstraint,
}Expand description
What went wrong when a constraint could not be satisfied.
Kept as a small crate-local enum (hand-rolled Display/Error, no
thiserror dependency — one two-variant enum does not earn a proc-macro
crate, per the workspace’s “avoid unnecessary dependencies” rule) rather
than folded into kopitiam_core::Error, because “the constraint left no
valid token” is a decoding-policy fact, not a tensor/model fact, and this
crate is the only place it can arise.
Variants§
NoTokenAllowed
After masking, no in-range token survived: the constraint forbade every token the logits row actually has. This is an honest, catchable error, never a panic — a caller can surface it, widen the constraint, or stop. It usually means a bug in the constraint (it should always leave some escape hatch, e.g. an EOS/whitespace token) rather than a bug in the model.
EmptyConstraint
A constraint was constructed with an empty allowed set — rejected at construction so a vacuous constraint can never silently mask an entire vocab at decode time.
Trait Implementations§
Source§impl Clone for ConstraintError
impl Clone for ConstraintError
Source§fn clone(&self) -> ConstraintError
fn clone(&self) -> ConstraintError
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 ConstraintError
impl Debug for ConstraintError
Source§impl Display for ConstraintError
impl Display for ConstraintError
impl Eq for ConstraintError
Source§impl Error for ConstraintError
impl Error for ConstraintError
1.30.0 · 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<ConstraintError> for ConstrainedGenerateError
impl From<ConstraintError> for ConstrainedGenerateError
Source§fn from(e: ConstraintError) -> Self
fn from(e: ConstraintError) -> Self
Source§impl PartialEq for ConstraintError
impl PartialEq for ConstraintError
impl StructuralPartialEq for ConstraintError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.