Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-083

BERT CLS Pooling

Problem

Return a copy of the first hidden-state vector, which plays the role of the [CLS] representation.

Return an empty list for empty hidden states.

Hint

The [CLS] token always sits at position 0 of the sequence.

Test cases

case 1
in: [[[1,2],[3,4]]]
expected: [1,2]
case 2
in: [[[0.5]]]
expected: [0.5]
case 3
in: [[]]
expected: []
case 4
in: [[[1,-1]]]
expected: [1,-1]
Starter codePython
def cls_pooling(hidden_states):
    # Your code here
    pass

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