Shivanandroy / simpleT5

simpleT5 is built on top of PyTorch-lightning⚡️ and Transformers🤗 that lets you quickly train your T5 models.
MIT License
382 stars 61 forks source link

shows object has no attribute 'convert_and_load_onnx_model' #16

Closed pradeepdev-1995 closed 2 years ago

pradeepdev-1995 commented 2 years ago

Shows the error AttributeError: 'SimpleT5' object has no attribute 'convert_and_load_onnx_model' while running the example notebook provided in the repository

https://github.com/Shivanandroy/simpleT5/blob/main/examples/simpleT5-summarization.ipynb

Shivanandroy commented 2 years ago

Hi @pradeepdev-1995 , Thanks for pointing out, I have updated the notebook. The recent version of simpleT5 only supports below methods

# import
from simplet5 import SimpleT5

# instantiate
model = SimpleT5()

# load (supports t5, mt5, byT5 models)
model.from_pretrained("t5","t5-base")

# train
model.train(train_df=train_df, # pandas dataframe with 2 columns: source_text & target_text
            eval_df=eval_df, # pandas dataframe with 2 columns: source_text & target_text
            source_max_token_len = 512, 
            target_max_token_len = 128,
            batch_size = 8,
            max_epochs = 5,
            use_gpu = True,
            outputdir = "outputs",
            early_stopping_patience_epochs = 0,
            precision = 32
            )

# load trained T5 model
model.load_model("t5","path/to/trained/model/directory", use_gpu=False)

# predict
model.predict("input text for prediction")
pradeepdev-1995 commented 2 years ago

@Shivanandroy Thank you Which means convert_and_load_onnx_model is no longer available? If I want to export a model to onnx for faster inference then what should I do?

Shivanandroy commented 2 years ago

There are many packages which can help you with quantization and onnx runtime. e.g. fastT5: https://github.com/Ki6an/fastT5

pradeepdev-1995 commented 2 years ago

Thank you