RAGEngineering Hub
Chapter 3 · concept 3 of 6 · show all
  1. 1What RAG is, and why
    1. 1.1Why models need outside knowledge, and what hallucination means
    2. 1.2What RAG is: anatomy of a request
    3. 1.3RAG vs fine tuning vs long context and prompt caching
    4. 1.4Use cases and the quality, latency and cost triangle
    5. Chapter overview
  2. 2Tokens, cost and your first RAG
    1. 2.1Tokens and context windows for RAG
    2. 2.2The RAG lifecycle and your first RAG in miniature
    3. Chapter overview
  3. 3Getting documents in
    1. 3.1Content sources and file formats
    2. 3.2Parsing, layout and OCR
    3. 3.3Tables, images and mixed content
    4. 3.4Cleaning, normalization and quality gates
    5. 3.5Metadata, document identity and versioning
    6. 3.6Updates, deletes, reindexing and ingestion pipelines
    7. Chapter overview
  4. 4Chunking
    1. 4.1Why we chunk, and the main chunking strategies
    2. 4.2Structure aware chunking and tables
    3. 4.3Chunk size, overlap and token based sizing
    4. 4.4Contextual chunking and late chunking
    5. 4.5Parent child and multi representation indexing
    6. 4.6Chunk metadata, provenance and the chunking debugging playbook
    7. Chapter overview
  5. 5Embeddings
    1. 5.1Embeddings and similarity from first principles
    2. 5.2What embeddings cannot do
    3. 5.3Choosing an embedding model: size, cost, language
    4. 5.4Embedding model migration and index rebuilds
    5. Chapter overview
  6. 6Vector stores and scores
    1. 6.1Vector databases, ANN indexes and choosing a store
    2. 6.2Score calibration and thresholds
    3. 6.3Late interaction and multivector retrieval
    4. Chapter overview
  7. 7Finding the right chunks
    1. 7.1Query understanding, rewriting and expansion
    2. 7.2Dense retrieval and keyword search with BM25
    3. 7.3Hybrid retrieval and rank fusion
    4. 7.4topK, no good match, and metadata filtering
    5. 7.5Routing, diversity, deduplication and caching
    6. 7.6Reranking: two stage, cross encoder and LLM rerankers
    7. Chapter overview
  8. 8When retrieval fails
    1. 8.1Retrieval failure analysis playbook
    2. Chapter overview
  9. 9Building the answer
    1. 9.1Context selection, packing and citations
    2. 9.2Grounding prompts and abstention
    3. 9.3Lost in the middle and context management
    4. 9.4Conflicts, staleness and freshness rules
    5. 9.5Hallucination checks and answer verification
    6. 9.6Conversational RAG, answer UX and RAG APIs
    7. Chapter overview
  10. 10Measuring
    1. 10.1Why measure, and what to measure
    2. 10.2Building a golden dataset
    3. 10.3Retrieval metrics: precision, recall, MRR, nDCG
    4. 10.4Faithfulness and answer correctness
    5. 10.5LLM as judge, and judging the judge
    6. 10.6Offline and online evals, regression tests and slices
    7. Chapter overview
  11. 11Safety and operations
    1. 11.1Prompt injection and poisoned documents
    2. 11.2Access control, privacy and governance
    3. 11.3Index lifecycle operations
    4. 11.4Observability and tracing
    5. 11.5Latency, cost, caching and model routing
    6. 11.6Reliability, degraded modes and launch readiness
    7. Chapter overview
  12. 12Scale and advanced RAG
    1. 12.1Scaling, multi tenancy and enterprise architecture
    2. 12.2Choosing an architecture: naive, advanced, agentic, graph
    3. 12.3Agentic RAG and RAG as an MCP tool
    4. 12.4GraphRAG, structured data and multimodal RAG
    5. Chapter overview

Tables, images and mixed content

How to turn tables, charts and images into text that search can find and a model can read correctly, and why tables deserve their own tests.

A real question

Why does the assistant quote the wrong number from a table?

Because the row reached it without its header, or cut in half. A number only means something next to its column name.

The problem

Why this matters

A table is just text. The model will work out which number is which.
The belief

A table is just text. The model will work out which number is which.

Without the header row, “60.5% | 61.9%” could be any two years. Tables need their header with every row, and images need a caption to be searchable at all.
What really happens

Without the header row, “60.5% | 61.9%” could be any two years. Tables need their header with every row, and images need a caption to be searchable at all.

Why not the simpler way

The simple way treats a table like any paragraph. The parser often flattens it into one line of numbers, the chunker may cut it in half, and the model then reads "2024 61.2 58.9" with no idea which number is which. Images are worse: a chart or diagram with the key fact becomes nothing at all, because search only sees text.

The idea

The idea in plain words

Give every non-prose element a text form that keeps its meaning. A table keeps its header with every row, or becomes one short sentence per row. A chart gets a description of what it shows and its key values. An image or diagram gets a caption, ideally written by a person or a vision model, and the caption is what gets indexed.

A good museum audio guide describes the painting, so you understand it even with your eyes closed.

How it works

Step by step

  1. If a table fits in one chunk, keep it in one chunk, with the heading above it.
    1

    Keep small tables whole

    If a table fits in one chunk, keep it in one chunk, with the heading above it.

  2. Cut only between rows, and copy the header row into every part.
    2

    Split big tables by rows

    Cut only between rows, and copy the header row into every part.

  3. Search reads text only. A chart with the key fact needs a written caption, linked to the image.
    3

    Give images a caption

    Search reads text only. A chart with the key fact needs a written caption, linked to the image.

In detail

Tables. Keep small tables whole as markdown. For large tables, split between rows and repeat the header, or render each row as "column: value" pairs. Keep the table's title and the section heading with it. For numeric tables that users query by value ("which product costs under 20 euro?"), also load them into a database and answer those questions with a query.

Images and charts. Extract them with their position, write or generate a caption, and index the caption with a link back to the image. If a vision model writes captions, check a sample, because a wrong caption is a confident wrong fact.

Mixed pages. Keep the order: a caption belongs next to the paragraph that refers to it.

The same document of headings, paragraphs and a table cut three ways: a fixed window cuts every N tokens and can go through the table; recursive splitting cuts at paragraph breaks; splitting by headings makes one chunk per section.Fixed windowevery N tokenscut through the tableRecursiveparagraph, line, sentenceBy headingsone section per chunkheading · paragraph · paragraph · table · heading · paragraph · paragraph
A fixed window ignores the structure. Recursive and heading-based splitting move the cuts to places where the text already breaks.

The code

Try it in Python

def rows_as_text(header: list[str], rows: list[list[str]], title: str = "") -> list[str]:
    """One self-contained line per row: every value keeps its column name."""
    prefix = f"{title}: " if title else ""
    return [prefix + ", ".join(f"{h} {v}" for h, v in zip(header, row)) for row in rows]

print(rows_as_text(["Code", "Meaning", "Cause"],
                   [["E4012", "Mesh pairing failed", "Mesh extender on old firmware"]],
                   title="FiberBox error codes"))

See it

What we measured

Measured · table questions with the answer passage in the top 3

The 8 golden questions answered from a markdown table, vector search, bge-small-en-v1.5. The corpus has no images.

Golden questions answered from a table-8 of 47
Fixed 128 tokens (2 tables cut in half)baseline5 of 8
Recursive 512 tokens5 of 88 of 8

Measured 2026-11-03. Not measured yet. Planned: render each table row as 'column: value' sentences, re-embed, and compare with the markdown form on these 8 questions; add an image with a caption to test captions.

Try it on a real example

A real question: “What was the cost to income ratio in 2024?”

Chunking

Polder Bank annual report · end of chunk 2

| Item | 2025 | 2024 | Change | … | Net profit | 412 | 365 | +12.9% |
| Cost to

Start of chunk 3

income ratio | 60.5% | 61.9% | -1.4 pt |
| Return on equity | 9.1% | 8.4% | +0.7 pt |

The row is cut inside a cell, and chunk 3 has no header. Nothing says that 61.9% is the 2024 value.

Choosing

Use it when, avoid it when

Use it when
  • Small tables whole, large tables split by rows with the header repeated
  • Captions for every image or chart that carries a fact
Avoid it when
  • Tables flattened into one line of numbers
  • Indexing images without any text form

What it costs · Table handling needs a parser that detects tables. Captions need a person or a vision model call per image, once per document version.

In production

Tag every table question in your golden set and report its score separately; table failures hide inside an overall number. Keep the original table or image next to its text form, so the answer can show the real thing. Review generated captions like any other content: they are part of your knowledge base now.

Watch out

Common mistakes

  • The model will work out the table. Only if the header and the row arrive together.
  • Images do not matter for RAG. If a fact is only in a chart, it does not exist for search until it has a caption.
  • Tables are rare. In this corpus, one question in six depends on one.

Check yourself

Remember this

Remember these

  • Every table row needs its column names to mean anything.
  • Keep tables whole, or split between rows and repeat the header.
  • Images and charts need a caption before search can find them.
  • Here, 128 token chunks cut 2 tables in half; 512 token chunks cut none.

Say it in an interview

  1. 01Tables, charts and images need a text form that keeps their meaning before indexing.
  2. 02Table rows always carry their column names, or the numbers mean nothing.
  3. 03On my corpus 8 of 47 questions depend on a table; fixed 128 cut 2 tables in half.
  4. 04Images get a caption, and I review generated captions like any other content.
  5. 05I score table questions separately so their failures do not hide in the average.

Quick quiz

Three questions

Question 1

Q1

How many of the 47 Polder golden questions are answered from a table?

Question 2

Q2

What is the safest text form of a table row for retrieval?

Question 3

Q3 · from RAG-08

Which parsing step decides whether a table survives at all?

Saved on this device. No account needed.