from_preset() is a KerasHub constructor for loading a pretrained model together with its configuration, weights, and tokenizer assets from disk. section 15.4.2
Listing 15.20 Loading the RoBERTa pretrained model with KerasHub
py_require("keras-hub")
keras_hub <- import("keras_hub")
tokenizer <- keras_hub$models$Tokenizer$from_preset("roberta_base_en")
backbone <- keras_hub$models$Backbone$from_preset("roberta_base_en")
Load a RoBERTa tokenizer and backbone from the same preset, then use the tokenizer for text and the backbone for model inputs. section 15.4.2
RoBERTa and Xception presets
The preset name identifies the checkpoint to load. The RoBERTa example uses "roberta_base_en" for both tokenizer and backbone. For image feature extraction, "xception_41_imagenet" loads a convolutional base, optionally with trainable = FALSE, while ImageConverter$from_preset() matches image preprocessing to the checkpoint. section 15.4.2 section 8.3.1
A preset can provide the main components needed to use pretrained models:
- Tokenizers convert text into integer sequences using the checkpoint's tokenization setup. section 15.4.2
- Backbones provide pretrained task-independent model representations that can feed a task-specific head. section 15.4.2
- ImageConverter presets rescale and resize images to match the pretrained checkpoint's expected input format. section 8.3.1

