Instructions to use keras/roberta_base_en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasHub
How to use keras/roberta_base_en with KerasHub:
import keras_hub # Load TextClassifier model text_classifier = keras_hub.models.TextClassifier.from_preset( "hf://keras/roberta_base_en", num_classes=2, ) # Fine-tune text_classifier.fit(x=["Thilling adventure!", "Total snoozefest."], y=[1, 0]) # Classify text text_classifier.predict(["Not my cup of tea."])import keras_hub # Create a MaskedLM model task = keras_hub.models.MaskedLM.from_preset("hf://keras/roberta_base_en")import keras_hub # Create a Backbone model unspecialized for any task backbone = keras_hub.models.Backbone.from_preset("hf://keras/roberta_base_en") - Keras
How to use keras/roberta_base_en with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://keras/roberta_base_en") - Notebooks
- Google Colab
- Kaggle
Update README.md with new model card content
Browse files
README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
### Model Overview
|
| 2 |
A RoBERTa encoder network.
|
| 3 |
|
|
@@ -36,7 +39,7 @@ __Arguments__
|
|
| 36 |
### Example Usage
|
| 37 |
```python
|
| 38 |
import keras
|
| 39 |
-
import
|
| 40 |
import numpy as np
|
| 41 |
```
|
| 42 |
|
|
@@ -46,8 +49,8 @@ features = ["The quick brown fox jumped.", "I forgot my homework."]
|
|
| 46 |
labels = [0, 3]
|
| 47 |
|
| 48 |
# Pretrained classifier.
|
| 49 |
-
classifier =
|
| 50 |
-
"
|
| 51 |
num_classes=4,
|
| 52 |
)
|
| 53 |
classifier.fit(x=features, y=labels, batch_size=2)
|
|
@@ -74,8 +77,8 @@ features = {
|
|
| 74 |
labels = [0, 3]
|
| 75 |
|
| 76 |
# Pretrained classifier without preprocessing.
|
| 77 |
-
classifier =
|
| 78 |
-
"
|
| 79 |
num_classes=4,
|
| 80 |
preprocessor=None,
|
| 81 |
)
|
|
@@ -86,7 +89,7 @@ classifier.fit(x=features, y=labels, batch_size=2)
|
|
| 86 |
|
| 87 |
```python
|
| 88 |
import keras
|
| 89 |
-
import
|
| 90 |
import numpy as np
|
| 91 |
```
|
| 92 |
|
|
@@ -96,8 +99,8 @@ features = ["The quick brown fox jumped.", "I forgot my homework."]
|
|
| 96 |
labels = [0, 3]
|
| 97 |
|
| 98 |
# Pretrained classifier.
|
| 99 |
-
classifier =
|
| 100 |
-
"
|
| 101 |
num_classes=4,
|
| 102 |
)
|
| 103 |
classifier.fit(x=features, y=labels, batch_size=2)
|
|
@@ -124,8 +127,8 @@ features = {
|
|
| 124 |
labels = [0, 3]
|
| 125 |
|
| 126 |
# Pretrained classifier without preprocessing.
|
| 127 |
-
classifier =
|
| 128 |
-
"
|
| 129 |
num_classes=4,
|
| 130 |
preprocessor=None,
|
| 131 |
)
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: keras-hub
|
| 3 |
+
---
|
| 4 |
### Model Overview
|
| 5 |
A RoBERTa encoder network.
|
| 6 |
|
|
|
|
| 39 |
### Example Usage
|
| 40 |
```python
|
| 41 |
import keras
|
| 42 |
+
import keras_hub
|
| 43 |
import numpy as np
|
| 44 |
```
|
| 45 |
|
|
|
|
| 49 |
labels = [0, 3]
|
| 50 |
|
| 51 |
# Pretrained classifier.
|
| 52 |
+
classifier = keras_hub.models.RobertaClassifier.from_preset(
|
| 53 |
+
"roberta_base_en",
|
| 54 |
num_classes=4,
|
| 55 |
)
|
| 56 |
classifier.fit(x=features, y=labels, batch_size=2)
|
|
|
|
| 77 |
labels = [0, 3]
|
| 78 |
|
| 79 |
# Pretrained classifier without preprocessing.
|
| 80 |
+
classifier = keras_hub.models.RobertaClassifier.from_preset(
|
| 81 |
+
"roberta_base_en",
|
| 82 |
num_classes=4,
|
| 83 |
preprocessor=None,
|
| 84 |
)
|
|
|
|
| 89 |
|
| 90 |
```python
|
| 91 |
import keras
|
| 92 |
+
import keras_hub
|
| 93 |
import numpy as np
|
| 94 |
```
|
| 95 |
|
|
|
|
| 99 |
labels = [0, 3]
|
| 100 |
|
| 101 |
# Pretrained classifier.
|
| 102 |
+
classifier = keras_hub.models.RobertaClassifier.from_preset(
|
| 103 |
+
"roberta_base_en",
|
| 104 |
num_classes=4,
|
| 105 |
)
|
| 106 |
classifier.fit(x=features, y=labels, batch_size=2)
|
|
|
|
| 127 |
labels = [0, 3]
|
| 128 |
|
| 129 |
# Pretrained classifier without preprocessing.
|
| 130 |
+
classifier = keras_hub.models.RobertaClassifier.from_preset(
|
| 131 |
+
"roberta_base_en",
|
| 132 |
num_classes=4,
|
| 133 |
preprocessor=None,
|
| 134 |
)
|