当前位置: 首页 > news >正文

jinaai/jina-embeddings-v2-base-zh向量模型报错解决

报错信息
OSError: We couldn’t connect to ‘https://huggingface.co’ to load this file, couldn’t find it in the cached files and it looks like jinaai/jina-bert-implementation is not the path to a directory containing a file named configuration_bert.py.

报错信息简述是连不上huggingface网址,也找不到缓存文件,缺失jinaai/jina-bert-implementation路径的configuration_bert.py文件。

网上也有好多解决的方法,对我来说感觉都太复杂了。
现在提供我的解决思路,非常简单,希望对你有帮助。

解决方法
在使用jinaai/jina-embeddings-v2-base-zh向量模型时,发现会报错信息如上。
此时我们还需要下载这个模型jinaai/jina-bert-implementation。

Huggling Face 下载

# Load model directly
from transformers import AutoTokenizer, AutoModel
model = "jinaai/jina-embeddings-v2-base-zh"
tokenizer = AutoTokenizer.from_pretrained(model , cache_dir="./", trust_remote_code=True)
model = AutoModel.from_pretrained(model , cache_dir="./", trust_remote_code=True)

网不好的使用国内的魔塔下载
jina-bert-implementation模型下载
jina-embeddings-v2-base-zh模型下载
建议手动下载,因为里面有很多而外的文件,速度比较慢。
以上两种方式下载完成后,最后整理一下文件,两个模型最小包含文件如下:
我存放的目录为 /home/jinaai/

/home/jinaai/
├── jina-bert-implementation
│   ├── configuration_bert.py
│   └── modeling_bert.py
└── jina-embeddings-v2-base-zh├── config.json├── merges.txt├── model.safetensors├── special_tokens_map.json├── tokenizer_config.json├── tokenizer.json└── vocab.json

修改jina-embeddings-v2-base-zh模型config.json配置文件,将红色框中的路径换成jina-bert-implementation模型实际的路径即可。

在这里插入图片描述

测试是否成功

from numpy.linalg import norm
import torch
from transformers import AutoModel
from numpy.linalg import normif __name__ == "__main__":path = "/home/jinaai/jina-embeddings-v2-base-zh"cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))model = AutoModel.from_pretrained(path, trust_remote_code=True, torch_dtype=torch.bfloat16)embeddings = model.encode(['How is the weather today?', '今天天气怎么样?'])print(cos_sim(embeddings[0], embeddings[1]))# 打印结果: 0.7868529

完美解决 OSError: We couldn’t connect to ‘https://huggingface.co’ to load this file, couldn’t find it in the cached files and it looks like jinaai/jina-bert-implementation is not the path to a directory containing a file named configuration_bert.py.这个报错,祝你好运~

相关文章:

  • 从 0 到 1:互联网产品经理核心技能全解析
  • php thinkphp 小程序发送订阅模板消息通知
  • 如何给多台Linux机器设置时间同步
  • Power Platform开发小技巧,一天一个APP, 如何快速搭建二维码识别器
  • 深度学习:(五)初识神经网络
  • Git 提交规范
  • 基于PHP+MySQL组合开发地方门户分类信息网站源码系统 带完整的安装代码包以及搭建部署教程
  • 测试用例的举例
  • Xcode 16 上传AppStore遇到第三方库 bitcode 的问题
  • django drf 过滤器
  • 字符编码发展史4 — Unicode与UTF-8
  • 2024 CSP 游记
  • 用Flutter几年了,Flutter每个版本有什么区别?
  • 数据结构与算法——Java实现 20.习题——二叉树层序遍历
  • Iceberg 基本操作和快速入门
  • 《剑指offer》分解让复杂问题更简单
  • Dubbo 整合 Pinpoint 做分布式服务请求跟踪
  • mysql 数据库四种事务隔离级别
  • php ci框架整合银盛支付
  • 从零开始的无人驾驶 1
  • 面试遇到的一些题
  • 如何抓住下一波零售风口?看RPA玩转零售自动化
  • 一加3T解锁OEM、刷入TWRP、第三方ROM以及ROOT
  • 一起参Ember.js讨论、问答社区。
  • 用jQuery怎么做到前后端分离
  • - 转 Ext2.0 form使用实例
  • 正则表达式-基础知识Review
  • ​一帧图像的Android之旅 :应用的首个绘制请求
  • #WEB前端(HTML属性)
  • $.each()与$(selector).each()
  • ()、[]、{}、(())、[[]]等各种括号的使用
  • (0)Nginx 功能特性
  • (4)事件处理——(7)简单事件(Simple events)
  • (c语言+数据结构链表)项目:贪吃蛇
  • (Oracle)SQL优化技巧(一):分页查询
  • (附源码)SSM环卫人员管理平台 计算机毕设36412
  • (六)Hibernate的二级缓存
  • (七)c52学习之旅-中断
  • (五)MySQL的备份及恢复
  • (原创)boost.property_tree解析xml的帮助类以及中文解析问题的解决
  • (原創) X61用戶,小心你的上蓋!! (NB) (ThinkPad) (X61)
  • (轉)JSON.stringify 语法实例讲解
  • .htaccess 强制https 单独排除某个目录
  • .NET Core中的去虚
  • .NET HttpWebRequest、WebClient、HttpClient
  • .NET(C#、VB)APP开发——Smobiler平台控件介绍:Bluetooth组件
  • .NET/C# 中设置当发生某个特定异常时进入断点(不借助 Visual Studio 的纯代码实现)
  • .Net7 环境安装配置
  • .net后端程序发布到nignx上,通过nginx访问
  • .NET开源项目介绍及资源推荐:数据持久层 (微软MVP写作)
  • .Net语言中的StringBuilder:入门到精通
  • .net专家(张羿专栏)
  • .vollhavhelp-V-XXXXXXXX勒索病毒的最新威胁:如何恢复您的数据?
  • 。。。。。
  • @param注解什么意思_9000字,通俗易懂的讲解下Java注解