Apply to my task
arXiv:2607.22723 ★ 77 Jul 22, 2026

Classification-Guided Prompting: Figure Out the Task Type First, Then Give a Narrow Prompt Built Just For It

Key result

Discovery: a single prompt with rules for all 16 document types at once performs worse than 16 separate narrow instructions. The model wastes attention on rules that don't even apply to the current document. Classification-Guided Prompting enables automatic data extraction from a mixed batch of different papers — invoices, delivery notes, acceptance certificates — without manual sorting and without one bloated one-size-fits-all prompt. First, the model quietly identifies the document type, then receives only the relevant slice of rules — common formatting plus 2-4 examples tailored to that specific type. The other 15 rule sets simply don't enter the picture.

TL;DR

This method splits data extraction into two steps: first the model identifies the document type (e.g., "invoice" or "contract"), then it gets a narrow prompt built specifically for that type — only the relevant fields and 2-4 examples, with no instructions for all the other types cluttering things up. Instead of one giant "one-size-fits-all" prompt, the model works with a clean, focused rule set.

When a prompt packs in instructions for 16 different document types at once, the model's attention gets spread thin across relevant and irrelevant parts alike. It sees rules for types that don't even appear in this particular document, and that gets in the way of accurately extracting the fields it actually needs — formats get mixed up, details slip through, and error rates climb. The authors call this "attention dilution": the more clutter in the prompt, the weaker the signal from the instruction that actually matters.

The method fixes this by classifying before extraction: first have the model identify the task type from a predefined list, then assemble (or have the model assemble) a prompt using only the rules relevant to that specific type. The model gets a narrow, purpose-built context instead of an all-you-can-eat buffet of instructions.


Method Blueprint

STEP 1: Classify the document/task type → a type label (e.g., "Invoice")
STEP 2: Assemble a prompt for that type: general format rules + fields specific to this type + 2-4 examples → finished prompt
STEP 3: Have the LVLM extract data using the assembled prompt and the image → structured JSON

In the original setup, steps 1 and 2 are handled by separate systems (a classifier + a templating engine). In a regular chat, it's easier to combine them into a single request, where the model first determines the type "internally" and then applies only the relevant block of rules.


Example in Action

Task: A small business owner receives a mixed bag of documents from vendors — service reports, invoices, bills of lading, delivery notes — and wants to use ChatGPT/Claude with photo uploads to automatically pull key data into a spreadsheet, without manual entry.

Prompt:

You are a document-processing specialist.

STEP 1 — Identify the document type in the photo from this list:
- Invoice
- Service Completion Report
- Universal Transfer Document (UTD)
- Delivery Note
Don't write an explanation, just determine the type and move to step 2.

STEP 2 — Extract the data using the rules below.

General rules for all types:
- Output clean JSON only, no comments
- Dates in "year-month-day" format
- If a field is missing or unreadable, write "not determined"
- Extract ONLY the fields listed for the type identified in step 1

Type-specific rules (use only the ones matching the identified type):

Type "Invoice": extract these fields — invoice number, date, vendor, amount, VAT
Sample output: {"number": "145", "date": "2024-03-11", "vendor": "Acme Corp", "amount": "45000", "vat": "7500"}

Type "Service Completion Report": extract these fields — report number, date, contractor, client, list of services, amount
Sample output: {"number": "22", "date": "2024-02-01", "contractor": "John Smith Contracting", "client": "Acme Corp", "services": "equipment installation", "amount": "80000"}

[add similar blocks for UTD and Delivery Note]

Document to analyze: [attach photo]

Result: The model first determines the document type within its response (or silently, if you ask it not to show that step), then outputs clean JSON containing only the fields relevant to that type — with no attempt to cram in fields from other document categories.


Why This Works

When rules for several task types are jumbled together in one prompt, the model spreads its attention across the entire instruction text — including parts that have nothing to do with the current document. That weakens the "signal" coming from the rules that actually apply.

LLMs excel at narrow, specific instructions paired with clear examples — that's their sweet spot: the tighter and shorter the task, the more precise the execution.

Classification "narrows" the task down to one specific case before the model starts extracting data. Only the relevant slice of instructions makes it into the prompt — the model doesn't waste "attention" on the rest.

Levers you can pull: - The type list in step 1 → expand it for your own use case (not just documents — this works for email types, customer inquiry categories, or report formats too) - Number of examples (2-4) → more examples boost accuracy but lengthen the prompt - The "not determined" rule → swap in your own behavior for missing fields (e.g., "leave blank" or "flag for review")


Limitations

⚠️ Dependency on step one: if the model misidentifies the document type in step 1, everything downstream is built on the wrong prompt — extraction proceeds using the wrong rules. This method only pays off when classification is accurate.

⚠️ Requires a closed list of types: this method works when you have a finite set of known categories with clearly defined fields. For one-off, totally unpredictable documents with no clear category, it doesn't add much — you'll be back to a single generic prompt.

⚠️ Poor photo quality: the no-fine-tuning version (the one usable in a regular chat) handles stamps, watermarks, and low contrast noticeably worse than the version with additional model training — and that requires code and GPUs, which isn't available in chat.


How It Was Tested

Researchers assembled a real-world production dataset from an e-procurement portal — nearly 100,000 photographed documents across 16 types (licenses, diplomas, social insurance certificates, and others), complete with real-world noise: stamps, watermarks, and camera-capture distortions. They compared the method against a strong baseline — a separately trained OCR + entity-extraction pipeline specifically tuned for each document type.

The result was surprising: the method with zero fine-tuning (just classification + a narrow prompt run on a plain Qwen2.5-VL-7B model) beat the specially trained baseline by almost 18 percentage points in accuracy. The logic is simple — the trained pipeline is tuned for each type separately, but it suffers from cross-type transfer issues and error accumulation along the OCR → extraction chain. Classification plus a narrow prompt gives the model less noise for the same amount of information.

Additional fine-tuning of the model itself pushed results even higher and especially helped with stamps and low-quality photos — but that requires serious infrastructure (8 GPUs, several days of training) and falls outside what's practical in a regular chat.

Research digest

Key result

Discovery: a single prompt with rules for all 16 document types at once performs worse than 16 separate narrow instructions. The model wastes attention on rules that don't even apply to the current document. Classification-Guided Prompting enables automatic data extraction from a mixed batch of different papers — invoices, delivery notes, acceptance certificates — without manual sorting and without one bloated one-size-fits-all prompt. First, the model quietly identifies the document type, then receives only the relevant slice of rules — common formatting plus 2-4 examples tailored to that specific type. The other 15 rule sets simply don't enter the picture.

Principle

The rule is simple: classify before extraction, not mixed in with it. It's like at a clinic — the front desk first figures out which specialist you need, rather than handing you every reference manual for every specialty at once. One document type — one narrow prompt, with no mixing of rules from other categories. The model works with a clean chunk of instructions instead of digging through a buffet of 16 sections.

Why it works

The reason lies in how the model distributes attention across the instruction text. If the prompt contains 16 rule sets, some attention leaks even into the parts that aren't needed for this particular document. A narrow task with 2-4 examples is exactly what LLMs do best — not parsing a massive rulebook. Classification strips away the noise before extraction even starts — the signal from the relevant rule gets stronger because there's no more noise from other types nearby.

When to apply

Document processing workflows → recognizing a mixed stream of invoices, acceptance certificates, universal transfer documents, delivery notes, especially when there are ten or more types, each with its own fields. Not suitable for one-off documents without a clear category — there it's simpler to just write a single general-purpose prompt than to build a classifier.

Mini recipe

1. List the document types: enumerate every category of document you encounter — invoice, acceptance certificate, universal transfer document, delivery note, and so on. 2. Describe the rules for each type: for every category, specify its own fields and 2-4 examples in JSON format. 3. Build a two-step prompt: first ask the model to identify the type from the list, then provide the rule dictionary, noting 'use only the rules matching the identified type.' 4. Configure behavior for missing fields: replace the default 'not specified' with your own rule — for example, 'leave blank' or 'flag for review.'

Examples

[BAD]: `Extract from the document the number, date, amount, supplier, contractor, list of work performed, VAT, series, shipper, and other fields` (a single prompt mixing fields from every document type at once) [GOOD]: `Step 1 — identify the document type from the list: Invoice / Acceptance Certificate / Universal Transfer Document / Delivery Note. Don't explain, just identify the type and move to step 2. Step 2 — extract only the fields specified for that particular type: [list of fields and a sample JSON for each type]`

In plain words

Modern models are great at reading text in images, but ask them to pull data out of a pile of different documents, and they start fumbling. The problem is one-size-fits-all prompts: if you stuff a model with a ten-page instruction that covers rules for invoices, contracts, and gym membership slips all at once, it loses the thread. The model tries to hold everything in memory at the same time, which causes attention to get diluted, leading it to mix up fields or flat-out hallucinate.

It's like hiring a secretary and handing them an employee handbook the size of "War and Peace," covering what to do in case of a fire, a tax audit, or a pizza delivery guy showing up. So when all they need to do is stamp an invoice, the poor soul freezes up, still flipping through the fire-safety chapter. Technically they know everything, but in practice they move at a snail's pace, because their brain is clogged with irrelevant clutter.

The fix proposed in this research is the Classification-Guided Extraction method. The idea is simple: first, the model acts like a mail sorter and just figures out the document type. Once it knows it's looking at, say, an invoice, it gets handed a short, no-nonsense prompt built specifically for that type. No filler — just the fields that matter and 2-4 concrete examples. The model isn't distracted by rules meant for receipts or shipping slips, so it hits the target dead-on.

Even though this was tested on boring office paperwork, the principle is universal. You can stretch this approach onto any complex task: from parsing medical lab results to sorting customer complaints. Instead of building one giant "do-everything" machine, you create a pipeline made of a quick classifier plus a set of narrow specialists. A focused prompt always beats a giant wall of generic text, because it saves both context window space and the developer's sanity.

Bottom line: stop feeding AI massive "one prompt to rule them all" instructions — that's a recipe for errors and slowdowns. Split the task into two steps: first figure out what you're dealing with, then issue a clear, no-noise command. A two-stage architecture turns a model from a confused newbie into a pro who knows exactly where to look. Whoever switches to this setup gets clean data without manual cleanup afterward; everyone else keeps wondering why their smart assistant mixed up a date with a phone number again.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on Classification-Guided Prompting: Figure Out the Task Type First, Then Give a Narrow Prompt Built Just For It arXiv:2607.22723

Sign in to apply this study New accounts get 50 free credits.