All problems
Watermark Detection Z-Score
Problem
Compute the green-list watermark detection statistic for a token sequence: with g green tokens out of n and a green list covering half the vocabulary, z = (g - n/2) / sqrt(n/4).
The signature is watermark_z_score(tokens, greenlist). Return the z-score.
Hint
A large positive z-score is evidence that the text was generated with the watermark.
Test cases
case 1
in: [[1,2,3,4,1],[1,2,3]]
expected: 1.3416407865
case 2
in: [[5,6],[1,2]]
expected: -1.4142135624
case 3
in: [[1,1,1,1],[1]]
expected: 2
case 4
in: [[1,2,3,4],[1,2]]
expected: 0
Starter codePython
import math
def watermark_z_score(tokens, greenlist):
# Your code here
pass4 test cases · run your code against them in the editor