cdqa-suite / cdQA

⛔ [NOT MAINTAINED] An End-To-End Closed Domain Question Answering System.
https://cdqa-suite.github.io/cdQA-website/
Apache License 2.0
616 stars 191 forks source link

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

Open Gopichand995 opened 1 year ago

Gopichand995 commented 1 year ago

Traceback (most recent call last): File "C:\Users\04647U744\Documents\Github\CASH_sfaidebtreducerWSP\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 commented 1 year ago

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]))