RAG and data · 2026-09-22
Lowering repeated document template cost on Qwen-VL-OCR with cache
Different from version/region selection and invoice-table validation, this covers how cache support lowers cost when processing the same document template repeatedly (a fixed instruction or form structure).
Same OCR model, a different question
The Qwen-VL-OCR API version and region selection article covers correct setup, and the invoice and table reading article covers validating missing fields. This article focuses on a third question: how do you keep cost low when processing the same document template (a fixed form structure or a standard invoice layout, for example) at high volume?
Qwen-VL-OCR's catalog page carries cache support; that support gains value less in processing a single image and more in a batch workflow processing many images in sequence with the same instruction and template structure.
Serving the fixed instruction from cache
An OCR request usually has two parts: a fixed instruction that stays the same on every request (for example, 'extract amount, date, and vendor name from this invoice, conform to this JSON schema') and the image content that changes per request. When the fixed instruction part is kept at the start of the request and resent as-is, the cache processes that part at the cache-read price rather than the full price; since only the image changes, most of the total cost still comes from the image, but the fixed text's share drops.
For a batch job processing hundreds or thousands of similar documents with the same template, that difference adds up; the gain is more noticeable when the instruction text is long and detailed (many field definitions, an example output shape).
- Keep the fixed instruction at the start of the request and repeat it identically on every request.
- Let only the image content change; keep the instruction text fixed.
- The gain is more noticeable with a long instruction text and high batch volume.
The cache advantage resets if the template changes
The cache requires a prefix that overlaps with a previous request; if you write the instruction text differently for each document type (one instruction for invoices, another for forms), each template builds its own cache history separately. In a pipeline processing many different document types, using each type's fixed instruction consistently maximizes cache hit rate.
Frequently asked questions
Does the cache also make image content cheaper?
The cache works for a prefix that exactly overlaps a previous request; image content that changes on every request normally doesn't benefit from the cache — only the fixed instruction portion does.
Does the cache make a difference on a one-off OCR request?
No, since writing to cache carries a cost, a one-off request sees no gain. The benefit shows up in batch jobs where the same template is reused across many requests.