Example #1
0
 def build_backend(self):
     """Build the transformer backend. Use the `BaseTransformerBackend` base class
     to inherit from when building a new backend. All the layers in the transformer
     backend model will be available (encoder, embeddings etc.) for use. Adjust
     your derived class based on the transformer backend you want to use.
     """
     backend_config = self.config.get("backend", {})
     backend_type = getattr(backend_config, "type", "huggingface")
     backend_class = registry.get_transformer_backend_class(backend_type)
     self.backend = backend_class(self.config)
Example #2
0
    def build_backend(self):
        """Build the transformer backend. Use the `BaseTransformerBackend` base class
        to inherit from when building a new backend. All the layers in the transformer
        backend model will be available (encoder, embeddings etc.) for use. Adjust
        your derived class based on the transformer backend you want to use.
        """
        backend_config = self.config.get("backend", {})
        backend_type = backend_config.get("type", "huggingface")
        backend_class = registry.get_transformer_backend_class(backend_type)
        self.backend = backend_class(self.config)

        if backend_config.get("freeze", False):
            for param in self.backend.parameters():
                param.requires_grad = False