Instructions to use google/gemma-2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-2b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="google/gemma-2b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b") model = AutoModelForCausalLM.from_pretrained("google/gemma-2b") - llama-cpp-python
How to use google/gemma-2b with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="google/gemma-2b", filename="gemma-2b.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use google/gemma-2b with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf google/gemma-2b # Run inference directly in the terminal: llama-cli -hf google/gemma-2b
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf google/gemma-2b # Run inference directly in the terminal: llama-cli -hf google/gemma-2b
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf google/gemma-2b # Run inference directly in the terminal: ./llama-cli -hf google/gemma-2b
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf google/gemma-2b # Run inference directly in the terminal: ./build/bin/llama-cli -hf google/gemma-2b
Use Docker
docker model run hf.co/google/gemma-2b
- LM Studio
- Jan
- vLLM
How to use google/gemma-2b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/gemma-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-2b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/google/gemma-2b
- SGLang
How to use google/gemma-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-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-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-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-2b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use google/gemma-2b with Ollama:
ollama run hf.co/google/gemma-2b
- Unsloth Studio new
How to use google/gemma-2b with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for google/gemma-2b to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for google/gemma-2b to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for google/gemma-2b to start chatting
- Docker Model Runner
How to use google/gemma-2b with Docker Model Runner:
docker model run hf.co/google/gemma-2b
- Lemonade
How to use google/gemma-2b with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull google/gemma-2b
Run and chat with the model
lemonade run user.gemma-2b-{{QUANT_TAG}}List all available models
lemonade list
Update README.md
#91 opened 23 days ago
by
ceoavinash
Get Access
#90 opened 6 months ago
by
AurasZ
Request: Get Access
1
#89 opened 6 months ago
by
AurasZ
provide me acess of this directory to use this model
#88 opened 7 months ago
by
Aman5678
Request: request for access
4
#87 opened 9 months ago
by
Deepak4667
https://huggingface.co/k0vv/kov
#85 opened 10 months ago
by
k0vv
Request: DOI
1
#84 opened 10 months ago
by
Turning123
Request: DOI
1
#83 opened 11 months ago
by
Arefin994
Update config.json
1
#82 opened 11 months ago
by
ArchaveCommunity
Used gemma-2b in my Pre Proposal work for Google Summer Of Code 2025
1
#81 opened about 1 year ago
by
Kakaarot
Problems with running on CPU
3
#79 opened over 1 year ago
by
IExist999
Gated Repos Permission
2
#78 opened over 1 year ago
by
aymenmir
google/gemma-2b-kamba-instruct
#77 opened over 1 year ago
by
Qybera
Update README.md
#75 opened over 1 year ago
by
LCG123
Request: DOI
1
#74 opened over 1 year ago
by
Jonasbukhave
Interview request: genAI evaluation & documentation
1
#73 opened over 1 year ago
by
meggymuggy
Supported Languages
1
#72 opened over 1 year ago
by
vpkprasanna
Upload config (3).json
#70 opened over 1 year ago
by
Malekhmem
Randomness of the output of the trained model
1
#68 opened almost 2 years ago
by
Sam1989
Can't reproduce hellaswag result - getting 42.3% v.s. 71.4 % reported
1
#67 opened almost 2 years ago
by
robgarct
Any one who use the script in the Model Card for inference purpose?
3
#64 opened almost 2 years ago
by
disper84
403 Forbidden: Authorization error
6
#62 opened almost 2 years ago
by
parkerbotta
Memory requirements to load the model
1
#61 opened almost 2 years ago
by
nroshania
Following blog for fine tuning gemma-2b doesn't yield same results
12
#60 opened almost 2 years ago
by
chongdashu
[AUTOMATED] Model Memory Requirements
#59 opened about 2 years ago
by
model-sizer-bot
[AUTOMATED] Model Memory Requirements
#58 opened about 2 years ago
by
model-sizer-bot
[AUTOMATED] Model Memory Requirements
#57 opened about 2 years ago
by
model-sizer-bot
[AUTOMATED] Model Memory Requirements
#56 opened about 2 years ago
by
model-sizer-bot
[AUTOMATED] Model Memory Requirements
#55 opened about 2 years ago
by
model-sizer-bot
Running finetuned inference on CPU - accelerate ImportError
1
#54 opened about 2 years ago
by
saikrishna6491
Unable to reproduce the score of gemma_2b at pass@1 in humaneval.
3
#53 opened about 2 years ago
by
ChiYuqi
Feature extraction suitability?
1
#52 opened about 2 years ago
by
ivoras
Update README.md
#51 opened about 2 years ago
by
raj729
gemma 2b inference Endpoints error
4
#46 opened about 2 years ago
by
gawon16
gemma -2b with multi-gpu
3
#44 opened about 2 years ago
by
Iamexperimenting
pretraining Gemma for domain dataset
➕ 1
8
#41 opened about 2 years ago
by
Iamexperimenting
[AUTOMATED] Model Memory Requirements
#40 opened about 2 years ago
by
model-sizer-bot
Gemma tokenizer issue
1
#37 opened about 2 years ago
by
Akshayextreme
Question about their name.. why it is 2b???
2
#36 opened about 2 years ago
by
sh0416
[AUTOMATED] Model Memory Requirements
#35 opened about 2 years ago
by
model-sizer-bot
[AUTOMATED] Model Memory Requirements
#34 opened about 2 years ago
by
model-sizer-bot
What is the context size for Gemma? I get error when asking for it in the config file e.g., AttributeError("'GemmaConfig' object has no attribute 'context_length'")
3
#32 opened about 2 years ago
by
brando
torch import required in examples
#31 opened about 2 years ago
by
shamikbose89
ImportError: Using `bitsandbytes` 8-bit quantization requires Accelerate: `pip install accelerate` and the latest version of bitsandbytes
15
#29 opened about 2 years ago
by
WQW
torch.cuda.OutOfMemoryError
7
#26 opened about 2 years ago
by
shiwanglai
GPU utlisation high on Gemma-2b-it
1
#24 opened about 2 years ago
by
sharad07
Sentiment analysis
2
#23 opened about 2 years ago
by
PTsag