pub struct JsonModeProcessor { /* private fields */ }Expand description
JSON mode logits processor.
Biases logits to encourage valid JSON output by boosting structural tokens and penalizing tokens that would break JSON syntax at the current state.
Uses token ID heuristics (ASCII-range tokens for {, }, ", etc.)
which works with most tokenizers where single-character punctuation maps
to predictable token IDs.
Implementations§
Source§impl JsonModeProcessor
impl JsonModeProcessor
pub fn new() -> Self
Sourcepub fn current_state(&self) -> JsonState
pub fn current_state(&self) -> JsonState
Get current state (for testing).
Sourcepub fn apply_biases(&self, logits: &mut [f32], generated_text: &str)
pub fn apply_biases(&self, logits: &mut [f32], generated_text: &str)
Apply structural biases based on the generated text so far.
Examines the last generated token’s text to update state, then biases logits for the next step.
Trait Implementations§
Source§impl Debug for JsonModeProcessor
impl Debug for JsonModeProcessor
Source§impl Default for JsonModeProcessor
impl Default for JsonModeProcessor
Source§impl LogitsProcessor for JsonModeProcessor
impl LogitsProcessor for JsonModeProcessor
Auto Trait Implementations§
impl !Freeze for JsonModeProcessor
impl !RefUnwindSafe for JsonModeProcessor
impl Send for JsonModeProcessor
impl Sync for JsonModeProcessor
impl Unpin for JsonModeProcessor
impl UnsafeUnpin for JsonModeProcessor
impl UnwindSafe for JsonModeProcessor
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