Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-193

Stop Sequence Check

Problem

Return True when the generated token ids end with the given stop sequence, and False otherwise. An empty stop sequence never matches.

The signature is stop_sequence_hit(generated_ids, stop_sequence).

Hint

Stop sequences are matched against the tail of the generated stream.

Test cases

case 1
in: [[1,2,3],[2,3]]
expected: true
case 2
in: [[1,2,3],[3]]
expected: true
case 3
in: [[1,2,3],[1,2]]
expected: false
case 4
in: [[],[1]]
expected: false
case 5
in: [[1],[1,1]]
expected: false
Starter codePython
def stop_sequence_hit(generated_ids, stop_sequence):
    # Your code here
    pass

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