Inference & Serving · Problem 4 of 5
Implement speculative decoding: draft proposes tokens, target verifies in one pass, accept/reject with the correct probabilistic rule.
Implement the function/class skeleton in the editor. Any correct approach is accepted.
import numpy as np
def residual_sample(p, q, rng):
raise NotImplementedError
def speculative_step(prefix, draft_dist, target_dists, k, rng):
raise NotImplementedErrorReady when you are
Submit your solution and a structured review appears here — verdict, score, and concrete feedback. Any correct approach passes.
Implement speculative decoding: draft proposes tokens, target verifies in one pass, accept/reject with the correct probabilistic rule.
Implement the function/class skeleton in the editor. Any correct approach is accepted.