我们可以计算 Huggingface Bert 中的特征重要性吗?

Can we calculate feature importance in Huggingface Bert?

We can fit a LinearRegression model on the regression dataset and retrieve the coeff_ property that contains the coefficients found for each input variable. These coefficients can provide the basis for a crude feature importance score. This assumes that the input variables have the same scale or have been scaled prior to fitting a model.

伯特呢?我们可以从模型中获取 coef_ 变量并使用它来计算特征重要性,就像文本分类任务中的 LinearRegression 模型一样吗?

Captum 是用于解释转换器的重要工具(来自 pytorch/Facebook),您可以获得模型对特定层的特定标记的关注程度的分数。在此处查看教程:https://captum.ai/tutorials/Bert_SQUAD_Interpret or here https://github.com/pytorch/captum