tatsu-lab / stanford_alpaca

Code and documentation to train Stanford's Alpaca models, and generate the data.
https://crfm.stanford.edu/2023/03/13/alpaca.html
Apache License 2.0
29.56k stars 4.06k forks source link

ImportError when using `weight_diff.py` script #303

Open SebastianRiquelmeM opened 12 months ago

SebastianRiquelmeM commented 12 months ago

ImportError when using weight_diff.py script.

Problem Description:

I encountered an ImportError when attempting to execute the weight_diff.py script from the Stanford Alpaca project for applying a weight differential. The command used and the traceback of the error are as follows:

Operating System: Windows 11 Python Version: 3.10

Command:


python .\stanford_alpaca\weight_diff.py recover --path_raw ".\output_hf_7B" --path_diff ".\alpaca-7b-wdiff" --path_tuned ".\alpaca7b_recovered" --device "cuda"

Error:

Traceback (most recent call last):
  File "[project path]\stanford_alpaca\weight_diff.py", line 21, in <module>
    from train import smart_tokenizer_and_embedding_resize
  File "[project path]\stanford_alpaca\train.py", line 22, in <module>
    import utils
  File "[project path]\stanford_alpaca\utils.py", line 13, in <module>
    from openai import openai_object
ImportError: cannot import name 'openai_object' from 'openai' ([Python environment path]\lib\site-packages\openai\__init__.py)
boyue-jiang commented 12 months ago

I encountered the same problem and I guess cuz openai upadte their module. If you only want to recover the weight, you can just delete the code in utils.py that relates to openai.

gaodexiaozheng commented 12 months ago

I met the same problem, I resolved this by using openai==0.28.0, just like this:pip install openai==0.28.0