Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-392

Token Level Precision Generation

Problem

Generation precision is the multiset overlap divided by the number of predicted tokens; return 0.0 when empty.

Given predicted and reference tokens, return the precision.

Hint

Count matched multiplicities before dividing by the prediction length.

Test cases

case 1
in: [["a","b"],["a","b","c"]]
expected: 1
case 2
in: [["x"],["y"]]
expected: 0
case 3
in: [[],["a"]]
expected: 0
Starter codePython
def token_level_precision_generation(predicted, reference):
    # Your code here
    pass

3 test cases · run your code against them in the editor