Instructions to use google/gemma-2b-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/gemma-2b-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="google/gemma-2b-it") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b-it") model = AutoModelForCausalLM.from_pretrained("google/gemma-2b-it") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - llama-cpp-python
How to use google/gemma-2b-it with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="google/gemma-2b-it", filename="gemma-2b-it.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use google/gemma-2b-it 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-it # Run inference directly in the terminal: llama-cli -hf google/gemma-2b-it
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf google/gemma-2b-it # Run inference directly in the terminal: llama-cli -hf google/gemma-2b-it
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-it # Run inference directly in the terminal: ./llama-cli -hf google/gemma-2b-it
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-it # Run inference directly in the terminal: ./build/bin/llama-cli -hf google/gemma-2b-it
Use Docker
docker model run hf.co/google/gemma-2b-it
- LM Studio
- Jan
- vLLM
How to use google/gemma-2b-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/gemma-2b-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/gemma-2b-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/google/gemma-2b-it
- SGLang
How to use google/gemma-2b-it 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-it" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/gemma-2b-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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-it" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/gemma-2b-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use google/gemma-2b-it with Ollama:
ollama run hf.co/google/gemma-2b-it
- Unsloth Studio new
How to use google/gemma-2b-it 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-it 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-it 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-it to start chatting
- Docker Model Runner
How to use google/gemma-2b-it with Docker Model Runner:
docker model run hf.co/google/gemma-2b-it
- Lemonade
How to use google/gemma-2b-it with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull google/gemma-2b-it
Run and chat with the model
lemonade run user.gemma-2b-it-{{QUANT_TAG}}List all available models
lemonade list
Request: DOI
1
#75 opened 12 days ago
by
mazenhan343
Request: DOI
1
#74 opened about 1 month ago
by
ashishpatelk
Distributing this on an app? Licence?
#72 opened 6 months ago
by
HeyGoodEnough
Request: DOI
1
#71 opened 7 months ago
by
majivncio
MarCognity-AI for Google – Gemma 2B
2
#70 opened 8 months ago
by
elly99
Request: DOI
1
#69 opened 8 months ago
by
Tanh1116
Request: DOI
1
#67 opened 8 months ago
by
yigitakdas7
Patiently waiting 5 days
2
#66 opened 9 months ago
by
Josecajina
Request: DOI
1
#65 opened 9 months ago
by
Tarunsai6503
Request access to Gemma-2B for medical research
3
#64 opened 10 months ago
by
DinoFortunato
Request: DOI
👀 1
1
#63 opened 10 months ago
by
hgez4613
Request: DOI
1
#62 opened 10 months ago
by
waleedshah0
Request: DOI
1
#61 opened 11 months ago
by
hollow27mc
REQUEST DOI
1
#59 opened about 1 year ago
by
Natwar
Request: DOI
1
#58 opened about 1 year ago
by
mamatmusayev
Unable to get model access
🔥 1
4
#56 opened over 1 year ago
by
Khyatikhandelwal20
Extract only output
3
#55 opened over 1 year ago
by
tkaintura
Requesting access to model, the terms and conditions mentions access to reading emails
3
#54 opened over 1 year ago
by
vkSJSU
Update License
#52 opened over 1 year ago
by
hschaeufler
Request: access to gated repo
1
#51 opened almost 2 years ago
by
iamamofa
Generating multiple responses from the same prompt
2
#50 opened almost 2 years ago
by
OfriH
Inference API Parameters
3
#47 opened almost 2 years ago
by
Shivkumar27
Update README.md
#46 opened almost 2 years ago
by
Deepjyoti120
Issue with loading 4-bit quantized model on Apple M1 pro
4
#45 opened about 2 years ago
by
waxsum8
What do they mean by maj@1 ?
3
#44 opened about 2 years ago
by
joserass
Gemma Inference Scale
1
#42 opened about 2 years ago
by
metalfusion10
Fine tuning for NER Tasks
2
#41 opened about 2 years ago
by
NavS2023
Update config.json
1
#39 opened about 2 years ago
by
risaxD19
[AUTOMATED] Model Memory Requirements
1
#38 opened about 2 years ago
by
model-sizer-bot
Additional Tokens
#33 opened about 2 years ago
by
pcuenq
RuntimeError: cutlassF: no kernel found to launch!
2
#32 opened about 2 years ago
by
kehkok
Pretraining Time Cost?
1
#30 opened about 2 years ago
by
fov223
Transformer Pipeline
🔥 1
8
#26 opened about 2 years ago
by
francescoyoubiquo
Running on Google Pixel TPU?
12
#16 opened over 2 years ago
by
soupslurpr
THE most unhelpful, heavily censored & biased model I ever experienced
11
#15 opened over 2 years ago
by
Horned