huggingface model模型本地化

以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)

 

posted @ 2023-03-03 21:21  Shiyu_Huang  阅读(518)  评论(0编辑  收藏  举报