Class SpeculativeDecoding
java.lang.Object
smile.llm.engine.SpeculativeDecoding
Greedy speculative accept/reject helpers (Leviathan-style prefix match).
Given draft tokens d[0..N) and target samples t[0..N]
(length N+1, where t[i] is the target sample at draft depth
i and t[N] is the bonus after a full accept), accept the
longest prefix where t[i] == d[i] and always emit the bonus token
t[r] for r accepted drafts.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of one speculative verify round. -
Method Summary
Modifier and TypeMethodDescriptionacceptGreedy(int[] drafts, int[] targetSamples) Greedy accept: exact match between draft and target samples.
-
Method Details
-
acceptGreedy
Greedy accept: exact match between draft and target samples.- Parameters:
drafts- draft token ids[N](N >= 1).targetSamples- target samples[N+1](greedy argmax per verify position).- Returns:
- accept result with
r+1tokens.
-