ray.train.huggingface.TransformersCheckpoint.from_model
ray.train.huggingface.TransformersCheckpoint.from_model#
- classmethod TransformersCheckpoint.from_model(model: Union[transformers.modeling_utils.PreTrainedModel, torch.nn.Module], tokenizer: Optional[transformers.PreTrainedTokenizer] = None, *, path: os.PathLike, preprocessor: Optional[Preprocessor] = None) TransformersCheckpoint[source]#
Create a
Checkpointthat stores a HuggingFace model.- Parameters
model – The pretrained transformer or Torch model to store in the checkpoint.
tokenizer – The Tokenizer to use in the Transformers pipeline for inference.
path – The directory where the checkpoint will be stored.
preprocessor – A fitted preprocessor to be applied before inference.
- Returns
A
TransformersCheckpointcontaining the specified model.