How Small Table Numbers Fail in Vision Models and How Tiling Resolution Affects Accuracy
Vision-language models (VLMs) convert images into fixed-size visual patches or tokens before reasoning, so dense spreadsheets, dashboards, or screenshots with tiny fonts lose fine stroke detail whenever downscaling compresses a character below a few pixels.
- Downscaling blurs visually similar digits: Similar glyphs (
3,8,5,6,9, or decimal points and commas) collapse into ambiguous pixel blobs when a wide desktop screenshot is shrunk to fit encoder resolution limits. - Row and column misalignment: In wide, low-contrast, or borderless tables, narrow row/column spacing makes it easy for attention heads to shift a number by one column or row even when individual digits look readable.
- Image tiling resolution vs. global context trade-off: Splitting large images into higher-resolution tiles (or requesting high/original detail) preserves crisp character strokes and sharpens small-number accuracy. However, excessive tiling without a global view can split tables across tile borders or fragment row/column headers, while adding many high-res tiles increases visual token count, cost, and latency.
- Language model completion bias: Unlike dedicated OCR engines that transcribe characters strictly from pixels, VLMs predict tokens conditioned on surrounding text and numbers, which can cause plausible-looking approximations when visual evidence is noisy.
Steps to Improve Small Table Number Accuracy with Tiling and Resolution
- Preserve native resolution before encoding: Avoid resizing screenshots down on the client before upload, and request high/original image detail on vision calls when reading small or dense tables.
- Crop or tile around the table region with overlap: Isolate dense tables from surrounding chrome or slice wide tables into overlapping horizontal/vertical tiles with column headers repeated or visible so numbers are not cut mid-cell or detached from headers.
- Retain a lower-resolution overview alongside high-res crops: Keep overall table/page structure visible so the model maps each cropped cell back to its exact row label and column header.
- Enforce structured schemas and verify critical totals: Extract rows/columns into a strict schema (
temperature: 0), and cross-check subtotals/sums or pair with OCR/bounding-box verification when financial or metric accuracy is critical.
TypeScript Example: Tiling Dense Table Screenshots with Overlap and High-Detail Vision Calls
import sharp from "sharp";
import OpenAI from "openai";
const openai = new OpenAI();
interface TableTile {
index: number;
base64Png: string;
}
export async function buildOverlappingTiles(
imageBuffer: Buffer,
tileWidth = 1024,
tileHeight = 1024,
overlapPx = 128
): Promise<TableTile[]> {
const meta = await sharp(imageBuffer).metadata();
const width = meta.width ?? tileWidth;
const height = meta.height ?? tileHeight;
const stepX = Math.max(1, tileWidth - overlapPx);
const stepY = Math.max(1, tileHeight - overlapPx);
const tiles: TableTile[] = [];
let index = 0;
for (let top = 0; top < height; top += stepY) {
const extractHeight = Math.min(tileHeight, height - top);
for (let left = 0; left < width; left += stepX) {
const extractWidth = Math.min(tileWidth, width - left);
const croppedPng = await sharp(imageBuffer)
.extract({ left, top, width: extractWidth, height: extractHeight })
.png()
.toBuffer();
tiles.push({
index: index++,
base64Png: croppedPng.toString("base64"),
});
if (left + extractWidth >= width) break;
}
if (top + extractHeight >= height) break;
}
return tiles;
}
export async function extractTableFromTiles(
imageBuffer: Buffer,
question: string
): Promise<string> {
const tiles = await buildOverlappingTiles(imageBuffer);
const imageContent: OpenAI.Chat.Completions.ChatCompletionContentPart[] = tiles.flatMap(
(tile) => [
{ type: "text", text: `Tile ${tile.index}:` },
{
type: "image_url",
image_url: {
url: `data:image/png;base64,${tile.base64Png}`,
detail: "high",
},
},
]
);
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
temperature: 0,
messages: [
{
role: "system",
content:
"Read small numbers and table cells strictly from the provided tiles without guessing blurred digits. Preserve exact row and column alignment.",
},
{
role: "user",
content: [{ type: "text", text: question }, ...imageContent],
},
],
});
return response.choices[0]?.message.content ?? "";
}
Helpful Tips for High-Resolution Table Pipelines
- Cap tile counts to control token cost and latency: High-detail tiles multiply input image tokens rapidly across multi-tile requests; tile only detected table regions rather than full blank margins or decorative UI.
- Convert PDFs to crisp PNGs at sufficient DPI before tiling: Render PDF pages at ~200–300 DPI rather than low-DPI thumbnails so fine numeric characters start with clean pixel edges.
- Route high-stakes numerical tables to specialized parsers or dual-pass checks: For accounting, invoices, or dense financial tables, combine VLM structural extraction with deterministic OCR/layout tools or arithmetic checks on row/column totals.
You must log in or register to comment.
