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:
# !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/roberta_base_en") - Notebooks
- Google Colab
- Kaggle
Update README.md with new model card content
Browse files
README.md
CHANGED
|
@@ -50,7 +50,7 @@ labels = [0, 3]
|
|
| 50 |
|
| 51 |
# Pretrained classifier.
|
| 52 |
classifier = keras_nlp.models.RobertaClassifier.from_preset(
|
| 53 |
-
"
|
| 54 |
num_classes=4,
|
| 55 |
)
|
| 56 |
classifier.fit(x=features, y=labels, batch_size=2)
|
|
@@ -78,7 +78,7 @@ labels = [0, 3]
|
|
| 78 |
|
| 79 |
# Pretrained classifier without preprocessing.
|
| 80 |
classifier = keras_nlp.models.RobertaClassifier.from_preset(
|
| 81 |
-
"
|
| 82 |
num_classes=4,
|
| 83 |
preprocessor=None,
|
| 84 |
)
|
|
@@ -100,7 +100,7 @@ labels = [0, 3]
|
|
| 100 |
|
| 101 |
# Pretrained classifier.
|
| 102 |
classifier = keras_nlp.models.RobertaClassifier.from_preset(
|
| 103 |
-
"
|
| 104 |
num_classes=4,
|
| 105 |
)
|
| 106 |
classifier.fit(x=features, y=labels, batch_size=2)
|
|
@@ -128,7 +128,7 @@ labels = [0, 3]
|
|
| 128 |
|
| 129 |
# Pretrained classifier without preprocessing.
|
| 130 |
classifier = keras_nlp.models.RobertaClassifier.from_preset(
|
| 131 |
-
"
|
| 132 |
num_classes=4,
|
| 133 |
preprocessor=None,
|
| 134 |
)
|
|
|
|
| 50 |
|
| 51 |
# Pretrained classifier.
|
| 52 |
classifier = keras_nlp.models.RobertaClassifier.from_preset(
|
| 53 |
+
"roberta_base_en",
|
| 54 |
num_classes=4,
|
| 55 |
)
|
| 56 |
classifier.fit(x=features, y=labels, batch_size=2)
|
|
|
|
| 78 |
|
| 79 |
# Pretrained classifier without preprocessing.
|
| 80 |
classifier = keras_nlp.models.RobertaClassifier.from_preset(
|
| 81 |
+
"roberta_base_en",
|
| 82 |
num_classes=4,
|
| 83 |
preprocessor=None,
|
| 84 |
)
|
|
|
|
| 100 |
|
| 101 |
# Pretrained classifier.
|
| 102 |
classifier = keras_nlp.models.RobertaClassifier.from_preset(
|
| 103 |
+
"roberta_base_en",
|
| 104 |
num_classes=4,
|
| 105 |
)
|
| 106 |
classifier.fit(x=features, y=labels, batch_size=2)
|
|
|
|
| 128 |
|
| 129 |
# Pretrained classifier without preprocessing.
|
| 130 |
classifier = keras_nlp.models.RobertaClassifier.from_preset(
|
| 131 |
+
"roberta_base_en",
|
| 132 |
num_classes=4,
|
| 133 |
preprocessor=None,
|
| 134 |
)
|