stanford_alpaca icon indicating copy to clipboard operation
stanford_alpaca copied to clipboard

ImportError when using `weight_diff.py` script

Open SebastianRiquelmeM opened this issue 1 year ago • 2 comments

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)

SebastianRiquelmeM avatar Nov 20 '23 05:11 SebastianRiquelmeM

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.

boyue-jiang avatar Nov 20 '23 17:11 boyue-jiang

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

gaodexiaozheng avatar Nov 22 '23 08:11 gaodexiaozheng