当前位置:   article > 正文

HuggingFace_huggingface linux登录

huggingface linux登录

文章目录

一、官网

huggingface.co
  • 1

二、模型下载

环境中安装 transformers

conda install -n ycz transformers
  • 1

模型自动下载 引号中是模型名称

from transformers import BertTokenizer, BertModel
model = BertModel.from_pretrained('bert-base-chinese', output_hidden_states = True,)
tokenizer = BertTokenizer.from_pretrained('bert-base-chinese')
  • 1
  • 2
  • 3

模型自动下载位置

/home/用户名/.cache/huggingface/transformers
  • 1

手动下载
网页最上方搜索模型名字
点击Model card右侧的Files and Versions
传入模型保存本地路径

model = BertModel.from_pretrained('./model', output_hidden_states = True,)
tokenizer = BertTokenizer.from_pretrained('./model/vocab.txt')
注意,BertModel.from_pretrained里面输入的是文件夹的路径
BertTokenizer.from_pretrained里面输入的是vocab.txt,而不是tokenizer.json。
  • 1
  • 2
  • 3
  • 4

加速下载

model = BertModel.from_pretrained('bert-base-chinese', mirror='tuna')
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/281450
推荐阅读
相关标签
  

闽ICP备14008679号