ImportError: cannot import name 'Gemma3ForConditionalGeneration' from 'transformers' (/usr/local/lib/python3.10/site-packages/transformers/__init__.py)
I'm trying to use the gemma-3-12b-it model on a Hugging Face ZeroGPU Space but running into this error:
ImportError: cannot import name 'Gemma3ForConditionalGeneration' from 'transformers' (/usr/local/lib/python3.10/site-packages/transformers/init.py)
I have 'transformers==4.49.0' in my requirements.txt.
If anyone knows how to solve this error, would be a great help thanks.
I think 4.49.0 doesn't do it. There's a "special release" of 4.49.0 that also covers Gemma3 related changes:
run the following command:
pip install git+https://github.com/huggingface/[email protected]
Or add this to the requirements.txt:
transformers @ git+https://github.com/huggingface/transformers@46350f5eae87ac1d168ddfdc57a0b39b64b9a029
Hi @aryan835-datainflexion , To use Gemma-3 models, you need the latest development version of the Transformers library (4.50.0.dev0). You can install it directly from the GitHub branch using: pip install git+https://github.com/huggingface/[email protected] as mentioned [here]9https://huggingface.co/google/shieldgemma-2-4b-it#usage). Kindly try and let me know if you have any concerns.
Thank you.