Update README.md
Browse files
README.md
CHANGED
@@ -1,14 +1,52 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
3 |
library_name: transformers
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Gemma 3 model card
|
14 |
|
@@ -44,55 +82,6 @@ limited resources such as laptops, desktops or your own cloud infrastructure,
|
|
44 |
democratizing access to state of the art AI models and helping foster innovation
|
45 |
for everyone.
|
46 |
|
47 |
-
### Usage
|
48 |
-
|
49 |
-
Below, there are some code snippets on how to get quickly started with running the model. First, install the Transformers library with the version made for Gemma 3:
|
50 |
-
|
51 |
-
```sh
|
52 |
-
|
53 |
-
$ pip install git+https://github.com/huggingface/[email protected]
|
54 |
-
|
55 |
-
```
|
56 |
-
|
57 |
-
Then, copy the snippet from the section that is relevant for your use case.
|
58 |
-
|
59 |
-
#### Running with the `pipeline` API
|
60 |
-
|
61 |
-
```python
|
62 |
-
from transformers import pipeline
|
63 |
-
|
64 |
-
pipe = pipeline("text-generation", model="google/gemma-3-1b-pt", device="cuda", torch_dtype=torch.bfloat16)
|
65 |
-
output = pipe("Eiffel tower is located in", max_new_tokens=50)
|
66 |
-
```
|
67 |
-
|
68 |
-
#### Running the model on a single / multi GPU
|
69 |
-
|
70 |
-
```python
|
71 |
-
import torch
|
72 |
-
from transformers import AutoTokenizer, Gemma3ForCausalLM
|
73 |
-
|
74 |
-
ckpt = "google/gemma-3-1b-pt"
|
75 |
-
tokenizer = AutoTokenizer.from_pretrained(ckpt)
|
76 |
-
model = Gemma3ForCausalLM.from_pretrained(
|
77 |
-
ckpt,
|
78 |
-
torch_dtype=torch.bfloat16,
|
79 |
-
device_map="auto"
|
80 |
-
)
|
81 |
-
|
82 |
-
prompt = "Eiffel tower is located in"
|
83 |
-
model_inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
84 |
-
|
85 |
-
input_len = model_inputs["input_ids"].shape[-1]
|
86 |
-
|
87 |
-
with torch.inference_mode():
|
88 |
-
generation = model.generate(**model_inputs, max_new_tokens=50, do_sample=False)
|
89 |
-
generation = generation[0][input_len:]
|
90 |
-
|
91 |
-
decoded = tokenizer.decode(generation, skip_special_tokens=True)
|
92 |
-
print(decoded)
|
93 |
-
```
|
94 |
-
|
95 |
-
|
96 |
### Inputs and outputs
|
97 |
|
98 |
- **Input:**
|
|
|
1 |
---
|
2 |
+
base_model: google/gemma-3-1b-pt
|
3 |
+
language:
|
4 |
+
- en
|
5 |
library_name: transformers
|
6 |
+
license: gemma
|
7 |
+
tags:
|
8 |
+
- unsloth
|
9 |
+
- transformers
|
10 |
+
- gemma3
|
11 |
+
- gemma
|
12 |
+
- google
|
13 |
---
|
14 |
+
<div>
|
15 |
+
<p style="margin-bottom: 0; margin-top: 0;">
|
16 |
+
<strong>See <a href="https://huggingface.co/collections/unsloth/gemma-3-67d12b7e8816ec6efa7e4e5b">our collection</a> for all versions of Gemma 3 including GGUF, 4-bit & 16-bit formats.</strong>
|
17 |
+
</p>
|
18 |
+
<p style="margin-bottom: 0;">
|
19 |
+
<em>Unsloth's Gemma 3 <a href="https://unsloth.ai/blog/dynamic-4bit">Dynamic Quants</a> is selectively quantized, greatly improving accuracy over standard 4-bit.</em>
|
20 |
+
</p>
|
21 |
+
<div style="display: flex; gap: 5px; align-items: center; ">
|
22 |
+
<a href="https://github.com/unslothai/unsloth/">
|
23 |
+
<img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
|
24 |
+
</a>
|
25 |
+
<a href="https://discord.gg/unsloth">
|
26 |
+
<img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
|
27 |
+
</a>
|
28 |
+
<a href="https://docs.unsloth.ai/basics/tutorial-how-to-run-deepseek-r1-on-your-own-local-device">
|
29 |
+
<img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
|
30 |
+
</a>
|
31 |
+
</div>
|
32 |
+
<h1 style="margin-top: 0rem;">✨ Fine-tune Gemma 3 with Unsloth!</h1>
|
33 |
+
</div>
|
34 |
+
|
35 |
+
- Fine-tune Gemma 3 (12B) for free using our Google [Colab notebook here](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3.ipynb)!
|
36 |
+
- Read our Blog about Gemma 3 support: [unsloth.ai/blog/gemma3](https://unsloth.ai/blog/gemma3)
|
37 |
+
- View the rest of our notebooks in our [docs here](https://docs.unsloth.ai/get-started/unsloth-notebooks).
|
38 |
+
- Export your fine-tuned model to GGUF, Ollama, llama.cpp or 🤗HF.
|
39 |
+
|
40 |
+
| Unsloth supports | Free Notebooks | Performance | Memory use |
|
41 |
+
|-----------------|--------------------------------------------------------------------------------------------------------------------------|-------------|----------|
|
42 |
+
| **GRPO with Gemma 3 (12B)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma_3_(12B)-GRPO.ipynb) | 2x faster | 80% less |
|
43 |
+
| **Llama-3.2 (3B)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3.2_(1B_and_3B)-Conversational.ipynb) | 2.4x faster | 58% less |
|
44 |
+
| **Llama-3.2 (11B vision)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3.2_(11B)-Vision.ipynb) | 2x faster | 60% less |
|
45 |
+
| **Qwen2.5 (7B)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen2.5_(7B)-Alpaca.ipynb) | 2x faster | 60% less |
|
46 |
+
| **Phi-4 (14B)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Phi_4-Conversational.ipynb) | 2x faster | 50% less |
|
47 |
+
| **Mistral (7B)** | [▶️ Start on Colab](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Mistral_v0.3_(7B)-Conversational.ipynb) | 2.2x faster | 62% less |
|
48 |
+
|
49 |
+
<br>
|
50 |
|
51 |
# Gemma 3 model card
|
52 |
|
|
|
82 |
democratizing access to state of the art AI models and helping foster innovation
|
83 |
for everyone.
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
### Inputs and outputs
|
86 |
|
87 |
- **Input:**
|