Skip to content

This is a simple flavor for saving and loading hugging face transformers model on mlflow, this version use the "save_pretrained" and "from_pretrained" function in the background, the tokenizer and model has to be saved and loaded separately

Notifications You must be signed in to change notification settings

Warra07/mlflow-hf-transformers-flavor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation

Mlflow huggingface transformer flavor

Introduction

A simple flavor to save and load huggingface transformers model on MLflow

Usage

import mlflow_hf_transformers
import mlflow
import transformers
with mlflow.start_run() as run: 
  mlflow_hf_transformers.log_model(model=model,artifact_path="testmodel", tokenizer=tokenizer)
 
 
import mlflow_hf_transformers

import mlflow
logged_model = 'runs:/xxxxxx/testmodel'

loaded_model, tokenizer = mlflow_hf_transformers.load_model(logged_model)

Tokenizer is optional, you can also save and load the tokenizer as an artifact :

import mlflow_hf_transformers
import mlflow
import transformers
with mlflow.start_run() as run: 
  mlflow_hf_transformers.log_tokenizer(tokenizer,"tokenizer")

  
logged_model = 'runs:/xxxx/tokenizer'

loaded_tokenizer = mlflow_hf_transformers.load_tokenizer(logged_model)

Installation

  1. Make sure pip is installed (https://packaging.python.org/tutorials/installing-packages/)
  2. Then you can install the flavor:
    > pip install git+https://github.com/Warra07/mlflow-hf-transformers-flavor.git

About

This is a simple flavor for saving and loading hugging face transformers model on mlflow, this version use the "save_pretrained" and "from_pretrained" function in the background, the tokenizer and model has to be saved and loaded separately

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages