localGPT icon indicating copy to clipboard operation
localGPT copied to clipboard

Cannot import name 'LlamaTokenizer'

Open armbis opened this issue 2 years ago • 3 comments
trafficstars

Excuse me, I'm a newbie and I'm trying to use LocalGPT but I have this problem. A thousand thanks!

(base) Armando@iMac-di-Martina ~ % python Documents/LocalGPT/run_localGPT.py Traceback (most recent call last): File "/Users/Armando/Documents/LocalGPT/run_localGPT.py", line 7, in from transformers import LlamaTokenizer, LlamaForCausalLM, pipeline ImportError: cannot import name 'LlamaTokenizer' from 'transformers' (/Users/Armando/anaconda3/lib/python3.10/site-packages/transformers/init.py) (base) Armando@iMac-di-Martina ~ %

armbis avatar Jun 02 '23 08:06 armbis

@armbis can you please show your code, it is difficult trying to understand what is happening.

Allaye avatar Jun 02 '23 10:06 Allaye

armbis

Try uninstalling and then installing "transformers": pip uninstall transformers pip install transformers conda update transformers

I was personally able to resolve this error by running localGPT outside of conda. If you are running it inside conda, I believe you need to ensure the pip -r install requirements and transformers are installed on the conda environment.

mindwellsolutions avatar Jun 02 '23 17:06 mindwellsolutions

If you still having problems with from transformers import LlamaForCausalLM, LlamaTokenizer try to install the package directly from github:

pip install git+https://github.com/huggingface/transformers also don't forget to change the Tokenizer config file from LLaMATokenizer to LlamaTokenizer.

source: https://github.com/huggingface/transformers/issues/22222 closes #54

Swag19602 avatar Jun 03 '23 03:06 Swag19602