segment-any-text / wtpsplit

Toolkit to segment text into sentences or other semantic units in a robust, efficient and adaptable way.
MIT License
753 stars 44 forks source link

Error loading model to GPU #95

Closed damin604 closed 1 year ago

damin604 commented 1 year ago

Version: 1.2.0

from wtpsplit import WtP

wtp = WtP("wtp-canine-s-12l-no-adapters")
wtp.to("cuda")

throws,

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
test.ipynb Cell 6 in 4
      [1] from wtpsplit import WtP
      [3] wtp = WtP("wtp-canine-s-12l-no-adapters")
----> [4] wtp.to("cuda")

File (site-packages/wtpsplit/__init__.py:115), in WtP.__getattr__(self, name)
    114 def __getattr__(self, name):
--> 115     return getattr(self.model, name)

AttributeError: 'PyTorchWrapper' object has no attribute 'to'

The issue is due to the nested wtp.model.model not being handled by the __getattr__ method. Calling wtp.model.model.to("cuda") works.

bminixhofer commented 1 year ago

Thanks for the issue, was a regression from 1.2.0. It's fixed in 1.2.1!