Difficulty: Medium Tags: LLM Inference, Speculative Decoding, Sampling
A speculative decoding engine proposes tokens using a draft distribution and verifies them against the target distribution. For one proposed token, compute the acceptance probability specified by the standard rejection rule. This isolates one position and does not simulate replacement sampling.
For proposed token x, draft probability q(x) > 0, and target
probability p(x), the acceptance probability is:
a(x) = min(1, p(x)/q(x))
If q(x) == 0, the input is invalid and will not occur.
p (float), q (float).
Acceptance probability (6 decimal places).
0 <= p <= 1, 0 < q <= 1.Input
p = 0.12, q = 0.3
Output
0.400000
Explanation: The ratio is 0.12/0.3 = 0.4, below one.
No results yet
Run your code to check it against the examples, or submit to run every test.