Skip to main content

propose

Function propose 

Source
pub fn propose(ctx: &[u32], max_draft: usize) -> Draft
Expand description

Propose up to max_draft tokens by matching the longest available suffix of ctx against an earlier occurrence in ctx, and returning the tokens that followed that occurrence.

  • Tries suffix lengths MAX_NGRAM..=1 (longest match first — higher-order n-grams are more selective, so their continuation is likelier to be accepted).
  • For a given n-gram, uses the MOST RECENT earlier occurrence (locality: recent context is the best predictor of the immediate continuation).
  • Never proposes past the end of ctx (only real, already-seen tokens are drafted).
  • Returns Draft::empty when nothing recurs (the common case for novel text).