AttributeError:模块“transformers.modeling_bert”没有属性“gelu”

2024-05-14 04:54:40 发布

您现在位置:Python中文网/ 问答频道 /正文

import pandas as pd
from ast import literal_eval

from cdqa.utils.filters import filter_paragraphs
from cdqa.utils.download import download_model, download_bnpp_data
from cdqa.pipeline.cdqa_sklearn import QAPipeline

# Download data and models
download_bnpp_data(dir='./data/bnpp_newsroom_v1.1/')
download_model(model='bert-squad_1.1', dir='./models')

# Loading data and filtering / preprocessing the documents
df = pd.read_csv('data/bnpp_newsroom_v1.1/bnpp_newsroom-v1.1.csv', converters={'paragraphs': literal_eval})
df = filter_paragraphs(df)

# Loading QAPipeline with CPU version of BERT Reader pretrained on SQuAD 1.1
cdqa_pipeline = QAPipeline(reader='C:/models/bert_qa.joblib')

# Fitting the retriever to the list of documents in the dataframe
cdqa_pipeline.fit_retriever(X=df)


我试图加载模型,但cdqa_pipeline=qappeline(reader='C:/models/bert_qa.joblib')行抛出一个错误,称AttributeError:module'transformers.modeling_bert'没有属性'gelu'

我用的是变形金刚3.5版


Tags: thefromimportdfdatamodelpipelinemodels