Instructions to use keras/gpt2_large_en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasHub
How to use keras/gpt2_large_en with KerasHub:
import keras_hub # Load CausalLM model (optional: use half precision for inference) causal_lm = keras_hub.models.CausalLM.from_preset("hf://keras/gpt2_large_en", dtype="bfloat16") causal_lm.compile(sampler="greedy") # (optional) specify a sampler # Generate text causal_lm.generate("Keras: deep learning for", max_length=64)import keras_hub # Create a Backbone model unspecialized for any task backbone = keras_hub.models.Backbone.from_preset("hf://keras/gpt2_large_en") - Keras
How to use keras/gpt2_large_en with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://keras/gpt2_large_en") - Notebooks
- Google Colab
- Kaggle
Update README.md with new model card content
Browse files
README.md
CHANGED
|
@@ -92,7 +92,7 @@ gpt2_lm.generate(prompt)
|
|
| 92 |
Call `fit()` on a single batch.
|
| 93 |
```python
|
| 94 |
features = ["The quick brown fox jumped.", "I forgot my homework."]
|
| 95 |
-
gpt2_lm = keras_hub.models.GPT2CausalLM.from_preset("
|
| 96 |
gpt2_lm.fit(x=features, batch_size=2)
|
| 97 |
```
|
| 98 |
|
|
@@ -158,7 +158,7 @@ gpt2_lm.generate(prompt)
|
|
| 158 |
Call `fit()` on a single batch.
|
| 159 |
```python
|
| 160 |
features = ["The quick brown fox jumped.", "I forgot my homework."]
|
| 161 |
-
gpt2_lm = keras_hub.models.GPT2CausalLM.from_preset("
|
| 162 |
gpt2_lm.fit(x=features, batch_size=2)
|
| 163 |
```
|
| 164 |
|
|
|
|
| 92 |
Call `fit()` on a single batch.
|
| 93 |
```python
|
| 94 |
features = ["The quick brown fox jumped.", "I forgot my homework."]
|
| 95 |
+
gpt2_lm = keras_hub.models.GPT2CausalLM.from_preset("gpt2_large_en")
|
| 96 |
gpt2_lm.fit(x=features, batch_size=2)
|
| 97 |
```
|
| 98 |
|
|
|
|
| 158 |
Call `fit()` on a single batch.
|
| 159 |
```python
|
| 160 |
features = ["The quick brown fox jumped.", "I forgot my homework."]
|
| 161 |
+
gpt2_lm = keras_hub.models.GPT2CausalLM.from_preset("hf://keras/gpt2_large_en")
|
| 162 |
gpt2_lm.fit(x=features, batch_size=2)
|
| 163 |
```
|
| 164 |
|