Python BERT transformer不适用于我的NLP任务-错误消息未被理解

Python BERT transformer不适用于我的NLP任务-错误消息未被理解,python,nlp,Python,Nlp,我正试图使用一个伯特模型来执行我自己的句子分类 在熊猫数据框中选择预处理和标记的英文文本。我是博士 但是我的计算知识并没有超出基本的Python3,因此我 斗争,因为我将失去一些实际发生的微妙之处。我从来没有 以前在这样一个论坛上发布过,所以我为下面的任何违规行为道歉! 这是产生问题的COLAB单元 BERT_MODEL_HUB = model from fast_bert.learner_cls import BertLearner from fast_bert.metrics import

我正试图使用一个伯特模型来执行我自己的句子分类 在熊猫数据框中选择预处理和标记的英文文本。我是博士 但是我的计算知识并没有超出基本的Python3,因此我 斗争,因为我将失去一些实际发生的微妙之处。我从来没有 以前在这样一个论坛上发布过,所以我为下面的任何违规行为道歉! 这是产生问题的COLAB单元

BERT_MODEL_HUB = model
from fast_bert.learner_cls import BertLearner
from fast_bert.metrics import accuracy
import logging
logger = logging.getLogger()
device_cuda = torch.device("cuda")
metrics = [{'name': 'accuracy', 'function': accuracy}]
learner = BertLearner.from_pretrained_model(
 databunch,
 pretrained_path=BERT_MODEL_HUB,
 metrics=metrics,
 device=device_cuda,
 logger=logger,
 output_dir='/content/sample_data',
 finetuned_wgts_path=None,
 warmup_steps=500,
 multi_gpu=True,
 is_fp16=True,
 multi_label=False,
 logging_steps=50)
这是我尝试使用的伯特模型

from transformers import BertTokenizer, TFBertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
model = TFBertModel.from_pretrained("bert-base-cased")
我用的是FastBert

from fast_bert.data_cls import BertDataBunch
data_path = '/content/sample_data' # needs to be a directory?
label_path = '/content/drive/MyDrive/LABEL_DIR'
train_file = '/content/Dickens_Carroll_train.csv'
valid_file = '/content/Dickens_Carroll_valid.csv'
databunch = BertDataBunch(data_path, label_path,
 tokenizer=tokenizer,
train_file=train_file,
val_file=valid_file,
label_file='/content/drive/MyDrive/l
abels.csv',
 text_col='text',
 label_col='Source_Label',
batch_size_per_gpu=16,
max_seq_length=512,
multi_gpu=True,
multi_label=False,
model_type='bert')
这是我收到的错误消息

OSError Traceback (most recent call
last)
/usr/local/lib/python3.6/distpackages/transformers/configuration_utils.py in get_config_dict(cls,
pretrained_model_name_or_path, **kwargs)
 241 if resolved_config_file is None:
--> 242 raise EnvironmentError
 243 config_dict =
cls._dict_from_json_file(resolved_config_file)
OSError:
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call
last)
4 frames
/usr/local/lib/python3.6/distpackages/transformers/configuration_utils.py in get_config_dict(cls,
pretrained_model_name_or_path, **kwargs)
 249 f"- or '{pretrained_model_name_or_path}' is
the correct path to a directory containing a {CONFIG_NAME} file\n\n"
 250 )
--> 251 raise EnvironmentError(msg)
 252
 253 except json.JSONDecodeError:
OSError: Can't load config for
'<transformers.modeling_tf_bert.TFBertModel object at
0x7f04b8310668>'. Make sure that:
- '<transformers.modeling_tf_bert.TFBertModel object at
0x7f04b8310668>' is a correct model identifier listed on
'https://huggingface.co/models'
- or '<transformers.modeling_tf_bert.TFBertModel object at
0x7f04b8310668>' is the correct path to a directory containing a
config.json file
!pip install -q pyopenssl