Instructions to use zeromodels/gemma-7b-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/gemma-7b-it with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/gemma-7b-it") - Notebooks
- Google Colab
- Kaggle
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
Browse files- README.md +18 -18
- kf_config.json → zm_config.json +3 -3
README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
| 2 |
pipeline_tag: text-generation
|
| 3 |
license: gemma
|
| 4 |
base_model: google/gemma-7b-it
|
| 5 |
-
library_name:
|
| 6 |
extra_gated_heading: Access Gemma on Hugging Face
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
tags:
|
| 10 |
- keras
|
| 11 |
-
-
|
| 12 |
- gemma
|
| 13 |
- gemma-7b
|
| 14 |
- text-generation
|
|
@@ -18,13 +18,13 @@ tags:
|
|
| 18 |
- tf
|
| 19 |
---
|
| 20 |
|
| 21 |
-
## ***See [our collection](https://huggingface.co/collections/
|
| 22 |
|
| 23 |
# Run Gemma with Keras 3: JAX, PyTorch, or TensorFlow
|
| 24 |
|
| 25 |
-
[](https://arxiv.org/abs/2403.08295) · [HF Papers](https://huggingface.co/papers/2403.08295)
|
| 30 |
|
|
@@ -32,7 +32,7 @@ Gemma is Google's open decoder-only LLM family (RMSNorm, GeGLU, RoPE, multi-quer
|
|
| 32 |
|
| 33 |
For more details on the model, please go to Google's original [model card](https://huggingface.co/google/gemma-7b-it).
|
| 34 |
|
| 35 |
-
Pure-**Keras 3** conversion of [`google/gemma-7b-it`](https://huggingface.co/google/gemma-7b-it) for [
|
| 36 |
|
| 37 |
This is an **instruction-tuned** checkpoint: use the chat template via `GemmaTokenizer`.
|
| 38 |
|
|
@@ -42,10 +42,10 @@ This is an **instruction-tuned** checkpoint: use the chat template via `GemmaTok
|
|
| 42 |
import os
|
| 43 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 44 |
|
| 45 |
-
from
|
| 46 |
|
| 47 |
-
model = GemmaTextGenerate.from_weights("
|
| 48 |
-
tokenizer = GemmaTokenizer.from_weights("
|
| 49 |
|
| 50 |
inputs = tokenizer([
|
| 51 |
{"role": "user", "content": "Explain rotary embeddings in one sentence."}
|
|
@@ -54,23 +54,23 @@ outputs = model.generate(**inputs, max_new_tokens=64)
|
|
| 54 |
print(tokenizer.decode(outputs[0]))
|
| 55 |
```
|
| 56 |
|
| 57 |
-
Load any Gemma v1 variant the same way with `from_weights("
|
| 58 |
|
| 59 |
| Variant | Hub | Type |
|
| 60 |
|---|---|---|
|
| 61 |
-
| `gemma-2b` | [`
|
| 62 |
-
| `gemma-2b-it` | [`
|
| 63 |
-
| `gemma-1.1-2b-it` | [`
|
| 64 |
-
| `gemma-7b` | [`
|
| 65 |
-
| `gemma-7b-it` | [`
|
| 66 |
-
| `gemma-1.1-7b-it` | [`
|
| 67 |
|
| 68 |
## Tips
|
| 69 |
|
| 70 |
-
- Set `KERAS_BACKEND` **before** importing Keras /
|
| 71 |
- Prefer `GemmaTokenizer.from_weights(...)` so the chat template matches.
|
| 72 |
- Larger checkpoints: try `load_dtype="bfloat16"` or `quantization="int8"`.
|
| 73 |
-
- See [Gemma docs](https://imvision12.github.io/
|
| 74 |
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `GemmaTextGenerate.from_weights("hf:google/gemma-7b-it")`.
|
| 75 |
|
| 76 |
## Special Thanks
|
|
|
|
| 2 |
pipeline_tag: text-generation
|
| 3 |
license: gemma
|
| 4 |
base_model: google/gemma-7b-it
|
| 5 |
+
library_name: zeromodels
|
| 6 |
extra_gated_heading: Access Gemma on Hugging Face
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
tags:
|
| 10 |
- keras
|
| 11 |
+
- zeromodels
|
| 12 |
- gemma
|
| 13 |
- gemma-7b
|
| 14 |
- text-generation
|
|
|
|
| 18 |
- tf
|
| 19 |
---
|
| 20 |
|
| 21 |
+
## ***See [our collection](https://huggingface.co/collections/zeromodels/gemma-6a69aaecae0f1f518733ffa1) for all versions of Gemma.***
|
| 22 |
|
| 23 |
# Run Gemma with Keras 3: JAX, PyTorch, or TensorFlow
|
| 24 |
|
| 25 |
+
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/gemma/) [](https://huggingface.co/collections/zeromodels/gemma-6a69aaecae0f1f518733ffa1)
|
| 26 |
|
| 27 |
+
# zeromodels/gemma-7b-it
|
| 28 |
|
| 29 |
Paper: [Gemma: Open Models Based on Gemini Research and Technology (arXiv:2403.08295)](https://arxiv.org/abs/2403.08295) · [HF Papers](https://huggingface.co/papers/2403.08295)
|
| 30 |
|
|
|
|
| 32 |
|
| 33 |
For more details on the model, please go to Google's original [model card](https://huggingface.co/google/gemma-7b-it).
|
| 34 |
|
| 35 |
+
Pure-**Keras 3** conversion of [`google/gemma-7b-it`](https://huggingface.co/google/gemma-7b-it) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
| 36 |
|
| 37 |
This is an **instruction-tuned** checkpoint: use the chat template via `GemmaTokenizer`.
|
| 38 |
|
|
|
|
| 42 |
import os
|
| 43 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 44 |
|
| 45 |
+
from zeromodels.models.gemma import GemmaTextGenerate, GemmaTokenizer
|
| 46 |
|
| 47 |
+
model = GemmaTextGenerate.from_weights("zeromodels/gemma-7b-it")
|
| 48 |
+
tokenizer = GemmaTokenizer.from_weights("zeromodels/gemma-7b-it")
|
| 49 |
|
| 50 |
inputs = tokenizer([
|
| 51 |
{"role": "user", "content": "Explain rotary embeddings in one sentence."}
|
|
|
|
| 54 |
print(tokenizer.decode(outputs[0]))
|
| 55 |
```
|
| 56 |
|
| 57 |
+
Load any Gemma v1 variant the same way with `from_weights("zeromodels/<variant>")`:
|
| 58 |
|
| 59 |
| Variant | Hub | Type |
|
| 60 |
|---|---|---|
|
| 61 |
+
| `gemma-2b` | [`zeromodels/gemma-2b`](https://huggingface.co/zeromodels/gemma-2b) | base |
|
| 62 |
+
| `gemma-2b-it` | [`zeromodels/gemma-2b-it`](https://huggingface.co/zeromodels/gemma-2b-it) | instruct |
|
| 63 |
+
| `gemma-1.1-2b-it` | [`zeromodels/gemma-1.1-2b-it`](https://huggingface.co/zeromodels/gemma-1.1-2b-it) | instruct (1.1) |
|
| 64 |
+
| `gemma-7b` | [`zeromodels/gemma-7b`](https://huggingface.co/zeromodels/gemma-7b) | base |
|
| 65 |
+
| `gemma-7b-it` | [`zeromodels/gemma-7b-it`](https://huggingface.co/zeromodels/gemma-7b-it) | instruct |
|
| 66 |
+
| `gemma-1.1-7b-it` | [`zeromodels/gemma-1.1-7b-it`](https://huggingface.co/zeromodels/gemma-1.1-7b-it) | instruct (1.1) |
|
| 67 |
|
| 68 |
## Tips
|
| 69 |
|
| 70 |
+
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
|
| 71 |
- Prefer `GemmaTokenizer.from_weights(...)` so the chat template matches.
|
| 72 |
- Larger checkpoints: try `load_dtype="bfloat16"` or `quantization="int8"`.
|
| 73 |
+
- See [Gemma docs](https://imvision12.github.io/ZeroModels/gemma/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
|
| 74 |
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `GemmaTextGenerate.from_weights("hf:google/gemma-7b-it")`.
|
| 75 |
|
| 76 |
## Special Thanks
|
kf_config.json → zm_config.json
RENAMED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
-
"library_name": "
|
| 3 |
-
"
|
| 4 |
-
"model_module": "
|
| 5 |
"model_class": "GemmaTextGenerate",
|
| 6 |
"variant": "gemma-7b-it",
|
| 7 |
"weights": "model.weights.json",
|
|
|
|
| 1 |
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.2.1",
|
| 4 |
+
"model_module": "zeromodels.models.gemma",
|
| 5 |
"model_class": "GemmaTextGenerate",
|
| 6 |
"variant": "gemma-7b-it",
|
| 7 |
"weights": "model.weights.json",
|