ohmeow / blurr

A library that integrates huggingface transformers with the world of fastai, giving fastai devs everything they need to train, evaluate, and deploy transformer specific models.
https://ohmeow.github.io/blurr
Apache License 2.0
289 stars 34 forks source link

Value Error when importing blurr.modeling.all and blurr.data.all #21

Closed JeremyOBrien16 closed 2 years ago

JeremyOBrien16 commented 3 years ago

After pip install in Colab, import blurr.modeling.all and blurr.data.all are throwing errors. Did not encounter errors last week, not sure when they began. Has there been a syntax change for setup?


ValueError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/pandas/core/indexes/range.py in get_loc(self, key, method, tolerance) 354 try: --> 355 return self._range.index(new_key) 356 except ValueError as err:

ValueError: 1 is not in range

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last) 6 frames

in () ----> 1 from blurr.modeling.all import * /usr/local/lib/python3.6/dist-packages/blurr/modeling/all.py in () ----> 1 from ..utils import * 2 from .core import * 3 from .question_answering import * 4 from .token_classification import * 5 from .text2text.core import * /usr/local/lib/python3.6/dist-packages/blurr/utils.py in () 182 183 # Cell --> 184 BLURR_MODEL_HELPER = ModelHelper() 185 186 # Cell /usr/local/lib/python3.6/dist-packages/blurr/utils.py in __call__(self, *args, **kwargs) 25 26 def __call__(self, *args, **kwargs): ---> 27 if self._instance == None: self._instance = self._cls(*args, **kwargs) 28 return self._instance 29 /usr/local/lib/python3.6/dist-packages/blurr/utils.py in __init__(self) 59 model_type_df = self._df[(self._df.functional_area == 'modeling')].class_name.str.split('For', n=1, expand=True) 60 ---> 61 model_type_df[1] = np.where(model_type_df[1].notnull(), 62 'For' + model_type_df[1].astype(str), 63 model_type_df[1]) /usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in __getitem__(self, key) 2904 if self.columns.nlevels > 1: 2905 return self._getitem_multilevel(key) -> 2906 indexer = self.columns.get_loc(key) 2907 if is_integer(indexer): 2908 indexer = [indexer] /usr/local/lib/python3.6/dist-packages/pandas/core/indexes/range.py in get_loc(self, key, method, tolerance) 355 return self._range.index(new_key) 356 except ValueError as err: --> 357 raise KeyError(key) from err 358 raise KeyError(key) 359 return super().get_loc(key, method=method, tolerance=tolerance) KeyError: 1
LR-Silva commented 3 years ago

Same error here. It was working fine last week and now I cannot import.

ohmeow commented 3 years ago

I'll take a look ... either something in fastai or huggingface has changed. What versions of each are you both working with?

LR-Silva commented 3 years ago

I tried both the default version from pypi (0.0.18) or installing from source (0.0.19) with pip install -e ".[dev]". I got the same error when using on Colab and on my personal machine with both versions.

JeremyOBrien16 commented 3 years ago

Thanks for the quick response!

fastai 1.0.61 transformers 4.0.0

JeremyOBrien16 commented 3 years ago

Looks like huggingface pushed a transformers update a week ago: https://github.com/huggingface/transformers/releases

JeremyOBrien16 commented 3 years ago

Rolled back to transformer==3.5.1 and install / imports working fine.

ohmeow commented 3 years ago

Thanks for the info.

Btw, fastai needs to be >= 2.15 as well. I'll find some time to fix things to work against the latest this week.

wg

On Mon, Dec 7, 2020 at 6:29 PM JeremyOBrien16 notifications@github.com wrote:

Rolled back to transformer==3.5.1 and install / imports working fine.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ohmeow/blurr/issues/21#issuecomment-740319598, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAADNMEXAK5YXEEJ5VMXNJ3STWFPNANCNFSM4UPP5H6A .

LR-Silva commented 3 years ago

It worked here for me. Thanks 👍

tyoc213 commented 3 years ago

It worked here for me. Thanks +1

How?

For me is still failing?... well, installed from pip

python        : 3.8.5
fastai        : 2.1.8
fastprogress  : 0.2.7
torch         : 1.7.0
transformers  : 3.5.1

Oh yeah, it works with


Thx
pip install transformers==3.5.1 
pip install ohmeow-blurr==0.0.18
HenryDashwood commented 3 years ago

It's actually quite an easy fix I think. Huggingface have just buried their model files in a couple of extra layers of directories since the src folder was getting quite big. So in ModelHelper's __init__() you need to split self._df.module_part_3 instead of self._df.module_part_1. I got it to work on my fork here: https://github.com/HenryDashwood/blurr/commit/dececd4e706129694b25ee80c15dfb61ffadf9a9#diff-45d6eb3657aeaa14c3dacc16d9278dda8d6aa21c61456f9a03d80e34d368eeec

Unfortunately there are a few more version 4 breaking changes which come up when I try to test the notebooks. I might have some time to take a crack at them this week if it would be helpful?

ohmeow commented 3 years ago

Done.

The latest fast.ai and transformers libs actually broke a few things ... but all is working now; all tests are passing.

Closing this out ... lmk if anything is still broken for you all.

bappctl commented 2 years ago

[Works fine with] python: 3.7.13 pytorch: 1.7.1+cu110 fastai: 2.2.5 transformers: 4.3.3 ohmeow-blurr==0.0.24

and to use BLURR_MODEL_HELPER. instead of BLURR.

ohmeow commented 2 years ago

@bappctl : try installing the latest version of blurr ... pip install ohmeow-blurr==1.0.2

There were some of the old imports being cached in there that nbdev didn't clear out when I made the initial release. That's been fixed and the namespaces have changed. All the NLP/Text bits will be under blurr.text.

Feel free to close this out once things are working (or lmk if you are still having issues).

waisyousofi commented 2 years ago

You are right ,

ohmeow-blurr==0.0.24 and BLURR_MODEL_HELPER instead of BLURR

worked for me.

thanks✌️

ohmeow commented 2 years ago

Closing this out as v.1 is out and the code above is obsolete.