我想用 BERT 隐藏状态的分类算法进行分析

I want to analysis with classification algoritms using BERT's hidden state

我正在使用 Huggingface Transformer package and BERT with PyTorch.
I try to do text classification with CamembertForSequenceClassification。 我可以得到结果,但我想挑战更难的任务。
我指的是这个literature。在本文档的第 4.1 节中,指出

After training, we drop the softmax activation layer and use BERT's hidden state as the feature vector, which we then use as input for different classification algorithms.

所以,我检查 modeling_bert.py。有
attention_probs = nn.Softmax(dim=-1)(attention_scores)
如果我按照论文看,是不是要用attention_scores才pass它通过 Softmax 函数?如果是这样,我如何使用attention_scores并将其应用于分类算法?

简而言之,我想做的是使用 BERT 的隐藏状态并将其应用于逻辑回归等。

感谢您的帮助。

他们不是说那个Softmax层,因为那个在BertAttention里面。他们指的是 BERT 之上的池化层。

我在论文中找到了他们的存储库:https://github.com/axenov/politik-news

似乎他们在训练时使用的是普通的 BertForSequenceClassification。 (使用 hidden_states -> pooler 激活 -> 线性分类器 -> loss)

当他们预测时,他们只使用 hidden_states(或者在 bert_modeling.py 中它被称为 sequence_output),然后他们将它传递给在 BiasPredictor.py:L26 中加载的不同分类器.

因此,如果您想尝试不同的分类器,请使用它 here