unsloth icon indicating copy to clipboard operation
unsloth copied to clipboard

FastLanguageModel causes IPython dependency via transformers.utils.notebook

Open mschmill opened this issue 1 year ago • 2 comments

I am trying to follow along with the SFT example in the README (the very first one) and somehow importing FastLanguageModel is causing notebook functionality to be imported via models.dpo and transformers.utils.notebook. This causes an undocumented dependency on IPython which is probably not necessary or desirable.

Version is 2024.2, installed to a conda environment via pip, according to the directions in the README.

  File "/home/mschmill/Koda-API-Contract/src/koda_train/unsloth.py", line 4, in <module>
    from unsloth import FastLanguageModel
  File "/opt/anaconda/anaconda3/envs/smd/lib/python3.10/site-packages/unsloth/__init__.py", line 108, in <module>
    from .models import *
  File "/opt/anaconda/anaconda3/envs/smd/lib/python3.10/site-packages/unsloth/models/__init__.py", line 18, in <module>
    from .dpo import PatchDPOTrainer
  File "/opt/anaconda/anaconda3/envs/smd/lib/python3.10/site-packages/unsloth/models/dpo.py", line 15, in <module>
    from transformers.utils.notebook import (
  File "/opt/anaconda/anaconda3/envs/smd/lib/python3.10/site-packages/transformers/utils/notebook.py", line 20, in <module>
    import IPython.display as disp
ModuleNotFoundError: No module named 'IPython'

mschmill avatar Feb 29 '24 21:02 mschmill

Oh interesting! Thanks so much for the report - will add IPython to pyproject.toml!!

danielhanchen avatar Mar 01 '24 02:03 danielhanchen

I think I fixed this now! I added a try except block :) Thanks for the report :)

danielhanchen avatar Mar 03 '24 16:03 danielhanchen