Combine BertForSequenceClassificaion with Additional Features

Correction: my response above is useful in case one wants to add additional text features to the tokens.

However, if you want to combine text features with other features (like categorical or numerical ones) - which was actually the question above (apologies) - it makes sense to concatenate the final hidden state of the [CLS] token (which serves as a good representation of an entire piece of text) with the additional features. This is illustrated in this notebook.

3 Likes