Instructions to use keras/esm2_t12_35M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasHub
How to use keras/esm2_t12_35M with KerasHub:
import keras_hub # Load TextClassifier model text_classifier = keras_hub.models.TextClassifier.from_preset( "hf://keras/esm2_t12_35M", 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/esm2_t12_35M")import keras_hub # Create a Backbone model unspecialized for any task backbone = keras_hub.models.Backbone.from_preset("hf://keras/esm2_t12_35M") - Keras
How to use keras/esm2_t12_35M 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/esm2_t12_35M") - Notebooks
- Google Colab
- Kaggle
Download preprocessor.json from keras/esm2_t12_35M: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/keras/esm2_t12_35M/resolve/main/preprocessor.json
- Command line
-
hf download hf://keras/esm2_t12_35M/preprocessor.json
-
curl -L -o preprocessor.json https://huggingface.co/keras/esm2_t12_35M/resolve/main/preprocessor.json
1.73 kB
| { | |
| "module": "keras_hub.src.models.esm.esm_masked_plm_preprocessor", | |
| "class_name": "ESMMaskedPLMPreprocessor", | |
| "config": { | |
| "name": "esm_masked_plm_preprocessor_1", | |
| "trainable": true, | |
| "dtype": { | |
| "module": "keras", | |
| "class_name": "DTypePolicy", | |
| "config": { | |
| "name": "float32" | |
| }, | |
| "registered_name": null | |
| }, | |
| "tokenizer": { | |
| "module": "keras_hub.src.models.esm.esm_tokenizer", | |
| "class_name": "ESMTokenizer", | |
| "config": { | |
| "name": "esm_tokenizer", | |
| "trainable": true, | |
| "dtype": { | |
| "module": "keras", | |
| "class_name": "DTypePolicy", | |
| "config": { | |
| "name": "int32" | |
| }, | |
| "registered_name": null | |
| }, | |
| "config_file": "tokenizer.json", | |
| "vocabulary": null, | |
| "sequence_length": null, | |
| "lowercase": false, | |
| "strip_accents": false, | |
| "split": true, | |
| "suffix_indicator": "##", | |
| "oov_token": "<unk>", | |
| "special_tokens": null, | |
| "special_tokens_in_strings": false | |
| }, | |
| "registered_name": "keras_hub>ESMTokenizer" | |
| }, | |
| "config_file": "preprocessor.json", | |
| "sequence_length": 512, | |
| "truncate": "round_robin", | |
| "mask_selection_rate": 0.15, | |
| "mask_selection_length": 96, | |
| "mask_token_rate": 0.8, | |
| "random_token_rate": 0.1 | |
| }, | |
| "registered_name": "keras_hub>ESMMaskedPLMPreprocessor" | |
| } |