Instructions to use shibatch/tinygemma4text3m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shibatch/tinygemma4text3m with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("shibatch/tinygemma4text3m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -169,13 +169,14 @@ The model can generate TinyStories-like text fragments, but repetitions and temp
|
|
| 169 |
|
| 170 |
```python
|
| 171 |
import torch
|
| 172 |
-
from transformers import
|
| 173 |
|
| 174 |
repo = "shibatch/tinygemma4text3m"
|
| 175 |
|
| 176 |
-
tokenizer =
|
| 177 |
model = Gemma4ForCausalLM.from_pretrained(
|
| 178 |
repo,
|
|
|
|
| 179 |
torch_dtype=torch.float32,
|
| 180 |
)
|
| 181 |
model.eval()
|
|
@@ -195,16 +196,6 @@ with torch.no_grad():
|
|
| 195 |
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
|
| 196 |
```
|
| 197 |
|
| 198 |
-
If the model files are stored under an `hf/` subdirectory in the repository, use:
|
| 199 |
-
|
| 200 |
-
```python
|
| 201 |
-
tokenizer = AutoTokenizer.from_pretrained(repo, subfolder="hf")
|
| 202 |
-
model = Gemma4ForCausalLM.from_pretrained(
|
| 203 |
-
repo,
|
| 204 |
-
subfolder="hf",
|
| 205 |
-
torch_dtype=torch.float32,
|
| 206 |
-
)
|
| 207 |
-
```
|
| 208 |
|
| 209 |
## Loading with Transformers
|
| 210 |
|
|
|
|
| 169 |
|
| 170 |
```python
|
| 171 |
import torch
|
| 172 |
+
from transformers import PreTrainedTokenizerFast, Gemma4ForCausalLM
|
| 173 |
|
| 174 |
repo = "shibatch/tinygemma4text3m"
|
| 175 |
|
| 176 |
+
tokenizer = PreTrainedTokenizerFast.from_pretrained(repo, subfolder="hf")
|
| 177 |
model = Gemma4ForCausalLM.from_pretrained(
|
| 178 |
repo,
|
| 179 |
+
subfolder="hf",
|
| 180 |
torch_dtype=torch.float32,
|
| 181 |
)
|
| 182 |
model.eval()
|
|
|
|
| 196 |
print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
|
| 197 |
```
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
## Loading with Transformers
|
| 201 |
|