Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-084

Token Type IDs

Problem

Build BERT token type ids for the packed pair [CLS] A [SEP] B [SEP].

Return len_a + 2 zeros followed by len_b + 1 ones.

Hint

The first [CLS] and [SEP] belong to segment 0; the second [SEP] closes segment 1.

Test cases

case 1
in: [3,2]
expected: [0,0,0,0,0,1,1,1]
case 2
in: [1,1]
expected: [0,0,0,1,1]
case 3
in: [0,0]
expected: [0,0,1]
case 4
in: [2,0]
expected: [0,0,0,0,1]
Starter codePython
def token_type_ids(len_a, len_b):
    # Your code here
    pass

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