Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'transformers.modeling_bert' #371

Open
Gopichand995 opened this issue Jan 28, 2023 · 1 comment
Open

Comments

@Gopichand995
Copy link

Traceback (most recent call last):
File "C:\Users\04647U744\Documents\Github\CASH_sfaidebtreducer_WSP\model\cdqa_.py", line 18, in
cdqa_pipeline = QAPipeline(reader=r'C:\Users\04647U744\Desktop\exp\bert_qa.joblib')
File "C:\Users\04647U744\Documents\Github\CASH_sfaidebtreducer_WSP\cdqa\pipeline\cdqa_sklearn.py", line 82, in init
self.reader = joblib.load(reader)
File "C:\Users\04647U744\Anaconda3\lib\site-packages\joblib\numpy_pickle.py", line 587, in load
obj = _unpickle(fobj, filename, mmap_mode)
File "C:\Users\04647U744\Anaconda3\lib\site-packages\joblib\numpy_pickle.py", line 506, in _unpickle
obj = unpickler.load()
File "C:\Users\04647U744\Anaconda3\lib\pickle.py", line 1212, in load
dispatchkey[0]
File "C:\Users\04647U744\Anaconda3\lib\pickle.py", line 1528, in load_global
klass = self.find_class(module, name)
File "C:\Users\04647U744\Anaconda3\lib\pickle.py", line 1579, in find_class
import(module, level=0)
ModuleNotFoundError: No module named 'transformers.modeling_bert'

@Gopichand995
Copy link
Author

I am currently using "transformers" with a version of 4.26.0...i would like to know how to rectify the following module issue...here is the code

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=r'C:\Users\04647U744\Desktop\exp')
download_model(model='bert-squad_1.1', dir=r'C:\Users\04647U744\Desktop\exp')

Loading data and filtering / preprocessing the documents

df = pd.read_csv(r'C:\Users\04647U744\Documents\Github\CASH_sfaidebtreducer_WSP\data\paragraphs.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=r'C:\Users\04647U744\Desktop\exp\bert_qa.joblib')

Fitting the retriever to the list of documents in the dataframe

cdqa_pipeline.fit_retriever(df)

Sending a question to the pipeline and getting prediction

query = 'what is round robin assignment rule?'
prediction = cdqa_pipeline.predict(query)

print('query: {}\n'.format(query))
print('answer: {}\n'.format(prediction[0]))
print('title: {}\n'.format(prediction[1]))
print('paragraph: {}\n'.format(prediction[2]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant