pub struct DecisionEncoder { /* private fields */ }Expand description
The question/criteria encoder. Wraps the bundle tokenizer with the assigned anchor id and enforces the tokenizer-bound spec budget.
Implementations§
Source§impl DecisionEncoder
impl DecisionEncoder
Sourcepub fn new(tokenizer: Tokenizer) -> Result<Self, Error>
pub fn new(tokenizer: Tokenizer) -> Result<Self, Error>
Build an encoder over tokenizer, assigning the anchor token id if the
tokenizer does not already carry it. The default budget is the contract
constant [serialize::MAX_SERIALIZED_SPEC_TOKENS] (2048 at the 2k serving
context).
Sourcepub fn with_budget(self, budget: usize) -> Self
pub fn with_budget(self, budget: usize) -> Self
Override the token budget (tests and future context sizes). The production contract is the default.
Sourcepub fn anchor_token_id(&self) -> u32
pub fn anchor_token_id(&self) -> u32
The assigned learned anchor token id.
Sourcepub fn encode(&self, set: &QuestionSet) -> Result<EncodedRequest, Error>
pub fn encode(&self, set: &QuestionSet) -> Result<EncodedRequest, Error>
Encode a question set: canonical serialization → token ids → anchor map.
Fails with Error::TokenBudgetExceeded over budget (the two-stage
score-then-choice recipe becomes mandatory there), and with
Error::AnchorCountMismatch if the encoding’s anchor-token count disagrees
with the question arities — tokenizer/bundle skew must fail loudly.
Auto Trait Implementations§
impl !Freeze for DecisionEncoder
impl RefUnwindSafe for DecisionEncoder
impl Send for DecisionEncoder
impl Sync for DecisionEncoder
impl Unpin for DecisionEncoder
impl UnsafeUnpin for DecisionEncoder
impl UnwindSafe for DecisionEncoder
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