面包屑图标 当前位置: 首页
AI资讯
热点详情

多模态模型在RagFlow中的深度应用实践

AI热点日报
AI热点日报时间:2026-07-13
热点解读

RagFlow0 19 0引入多模态模型(image2text)增强文档图片解析。配置需在租户下激活模型并确保数据库字段正确。三大应用场景:PDF逐字OCR转录、deepdoc解析中图表增强提取结构化数据、直接上传图片的智能描述。注意租户表img2txt_id字段可能为空需手动修复。

RagFlow 0.19.0 多模态模型使用教程:全面提升文档图片解析能力

RagFlow 0.19.0 版本正式引入了 多模态模型(image2text),旨在显著增强对文档中各类图片内容的解析效果。本教程将系统介绍该功能的配置方法、三大核心应用场景及关键注意事项,帮助您充分利用多模态模型提升数据提取的质量与效率。

一、配置 image2text 模型

在正式使用之前,您需要先在当前租户环境下完成 image2text 模型的配置。具体操作步骤如下:

  • 进入 RagFlow 的模型管理界面,创建或选择一个支持 image2text 能力的模型(例如 GPT-4o、Qwen-VL 等)。
  • 确认该模型已在当前租户下成功激活并处于可用状态。

注意: 一个常见问题是:即便模型已配置完毕,部分环境下 租户表中的 img2txt_id 字段可能仍为空,这将导致图表增强解析功能无法自动启用。如果遇到此情形,请手动修改 tenant 表,将字段值设置为已创建的 image2text 模型名称。

小提示: 如果您是从旧版本升级而来,建议检查数据库中的 tenant 表,确认 img2txt_id 字段是否已正确填充。

二、三大核心应用场景

成功配置 image2text 模型后,它将自动参与以下三个场景的解析流程,显著提升图片信息提取能力:

1. PDF 文档内容提取

在知识库配置页面中,PDF 解析器除了原有的 deepdocnaive 选项外,还会同步显示您配置的 image2text 模型名称。选择该模型后,解析流程如下:

  • 将 PDF 文档的每一页逐一转换为图片格式。
  • 调用 image2text 模型从图片中精准提取文本内容。
  • 对提取结果进行分词等后续处理操作。

注意: 该过程仅执行 OCR 级别的逐字转录,不会像 deepdoc 那样对格式、表格进行深度解析。使用的提示词如下:

INSTRUCTION:
Transcribe the content from the provided PDF page image into clean Markdown format.
- Only output the content transcribed from the image.
- Do NOT output this instruction or any other explanation.
- If the content is missing or you do not understand the input, return an empty string.

RULES:
1. Do NOT generate examples, demonstrations, or templates.
2. Do NOT output any extra text such as 'Example', 'Example Output', or similar.
3. Do NOT generate any tables, headings, or content that is not explicitly present in the image.
4. Transcribe content word-for-word. Do NOT modify, translate, or omit any content.
5. Do NOT explain Markdown or mention that you are using Markdown.
6. Do NOT wrap the output in ```markdown or ``` blocks.
7. Only apply Markdown structure to headings, paragraphs, lists, and tables, strictly based on the layout of the image. Do NOT create tables unless an actual table exists in the image.
8. Preserve the original language, information, and order exactly as shown in the image.

当前局限: 提示词主要将多模态模型作为高级 OCR 使用,尚未充分发挥其深层推理能力。此外,使用 image2text 模型解析 PDF 时,切片结果中 不会存储对应的图片信息,导致检索时只能获取文本,无法返回图片。这是未来可优化的方向。

2. 文档中图表信息的智能提取

这是最实用的功能之一。当 PDF 解析器使用 deepdoc 且存在 image2text 模型时,系统会自动识别文档中的各类图表(如柱状图、折线图、表格等),并调用多模态模型进行增强解析。具体流程如下:

  • deepdoc 解析器将文档拆分为普通章节、表格和图表三类元素。
  • 图表部分提交给 VisionFigureParser,使用 image2text 模型提取结构化数据。
  • 提取结果与表格合并,进行后续处理。

相关代码片段:

if layout_recognizer == "DeepDOC":
    pdf_parser = Pdf()
    try:
        vision_model = LLMBundle(kwargs["tenant_id"], LLMType.IMAGE2TEXT)
        callback(0.15, "Visual model detected. Attempting to enhance figure extraction...")
    except Exception:
        vision_model = None
    if vision_model:
        sections, tables, figures = pdf_parser(filename if not binary else binary, from_page=from_page, to_page=to_page, callback=callback, separate_tables_figures=True)
        callback(0.5, "Basic parsing complete. Proceeding with figure enhancement...")
        try:
            pdf_vision_parser = VisionFigureParser(vision_model=vision_model, figures_data=figures, **kwargs)
            boosted_figures = pdf_vision_parser(callback=callback)
            tables.extend(boosted_figures)
        except Exception as e:
            callback(0.6, f"Visual model error: {e}. Skipping figure parsing enhancement.")
            tables.extend(figures)
    else:
        sections, tables = pdf_parser(filename if not binary else binary, from_page=from_page, to_page=to_page, callback=callback)
    res = tokenize_table(tables, doc, is_english)
    callback(0.8, "Finish parsing.")

图表增强的提示词如下:

You are an expert visual data analyst. Analyze the image and provide a comprehensive description of its content. Focus on identifying the type of visual data representation (e.g., bar chart, pie chart, line graph, table, flowchart), its structure, and any text captions or labels included in the image.

Tasks:
1. Describe the overall structure of the visual representation. Specify if it is a chart, graph, table, or diagram.
2. Identify and extract any axes, legends, titles, or labels present in the image. Provide the exact text where a vailable.
3. Extract the data points from the visual elements (e.g., bar heights, line graph coordinates, pie chart segments, table rows and columns).
4. Analyze and explain any trends, comparisons, or patterns shown in the data.
5. Capture any annotations, captions, or footnotes, and explain their relevance to the image.
6. Only include details that are explicitly present in the image. If an element (e.g., axis, legend, or caption) does not exist or is not visible, do not mention it.

Output format (include only sections relevant to the image content):
- Visual Type: [Type]
- Title: [Title text, if a vailable]
- Axes / Legends / Labels: [Details, if a vailable]
- Data Points: [Extracted data]
- Trends / Insights: [Analysis and interpretation]
- Captions / Annotations: [Text and relevance, if a vailable]

Ensure high accuracy, clarity, and completeness in your analysis, and includes only the information present in the image. A void unnecessary statements about missing elements.

效果对比:

  • 未开启图表增强:仅提取图片中的文字,如“2012年售价走势图 120 103 100 S0 60 40 一销售价格 平均价格 最大最小 20 1月 2月 3月4月5月6月 7月8月 9月10月11月12月”。
  • 开启后:能完整提取坐标轴、图例、数据点、趋势分析等,例如:
    - Visual Type: Line Graph - Title: 2012年售价走势图 - Axes / Legends / Labels: ...

小提示: 如果图表增强解析未生效,请检查数据库 tenant 表是否包含正确的 img2txt_id。手动修改后重启服务即可。

3. 图片文件的深度解析

对于直接上传的图片文件(如 JPEG、PNG),RagFlow 也会自动利用多模态模型提升解析效果。核心逻辑位于 rag/app/picture.py

def chunk(filename, binary, tenant_id, lang, callback=None, **kwargs):
    img = Image.open(io.BytesIO(binary)).convert('RGB')
    doc = {
        "docnm_kwd": filename,
        "title_tks": rag_tokenizer.tokenize(re.sub(r".[a-zA-Z]+$", "", filename)),
        "image": img,
        "doc_type_kwd": "image"
    }
    // 首先使用OCR提取文字
    bxs = ocr(np.array(img))
    txt = "n".join([t[0] for _, t in bxs if t[0]])
    eng = lang.lower() == "english"
    callback(0.4, "Finish OCR: (%s ...)" % txt[:12])
    # 如果OCR提取的文字超过32个字符,则不再调用多模态模型(提升性能)
    if (eng and len(txt.split()) > 32) or len(txt) > 32:
        tokenize(doc, txt, eng)
        callback(0.8, "OCR results is too long to use CV LLM.")
        return [doc]
    try:
        callback(0.4, "Use CV LLM to describe the picture.")
        cv_mdl = LLMBundle(tenant_id, LLMType.IMAGE2TEXT, lang=lang)
        img_binary = io.BytesIO()
        img.sa ve(img_binary, format='JPEG')
        img_binary.seek(0)
        # 通过大模型对图片进行描述,无额外提示词
        ans = cv_mdl.describe(img_binary.read())
        callback(0.8, "CV LLM respond: %s ..." % ans[:32])
        txt += "n" + ans
        tokenize(doc, txt, eng)
        return [doc]
    except Exception as e:
        callback(prog=-1, msg=str(e))
    return []

工作流程:

  • 首先对图片进行 OCR 提取文字信息。
  • 如果 OCR 结果足够长(超过32个字符),则直接返回结果,不再调用大模型以节省资源。
  • 否则,调用 image2text 模型对图片进行描述,并将描述结果与 OCR 文字合并。

注意: 此场景下大模型没有预设提示词,模型会自由描述图片内容,这对于缺乏文字信息的图片(如照片、示意图等)尤其实用。

三、常见问题与解答

Q1:为什么配置了 image2text 模型,但 PDF 解析时没有出现该选项?

A:请确认模型类型为 IMAGE2TEXT,且已在当前租户下成功激活。此外,检查数据库 tenant 表中的 img2txt_id 字段是否已正确设置。

Q2:图表增强解析后,结果中为什么没有图片?

A:目前使用 image2text 模型解析 PDF 时,切片不会保存图片信息。这与其他解析器(如 deepdoc)的行为不同,是已知的局限性,后续版本可能会进行优化。

Q3:图片文件解析时,OCR 文字过长会不会导致信息丢失?

A:当 OCR 文字超过32个字符时,系统认为已获得足够信息,不再调用大模型。这样做是为了提高性能,但如果图片包含复杂图表或隐含信息,建议手动调整阈值或使用其他解析方式。

Q4:多模态模型解析效果如何?

A:对于图表类图片,效果提升明显,能准确提取结构和数据。对于纯文本图片,效果等同于 OCR。对于无文字图片(如风景照),能够生成描述性文本。但受限于提示词设计,尚未充分发挥大模型的推理能力,未来仍有优化空间。

四、总结与展望

RagFlow 0.19.0 引入多模态模型,为文档图片解析带来了实质性提升。通过 PDF 全文提取、图表增强、图片描述 三个场景,有效解决了以往难以提取图片信息的痛点。尽管当前仍存在性能瓶颈、提示词设计不足等问题,但随着多模态大模型(如 3B、7B 参数级别)的快速发展,端到端的图片语义索引和检索将成为未来 RAG 领域的主流方向。建议您在实际使用中根据数据量大小权衡性能与效果,并持续关注后续版本的功能优化。

热点追踪提示词
你是一名 AI 行业编辑,请围绕下面这条热点输出一份资讯解读:
热点:多模态模型在RagFlow中的深度应用实践要求:
1. 先用一句话解释这条热点在讲什么
2. 再总结它为什么重要
3. 说明会影响哪些 AI 产品或内容方向
4. 最后给出 3 个适合资讯站使用的标题
来源:https://www.53ai.com/news/MultimodalLargeModel/2025060550937.html
ai 人工智能

游乐网为非赢利性网站,所展示的游戏/软件/文章内容均来自于互联网或第三方用户上传分享,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系youleyoucom@outlook.com。

相关热点
AI热点2026-07-13 18:56
AiLuvio实时AI翻译平台,高效准确专业在线翻译服务

实时AI视频通话翻译平台AiLuvio支持30多种语言,让不同母语者各说各话却能相互理解,适用于商务谈判、客户支持和私人聊天。用户可在浏览器免费体验或下载移动端应用,提供实时配音、聊天翻译、群组通话、加密通信等核心功能,价格亲民且门槛低。

AI热点2026-07-13 18:56
百度文心大模型4.0 Turbo限时免费体验上线

近日百度发布文心大模型4 0Turbo版,回复速度大幅提升,生成千字长文仅需二十多秒,在信息获取、专业知识问答和代码开发等方面表现极其优异,功能全面且性能卓越,现于文心一言官网限时免费开放体验。

AI热点2026-07-13 18:56
Figma被指抄袭苹果设计 下架Make Designs功能

Figma推出的生成式AI工具MakeDesigns因生成的界面与苹果iOS天气应用高度相似而下架。问题在于模型可变性太低,且依赖GPT-4等第三方模型。Figma承诺在重新上线前采取额外预防措施,并考虑训练自有模型以避免侵权。

AI热点2026-07-13 18:56
人工智能生成电影一站式创作观看分享平台

什么是AIflixhub? 简单来说,AIflixhub将人工智能与电影制作深度融合。它提供从脚本编写、视觉设计到最终成片的全套AI驱动工具,用户可以在其中创建、探索和分享AI电影。具体功能涵盖AI视频生成、AI音轨制作、AI音效合成等。平台的目标十分明确:让创作者借助AI赋能的工作流,将脑海中的电

延伸阅读