Instructions to use google/gemma-2-2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-2-2b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="google/gemma-2-2b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b") model = AutoModelForCausalLM.from_pretrained("google/gemma-2-2b") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use google/gemma-2-2b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/gemma-2-2b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/gemma-2-2b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/google/gemma-2-2b
- SGLang
How to use google/gemma-2-2b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "google/gemma-2-2b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/gemma-2-2b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "google/gemma-2-2b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/gemma-2-2b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use google/gemma-2-2b with Docker Model Runner:
docker model run hf.co/google/gemma-2-2b
Approval Process Duration
Hi! I need to access the model weights for some experiments, am wondering how long the approval process is meant to take? Applied yesterday but still pending.
Thanks!
Hi @danbigioi ,
Approval for any model on HuggingFace typically takes less than an hour. It’s possible that you may have followed an incorrect process. Please refer to the process outlined in this link.
To access the model weights, go to the Files and Versions section of the specific model and download the weights from there.
If the issue still persists, please provide additional details, such as screenshots, so we can assist you more effectively in resolving it.
Thank you.
Hi @GopiUppari
Just attaching screenshots with my issue. I accepted the license terms, and its been like that since:
Hi @GopiUppari
Just attaching screenshots with my issue. I accepted the license terms, and its been like that since:
Same situation, I applied in October.
@aymenmir @Arlse @jcarlson and anyone else struggling to get access, I found a workaround. If you go on the kaggle page for gemma, and request access through huggingface for the model weights there, you get approved immediately here.
https://www.kaggle.com/models/google/gemma?postConsentAction=download
Yeah, worked for me as well
This works, thank you!
How about the huggingface issue? It's the same as above for me.
How about the huggingface issue? It's the same as above for me.
Select 'Verify via Hugging Face' during verification.
Follow the link provided below and complete the steps to gain access to the “Google Gemma models on HuggingFace”.
https://www.kaggle.com/models/google/gemma-2/license/consent
Click on “Verify via Hugging Face” and also click “continue with Hugging Face”.
By following above step then will get as
Click on "Authorize," which will redirect you to the Kaggle Gemma Consent Form page. Fill out the required fields, accept the terms, and you will receive access to the Google Gemma models on HuggingFace in less than a minute.
Thank you.
Hi @GopiUppari
On December 14 I accepted the model card on Kaggle. I did not yet have a HF account at that time so I accepted it directly there.
Then, around Dec 27 I created a HF account because I wanted to access the code and configs too. I applied for access and it's still pending:
The workaround from above does not work for me since I can't re-consent to the model's card on Kaggle. How can I get access to gemma 2 gated repo on HF?
Hi @incognito124 ,
We have resolved the issue. You can click "Acknowledge License" on the model page. If you continue to face any issues, please let me know.
Thank you.
@aymenmir @Arlse @jcarlson and anyone else struggling to get access, I found a workaround. If you go on the kaggle page for gemma, and request access through huggingface for the model weights there, you get approved immediately here.
https://www.kaggle.com/models/google/gemma?postConsentAction=download
Worked!! thank you.








