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

SetFit fails with Numpy >2.0.0 #72

Open
chschroeder opened this issue Dec 11, 2024 · 0 comments
Open

SetFit fails with Numpy >2.0.0 #72

chschroeder opened this issue Dec 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@chschroeder
Copy link
Contributor

Bug description

The setfit multiclass example (examples/examplecode/setfit_multiclass_classification) fails on an installation with recent dependencies:

Traceback (most recent call last):
  File "/home/cschroeder/.pyenv/versions/3.9.18/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/cschroeder/.pyenv/versions/3.9.18/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/cschroeder/workspaces/small-text/examples/examplecode/setfit_multiclass_classification.py", line 106, in <module>
    main(num_iterations=args.num_iterations)
  File "/home/cschroeder/workspaces/small-text/examples/examplecode/setfit_multiclass_classification.py", line 51, in main
    indices_labeled = initialize_active_learner(active_learner, train.y)
  File "/home/cschroeder/workspaces/small-text/examples/examplecode/setfit_multiclass_classification.py", line 84, in initialize_active_learner
    active_learner.initialize(indices_initial)
  File "/home/cschroeder/.pyenv/versions/small-text-3.9/lib/python3.9/site-packages/small_text/active_learner.py", line 154, in initialize
    self._retrain(indices_validation=indices_validation)
  File "/home/cschroeder/.pyenv/versions/small-text-3.9/lib/python3.9/site-packages/small_text/active_learner.py", line 404, in _retrain
    self._clf.fit(dataset, **self.fit_kwargs)
  File "/home/cschroeder/.pyenv/versions/small-text-3.9/lib/python3.9/site-packages/small_text/integrations/transformers/classifiers/setfit.py", line 246, in fit
    return self._fit(sub_train, sub_valid, setfit_train_kwargs)
  File "/home/cschroeder/.pyenv/versions/small-text-3.9/lib/python3.9/site-packages/small_text/integrations/transformers/classifiers/setfit.py", line 261, in _fit
    seed = np.random.randint(np.iinfo(int_dtype()).max)
  File "numpy/random/mtrand.pyx", line 798, in numpy.random.mtrand.RandomState.randint
  File "numpy/random/_bounded_integers.pyx", line 1332, in numpy.random._bounded_integers._rand_int64
ValueError: high is out of bounds for int64

Downgrading numpy solves this.

Environment:

Python version: 3.9
small-text version: 2.0.0.dev1
small-text integrations (e.g., transformers):
PyTorch version (if applicable): 2.5.1
numpy: >2.0.0

@chschroeder chschroeder added the bug Something isn't working label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant