liveBook · Manning

Foundational model

As explained in Deep Learning with R, Third Edition

A foundation model is a large pretrained model intended to support many downstream tasks with little or no task-specific retraining.

A foundation model is trained on broad data so it can support many downstream tasks instead of being built for just one. Its training is generally self-supervised: the data supplies its own target, such as the next word in a sentence or a sharp image to reconstruct from a noisy one. That lets training use large amounts of unlabeled data. section 16.4.2 section 1.8

Turn a pretrained model into a review classifier

Load a pretrained RoBERTa backbone and its tokenizer with KerasHub. The backbone converts an input sequence into contextual representations; it does not yet produce a review label. Take the first token’s representation, add a classification head, then fine-tune on IMDb reviews. The resulting classifier reached 93% test accuracy after one epoch. Reusing a large model improved on the earlier 90% ceiling, though it was more expensive to run. section 15.4.2 section 15.4.4

Listing 15.22 Extending the base RoBERTa model for classification
inputs <- backbone$input
outputs <- inputs |>
  backbone() |>
  op_subset(, 1, ) |>  #1
  layer_dropout(0.1) |>
  layer_dense(768, activation = "relu") |>
  layer_dropout(0.1) |>
  layer_dense(1, activation = "sigmoid")

classifier <- keras_model(inputs, outputs)

The R/Keras listing shows the task-specific head attached to RoBERTa: select one sequence representation, then produce a binary prediction. section 15.4.4

Choose how much of a pretrained model to adapt:

  • Prompt it when its existing representations can answer the request without task-specific retraining. section 1.8
  • Use feature extraction: keep a pretrained backbone and train a new head on its outputs. For image classification, the convolutional base supplies reusable visual features while the original classifier is tied to its training classes. section 8.3.1
  • Fine-tune when the representations need adjustment. First train the new head with the base frozen; then unfreeze the base and train them jointly. Unfreezing before the head is trained can destroy useful pretrained representations. section 8.3.2

A backbone is the reusable, not-yet-task-specialized part of a model—not a synonym for every foundation model. Its reuse extends beyond classification: a pretrained ResNet backbone can receive a new head for object detection. Foundation models can also span modalities; a multimodal language model can incorporate image inputs alongside text. section 15.4.2 section 12.2.2 section 16.4.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines self-supervised pretraining and works through backbone reuse, classification heads, and fine-tuning; does not build a foundation model from scratch.
Examples
Uses RoBERTa for IMDb review classification and pretrained convolutional backbones for image classification and object detection.
What it assumes
Introduces what a task-independent backbone does while using Keras model-building and training operations for the worked adaptation.
What you can do after
Apply it via KerasHub by loading a pretrained backbone, attaching a task-specific head, and fine-tuning it.
How it connects
Links foundation models to self-supervised learning, backbones, feature extraction, fine-tuning, prompting, and multimodal language models.

Also explained in

Compare how 21 books explain foundational model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.