结合图像与表格的多模态 RAG
将 RAG 从纯文本扩展到图像、图表和结构化表格的检索与推理。
结合图像与表格的多模态 RAG 是 CoddyKit 上的免费 LangChain / RAG / Vector DBs 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 LangChain / RAG / Vector DBs 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 LangChain / RAG / Vector DBs 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Beyond Plain Text
Real documents contain images, charts, and tables. Multimodal RAG indexes and retrieves these non-text elements so the model can answer questions that depend on them.
What Counts as Multimodal
Multimodal sources include scanned pages, diagrams, screenshots, photos, and spreadsheet-style tables embedded in PDFs or web pages.
- Images
- Charts and figures
- Tables
Strategy 1: Describe Then Embed
Use a vision model to generate a text description of each image, then embed the description with your normal text embeddings. Retrieval stays text-based.
caption = vision_model.describe(image)
store.add_texts([caption], metadatas=[{"image": image_id}])Strategy 2: Multimodal Embeddings
Models like CLIP embed images and text into the same vector space, so a text query can directly match an image without a caption step.
Handling Tables
Tables lose meaning when flattened. Preserve structure by converting each table to Markdown or HTML before chunking so rows and headers stay linked.
table_md = "| Year | Revenue |\n|---|---|\n| 2024 | 10M |\n| 2025 | 12M |"
store.add_texts([table_md], metadatas=[{"type": "table"}])Summarizing Large Tables
For wide or long tables, store both a natural-language summary (for retrieval) and the raw table (for the answer), linking them by id.
Routing by Modality
At query time, detect what the question needs. A request about a chart should retrieve image elements; a numeric lookup should target tables.
Passing Images to the LLM
Multimodal LLMs accept images directly in the prompt. After retrieving the relevant image, include it alongside the question for grounded reasoning.
messages = [{"role": "user", "content": [
{"type": "text", "text": "What trend does this chart show?"},
{"type": "image_url", "image_url": {"url": img_url}},
]}]Citing Visual Sources
Track which image or table produced an answer in metadata, so you can show the user the exact figure or table the model relied on.
Cost and Latency
Vision calls and image embeddings cost more than text. Cache captions, downscale images, and only invoke vision when the query truly needs it.
Putting It Together
Extract images and tables during loading, index them via captions or multimodal embeddings, route queries by modality, and feed the right element to a multimodal LLM.
Quick Check
Test your understanding of multimodal RAG.
Recap
You extended RAG to multiple modalities:
- Describe-then-embed or multimodal embeddings for images
- Preserve table structure as Markdown
- Route queries by modality
- Feed images to a multimodal LLM and cite visual sources
常见问题解答
「结合图像与表格的多模态 RAG」课时是免费的吗?
是的 — 「结合图像与表格的多模态 RAG」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 LangChain / RAG / Vector DBs 课程的其余内容,请升级到 CoddyKit PRO。 LangChain / RAG / Vector DBs 课程共包含 4 节课。
「结合图像与表格的多模态 RAG」这节课中我会学到什么?
将 RAG 从纯文本扩展到图像、图表和结构化表格的检索与推理。 你通过在浏览器中直接运行的动手代码来练习 LangChain / RAG / Vector DBs,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 LangChain / RAG / Vector DBs 需要有经验吗?
无需任何先前经验。CoddyKit 上的 LangChain / RAG / Vector DBs 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。
「结合图像与表格的多模态 RAG」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 LangChain / RAG / Vector DBs 课中编写并运行代码吗?
能。每节 LangChain / RAG / Vector DBs 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- 用于代码生成与辅助的 RAG
- 构建实时 RAG 系统
- RAG 的新兴趋势与研究
- 结合图像与表格的多模态 RAG