unslothai / unsloth

Finetune Llama 3, Mistral, Phi & Gemma LLMs 2-5x faster with 80% less memory
https://unsloth.ai
Apache License 2.0
12.75k stars 832 forks source link

FastLanguageModel causes IPython dependency via transformers.utils.notebook #209

Open mschmill opened 4 months ago

mschmill commented 4 months ago

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'
danielhanchen commented 4 months ago

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

danielhanchen commented 4 months ago

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