Instructions to use kerasformers/gemma-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use kerasformers/gemma-7b with KerasFormers:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use kerasformers/gemma-7b with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://kerasformers/gemma-7b") - Notebooks
- Google Colab
- Kaggle
See our collection for all versions of Gemma.
Run Gemma with Keras 3: JAX, PyTorch, or TensorFlow
kerasformers/gemma-7b
Paper: Gemma: Open Models Based on Gemini Research and Technology (arXiv:2403.08295) · HF Papers
Gemma is Google's open decoder-only LLM family (RMSNorm, GeGLU, RoPE, multi-query attention). Base checkpoints are for completion; -it / 1.1 variants are instruction-tuned for chat.
For more details on the model, please go to Google's original model card.
Pure-Keras 3 conversion of google/gemma-7b for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX.
This is a base (pretrained) checkpoint: prompt it with raw text completion, or prefer an -it variant for chat.
✨ Quick start
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from kerasformers.models.gemma import GemmaGenerate, GemmaTokenizer
model = GemmaGenerate.from_weights("kerasformers/gemma-7b")
tokenizer = GemmaTokenizer.from_weights("kerasformers/gemma-7b")
inputs = tokenizer("The capital of France is")
outputs = model.generate(**inputs, max_new_tokens=32)
print(tokenizer.decode(outputs[0]))
Load any Gemma v1 variant the same way with from_weights("kerasformers/<variant>"):
| Variant | Hub | Type |
|---|---|---|
gemma-2b |
kerasformers/gemma-2b |
base |
gemma-2b-it |
kerasformers/gemma-2b-it |
instruct |
gemma-1.1-2b-it |
kerasformers/gemma-1.1-2b-it |
instruct (1.1) |
gemma-7b |
kerasformers/gemma-7b |
base |
gemma-7b-it |
kerasformers/gemma-7b-it |
instruct |
gemma-1.1-7b-it |
kerasformers/gemma-1.1-7b-it |
instruct (1.1) |
Tips
- Set
KERAS_BACKENDbefore importing Keras / kerasformers. - Prefer
GemmaTokenizer.from_weights(...)so the chat template matches. - Larger checkpoints: try
load_dtype="bfloat16"orquantization="int8". - See Gemma docs and Loading Weights.
- Community / upstream safetensors still work via the
hf:prefix, e.g.GemmaGenerate.from_weights("hf:google/gemma-7b").
Special Thanks
A huge thank you to the Google Gemma authors for creating and releasing these models.
License: Gemma (gated). Accept the license on the upstream Hub card before downloading.
- Downloads last month
- 44
Model tree for kerasformers/gemma-7b
Base model
google/gemma-7b