tensorflow/models · error · RuntimeError

The EncoderScaffold %s does not have a reference to the embe

Error message

The EncoderScaffold %s does not have a reference to the embedding data. This is required when you pass a custom embedding network to the scaffold. It is also possible that you are trying to get embedding data from an embedding scaffold with a custom embedding network where the scaffold has been serialized and deserialized. Unfortunately, accessing custom embedding references after serialization is not yet supported.

What it means

Error "The EncoderScaffold %s does not have a reference to the embedding data. This is required when you pass a custom embedding network to the scaffold. It is also possible that you are trying to get embedding data from an embedding scaffold with a custom embedding network where the scaffold has been serialized and deserialized. Unfortunately, accessing custom embedding references after serialization is not yet supported." thrown in tensorflow/models.

Source

Thrown at official/nlp/modeling/networks/encoder_scaffold.py:367

  @classmethod
  def from_config(cls, config, custom_objects=None):
    cls_names = ['hidden_cls', 'mask_cls']
    for cls_name in cls_names:
      cls_string = '{}_string'.format(cls_name)
      if cls_string in config:
        config[cls_name] = tf_keras.utils.get_registered_object(
            config[cls_string], custom_objects=custom_objects)
        del config[cls_string]
    return cls(**config)

  def get_embedding_table(self):
    if self._embedding_network is None:
      # In this case, we don't have a custom embedding network and can return
      # the standard embedding data.
      return self._embedding_layer.embeddings  # pyrefly: ignore[missing-attribute]

    if self._embedding_data is None:
      raise RuntimeError(('The EncoderScaffold %s does not have a reference '
                          'to the embedding data. This is required when you '
                          'pass a custom embedding network to the scaffold. '
                          'It is also possible that you are trying to get '
                          'embedding data from an embedding scaffold with a '
                          'custom embedding network where the scaffold has '
                          'been serialized and deserialized. Unfortunately, '
                          'accessing custom embedding references after '
                          'serialization is not yet supported.') % self.name)
    else:
      return self._embedding_data

  @property
  def embedding_network(self):
    if self._embedding_network is None:
      raise RuntimeError(
          ('The EncoderScaffold %s does not have a reference '
           'to the embedding network. This is required when you '
           'pass a custom embedding network to the scaffold.') % self.name)

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/nlp/modeling/networks/encoder_scaffold.py:367 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/0788d3a9f7696579. Report an issue: GitHub.