本地加载hugging face模型:Bert

找了个hf的镜像站,把config.json和pytorch_model.bin两个文件进行下载下来,模型文件uncased_L-12_H-768_A-12.zip下载下来先。

解压模型文件压缩包,把前面下载的两个文件也放进去,总共6个文件。这个文件夹就是代码

tokenizer = BertTokenizer.from_pretrained(BERT_PATH)

BERT_PATH这里对应的文件路径。

Some weights of BertForSequenceClassification were not initialized from the model checkpoint at bert-base-uncased and are newly initialized: ['classifier.bias', 'classifier.weight']

pip install tensorflow

from transformers import BertModel, BertTokenizer

model_name = 'bert-base-uncased'
tokenizer = BertTokenizer.from_pretrained(model_name)
model = BertModel.from_pretrained(model_name, from_tf=True)

相关推荐

  1. 本地hugging face模型Bert

    2024-05-09 14:34:02       13 阅读
  2. huggingface实战bert-base-chinese模型(训练+预测)

    2024-05-09 14:34:02       33 阅读
  3. 模型参数

    2024-05-09 14:34:02       19 阅读
  4. 【Python】如何训练模型并保存本地模型

    2024-05-09 14:34:02       11 阅读
  5. bert-base-chinese另外的方法.txt

    2024-05-09 14:34:02       21 阅读
  6. MFC 本地文件设置图标

    2024-05-09 14:34:02       38 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-05-09 14:34:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-05-09 14:34:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-05-09 14:34:02       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-05-09 14:34:02       20 阅读

热门阅读

  1. 【Excel VBA】在 Excel VBA 中使用 For 循环全面指南

    2024-05-09 14:34:02       10 阅读
  2. 神经网络和深度学习之间有什么区别

    2024-05-09 14:34:02       12 阅读
  3. React 第二十七章 Hook useMemo

    2024-05-09 14:34:02       13 阅读
  4. Spring AI

    Spring AI

    2024-05-09 14:34:02      7 阅读
  5. Spring IoC&DI—DI详解

    2024-05-09 14:34:02       8 阅读
  6. 分布式数据库有哪几种

    2024-05-09 14:34:02       17 阅读
  7. FFmpeg压缩视频大小

    2024-05-09 14:34:02       10 阅读
  8. MySQL-存储引擎

    2024-05-09 14:34:02       14 阅读
  9. Redis-5 分布式锁

    2024-05-09 14:34:02       15 阅读
  10. Vue项目中使用echarts教程

    2024-05-09 14:34:02       15 阅读