Instructions to use keras/bert_base_en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasHub
How to use keras/bert_base_en with KerasHub:
import keras_hub # Load TextClassifier model text_classifier = keras_hub.models.TextClassifier.from_preset( "hf://keras/bert_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/bert_base_en")import keras_hub # Create a Backbone model unspecialized for any task backbone = keras_hub.models.Backbone.from_preset("hf://keras/bert_base_en") - Keras
How to use keras/bert_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/bert_base_en") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse filesFiles changed (6)
- README.mdAdded+17
- assets/tokenizer/vocabulary.txtAdded
- config.jsonAdded+19
- metadata.jsonAdded+6
- model.weights.h5Added+3
- tokenizer.jsonAdded+21
1234567891011121314151617---library_name: keras-hub---This is a [`Bert` model](https://keras.io/api/keras_hub/models/bert) uploaded using the KerasHub library and can be used with JAX, TensorFlow, and PyTorch backends.Model config:* **name:** bert_backbone* **trainable:** True* **vocabulary_size:** 28996* **num_layers:** 12* **num_heads:** 12* **hidden_dim:** 768* **intermediate_dim:** 3072* **dropout:** 0.1* **max_sequence_length:** 512* **num_segments:** 2
This model card has been generated automatically and should be completed by the model author. See [Model Cards documentation](https://huggingface.co/docs/hub/model-cards) for more information.12345678910111213141516171819{ "module": "keras_nlp.src.models.bert.bert_backbone", "class_name": "BertBackbone", "config": { "name": "bert_backbone", "trainable": true, "vocabulary_size": 28996, "num_layers": 12, "num_heads": 12, "hidden_dim": 768, "intermediate_dim": 3072, "dropout": 0.1, "max_sequence_length": 512, "num_segments": 2 }, "registered_name": "keras_nlp>BertBackbone", "assets": [], "weights": "model.weights.h5"}123456{ "keras_version": "3.0.1", "keras_nlp_version": "0.7.0", "parameter_count": 108310272, "date_saved": "2023-12-27@02:03:19"}123version https://git-lfs.github.com/spec/v1oid sha256:a23576327ffd47bc7f9f2043bb0b2bb39fb921e74068cca2c16e8342714f47e9size 433648176123456789101112131415161718192021{ "module": "keras_nlp.src.models.bert.bert_tokenizer", "class_name": "BertTokenizer", "config": { "name": "bert_tokenizer", "trainable": true, "dtype": "int32", "vocabulary": null, "sequence_length": null, "lowercase": false, "strip_accents": false, "split": true, "suffix_indicator": "##", "oov_token": "[UNK]" }, "registered_name": "keras_nlp>BertTokenizer", "assets": [ "assets/tokenizer/vocabulary.txt" ], "weights": null}README.mdAdded+17
assets/tokenizer/vocabulary.txtAdded
config.jsonAdded+19
metadata.jsonAdded+6
model.weights.h5Added+3
tokenizer.jsonAdded+21