以t5-base为例:

 

储存模型:

from transformers import AutoModelForSeq2SeqLM
if __name__ == '__main__':
model_name = 't5-base'
prefix = 'your_path'
save_path = prefix+model_name

model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
model.save_pretrained(save_path)

 

加载模型:

model = AutoModelForSeq2SeqLM.from_pretrained(save_path)

 

黄世宇/Shiyu Huang's Personal Page:​​https://huangshiyu13.github.io/​