[Question]: How to solve the problems of local image URL failure and embedding model binding failure

用户在 RAGFlow V0.20.0 中解析含图片的本地 PDF 文件,调用 SILICONFLOW 的 BAAI/bge-large-zh-v1.5 和 bge-m3 模型 API 时失败。同时测试了通义千问(TONGYI)和 Ollama 的嵌入模型,均报告类似错误。

[Question]: How to solve the problems of local image URL failure and embedding model binding failure

[Question]: How to solve the problems of local image URL failure and embedding model binding failure

快速结论:该问题主要发生在 RAGFlow 使用第三方模型 API(如 SILICONFLOW)解析含图片的本地 PDF 时。优先排查本地图片路径是否已转换为 base64 编码,以及硬件显存是否足够承载大模型。

问题场景

用户在 RAGFlow V0.20.0 中解析含图片的本地 PDF 文件,调用 SILICONFLOW 的 BAAI/bge-large-zh-v1.5 和 bge-m3 模型 API 时失败。同时测试了通义千问(TONGYI)和 Ollama 的嵌入模型,均报告类似错误。

报错原文

[ERROR]Error code: 400 - {'code': 20040, 'message': 'Image url should be a valid url or should like data:image/TYPE;base64,YOUR-BASE64-CONTENT', 'data': None}

[ERROR]Fail to bind embedding model: Exceptions from Trio nursery (1 sub-exception)
[ERROR][Exception]: Exceptions from Trio nursery (1 sub-exception) -- Operation timed out after 30 seconds and 2 attempts.

[ERROR]Internal server error while chunking: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Clip node. Name:p2o.Clip.6 Status Message: /onnxruntime_src/onnxruntime/core/framework/bfc_arena.cc:376 void* onnxruntime::BFCArena::AllocateRawInternal(size_t, bool, onnxruntime::Stream*, bool, onnxruntime::WaitNotificationFn) Available memory of 0 is smaller than requested bytes of 79331328

原因分析

1. 本地图片 URL 失败

模型 API 仅接受 HTTP(S) URL 或 base64 编码的数据 URI,直接使用本地文件路径会导致 400 错误。该问题在 Issue #8906 中有修复(合并于 2025-07-18 之后),更新版本后应可通过直接打开本地文件解决。此外,已知本地部署环境中 base64 图片字符串可能被错误拆分为单个字符(形成多个 image_url 对象),而官方演示站点无此问题。正确格式应为每个图片 URL 对象使用一个完整的 base64 字符串。

2. 嵌入模型绑定失败(超时)

默认超时时间(30 秒)不足或并发数过高可能导致 Trio nursery 超时异常。

3. ONNXRuntime 显存溢出

ONNXRuntime 错误通常表明硬件显存不足以处理模型请求(请求 79MB 但可用显存为 0)。

环境排查

  • 确认 RAGFlow 版本:推荐更新至 2025-07-18 之后发布的版本(包含 #8906 修复)。
  • 检查硬件显存:确保 GPU 可用显存大于 79331328 字节(约 76MB)。
  • 检查部署模式:本地部署 vs. 官方 demo 站点(base64 分割问题仅出现在本地部署)。
  • 确认使用的嵌入模型是否支持 base64 图片输入(部分 API 对非 HTTP 图片路径回报 400)。

解决步骤

  1. 更新 RAGFlow 版本:确保版本已包含 PR #8906 的修复(2025-07-18 后合并),避免本地图片路径被错误传入模型 API。
  2. 处理图片编码:在调用模型 API 前,将本地图片转换为 base64 编码的 data URI 格式,格式为 data:image/{TYPE};base64,{BASE64_CONTENT}
  3. 调整超时和并发参数:可优先尝试增大环境变量 LM_TIMEOUT_SECONDS(例如设置为 60 秒),同时降低 GRAPH_EXTRACTOR_MAX_WORKERS 减少并发任务数。
  4. 禁用高资源消耗功能:关闭 reranker、RAPTOR、auto-keywords、auto-questions 等附加功能以减少资源占用。
  5. 优化模型部署:如果使用自有模型可尝试采用 vLLM 部署;确保嵌入模型运行在 GPU 而非 CPU 上。
  6. 更换或缩容模型:如果硬件显存不足(如出现 ONNX 零内存错误),可选择更小尺寸的嵌入模型或升级硬件。

验证方法

重新执行含图片的本地 PDF 解析任务,观察日志中是否仍输出 400 错误、“Operation timed out”或“Available memory of 0”等异常。若解析成功且嵌入模型绑定正常,则问题解决。

参考来源

infiniflow/ragflow #9470

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 14761

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注