Large Language Model Capability Differences in Document Processing and Code Generation
In real engineering deployments, the question "which model is stronger" is becoming harder to answer, because model capability is no longer a single curve but a set of independent capability clusters. This article breaks LLM evaluation into six dimensions and uses two high-frequency scenarios—document structuring and code generation quality assurance—to discuss the differing capability boundaries of large models and share reusable practices. It covers schema-first design, separating extraction from validation, evidence traceback, deterministic format handling, human review gates, test-first development, cross-file contract constraints, cost and architecture tradeoffs, building your own evaluation set, and common anti-patterns. It is vendor-neutral and focuses only on widely accepted technical approaches.
In real engineering deployments, the question “which model is stronger” is becoming harder to answer. The reason is simple: model capability is no longer a single-dimensional curve. It has split into several mutually independent capability clusters—long-context understanding, structured information extraction, format-faithful output, tool-call orchestration, code reasoning and refactoring, and multi-turn instruction following. The relative standing of the same model across these clusters is not consistent. So the right way to choose a model is not to find the “strongest” one, but to decompose a task into its capability requirements and then match accordingly.
This article uses two of the highest-frequency scenarios—document structuring and code generation quality assurance—as its main thread to discuss the differentiated capability boundaries of large models and offer reusable practices. It does not involve any specific vendor’s products and only discusses technical approaches broadly recognized in the industry.
1. Capability Decomposition: Don’t Measure a Model with a Single Score
When evaluating a model, it is advisable to distinguish at least the following six dimensions:
- Long-document understanding: Locating key information within inputs of hundreds of thousands of tokens, and resisting the positional bias where “content in the middle gets ignored.”
- Structured extraction: Mapping unstructured text onto a strict schema, and whether the model can proactively flag missing fields rather than fabricate them.
- Format-faithful output: The ability to reproduce tables, hierarchical headings, annotation positions, and cell styles.
- Code reasoning: Understanding cross-file dependencies, covering boundary conditions, and preserving semantics during refactoring.
- Tool calling and workflow orchestration: Plan decomposition, failure retries, and intermediate-result verification in multi-step tasks.
- Instruction-following stability: Consistency under long prompts and multiple constraints.
A common mistake is to replace the above decomposition with a single score from a public benchmark leaderboard. Benchmark questions often lean toward static question answering, whereas documents in real business carry scanning noise, complex merged cells, and formula dependencies, while code tasks require cross-repository understanding—all of which correlate only weakly with leaderboard performance.
2. Document Processing: From “Copy and Paste” to a Pipeline
The pain point described in the source material is representative: faced with ten quotations, the manual path is to open, copy, paste, and repeat—time-consuming and extremely error-prone. The real value of a model is not “read once and then summarize,” but turning this manual chain into a replayable pipeline.
2.1 Four High-Frequency Document Tasks
- Text and table extraction: Recognizing body paragraphs and table structure, and outputting them as computable structured data.
- Form understanding and auto-filling: Inferring field semantics from specification documents and mapping them to the key names of a target form.
- Document merging and annotation: Concatenating multiple documents while preserving the original layout, and writing review comments at specified positions.
- Format conversion and normalization: Unifying heterogeneous sources (scanned, exported, manually created) into the same schema.
2.2 Key Engineering Steps
The first step is schema-first. Don’t let the model “improvise freely.” Instead, define the target structure clearly first, then let the model fill it in. Beyond names and types, field definitions should also include constraints and null-value strategies.
{"supplier": { "type": "string", "required": true },"quote_no": { "type": "string", "pattern": "^[A-Z]{2}-\\d{6}$" },"items": {"type": "array","items": {"name": { "type": "string" },"qty": { "type": "number", "minimum": 0 },"unit_price": { "type": "number", "minimum": 0 },"currency": { "type": "string", "enum": ["CNY", "USD", "EUR"] }}},"valid_until": { "type": "string", "format": "date", "nullable": true }}
The second step is to separate extraction from validation. Having a single call do both extraction and validation significantly reduces stability. A more reliable approach is two stages:
Stage 1 (Extraction): document -> structured candidate results + the source snippet from the original text for each fieldStage 2 (Validation): candidate results -> rule checks + conflict detection -> pass / hold for human review
Requiring the model to return “field source snippets” is a technique with extremely low cost but very high payoff. It makes results auditable and turns error localization from “re-read the entire document” into “look only at the suspicious field.”
The third step is to prioritize deterministic capabilities. Operations like page merging, cell-style preservation, and formula recalculation achieve far higher accuracy and repeatability with code libraries than with generative models. The sensible division of labor is: the model handles semantic understanding, field mapping, and anomaly judgment; the program handles byte-level format operations. Mixing the two is the root cause of instability in many automation solutions.
The fourth step is to place human gates. For fields such as amounts, tax rates, compliance clauses, and legal entity names, set up threshold routing: when confidence falls below a threshold or documents conflict with each other, automatically hold the record for a human review queue rather than writing it directly to the database.
2.3 Prompt Template Example
Role: You are a rigorous financial-document information extractor.Input: A purchase quotation (may contain scanning noise and merged cells).Task:1. Extract the field set F (see schema); do not add or rename fields.2. Attach an evidence field to each: a continuous snippet from the source text that supports the conclusion (<= 40 characters).3. If a value is missing in the source, fill in null and explain it in the missing list; do not guess, complete, or cite external common knowledge.4. If amount units are inconsistent, keep the original values and note in notes that manual confirmation is needed.Output: Strict JSON, with no extra explanatory text.
The third constraint is the core defense against hallucination. Most extraction errors are not because the model “cannot understand,” but because the model “wants to give an answer too much.”
3. Code Generation: Build Quality In, Don’t Fix It Afterwards
The document scenario tests understanding and fidelity; the code scenario tests reasoning and constraint adherence. The step most prone to problems here is not “unable to write code,” but “writes code that looks correct, yet gets all the boundaries wrong.”
3.1 Test-First as a Constraint Mechanism
Having the model produce test cases first and then the implementation is essentially a form of self-constraint: tests translate vague natural-language requirements into executable acceptance criteria, and the model must then work under the condition of satisfying the tests. Key points for implementation:
- Tests must be runnable and must fail. If the generated tests pass outright, they verify nothing.
- Write boundaries and exceptions first, then the main flow. Empty input, oversized input, invalid types, concurrent calls, timeout retries.
- Prohibit the model from modifying tests to “pass.” This rule must be stated explicitly in the prompt, otherwise the model often takes shortcuts.
- Back it up with coverage and mutation testing. Line coverage does not equal effective assertions; supplement it with mutation testing or human review of critical branches.
A simplified workflow skeleton:
Requirement -> acceptance criteria list -> test cases (including failing ones) -> minimal implementation -> refactor -> regression^ |+------- if it fails, return to test alignment <---+
3.2 Cross-File and Repository-Level Understanding
Single-file completion is long past being the bottleneck. The real difficulty lies in this: when modifying a function, can it identify all callers, interface contracts, and breaking changes to implicit conventions? Actionable mitigations:
- Provide retrieval context rather than feeding in the whole repository. Use a symbol index to find relevant definitions and call sites, and inject them on demand.
- Declare contracts explicitly. List in the prompt the “public interface signatures that must not change” and the “behavioral invariants that must be preserved.”
- Require a change description. Have the model first output a list of changes and an impact analysis, then output the patch; this exposes errors at the review stage rather than the testing stage.
- Commit in small steps. Make only one semantically complete change at a time; rollback cost is low and problem attribution is clear.
3.3 Acceptance Checklist for Generated Code
- Does it handle null and zero-value semantics?
- Do exception paths have explicit types and logging?
- Does it introduce new external dependencies, and are they necessary?
- Are idempotency and retries safe?
- Could sensitive information be written into logs?
4. Cost and Architecture: Put the Model into the System, Don’t Treat It as Magic
The engineering stage must face three real constraints.
The context window is a scarce resource. The longer the context, the higher the unit cost, and effective attention usually declines as length grows. The strategy is layering: first use lightweight retrieval to narrow the scope, then hand high-value snippets to the model; for very long documents, perform structured chunking and keep the section hierarchy as locating anchors.
The determinism-first principle. Whatever correctness can be expressed through rules, regular expressions, type systems, and database constraints should not be handed to a probabilistic model. The model’s role is to handle ambiguity and semantics, not to bear all the logic.
Observability cannot be omitted. At a minimum, record the input summary, prompt version, model identifier, output schema validation result, human review conclusion, and elapsed time. Without these fields, you cannot attribute the cause when online quality degrades, nor can you run A/B comparisons.
The tradeoff point between cost and quality varies by scenario. For extraction tasks, you can try smaller, faster models combined with strict schema validation; complex refactoring and hard defect localization rely more on strong reasoning ability. The sensible approach is to set up a routing layer that dynamically selects the tier based on task difficulty and historical success rate.
5. Effectiveness Evaluation: Build Your Own Evaluation Set
Talking about model selection without your own evaluation set is basically relying on gut feeling. The recommended minimum viable approach:
| Stage | Approach | Purpose |
|---|---|---|
| Sample collection | Extract 50–200 samples containing hard cases from real business | Cover the real distribution |
| Annotation | Have humans provide standard answers and acceptable variants | Establish a baseline |
| Metrics | Field-level accuracy, exact-match rate, compilation pass rate, test pass rate | Quantifiable comparison |
| Regression | Automatically re-run on every prompt or model change | Prevent silent degradation |
| Failure attribution | Classify as comprehension error / format error / hallucination / insufficient context | Point to different improvement means |
Attribution classification is especially important: format errors can be solved with schema validation and retries, hallucinations require tightening the prompt and adding evidence constraints, and insufficient context requires improving the retrieval strategy—the improvement directions for the three are completely different, and generically “switching to a different model” is often ineffective.
6. Common Anti-Patterns
- Treating the prompt as documentation. A thousand-line prompt dilutes critical constraints; structure it into segments and put hard constraints up front.
- No retries, no validation. Generative output is inherently variable; an automation flow without a validation layer will inevitably break during peak periods.
- Writing untrusted data directly to the database. All downstream write operations should have schema validation and human gates.
- Making the model do too much at once. Cramming extraction, conversion, aggregation, and formatting into a single call means errors cannot be localized afterwards.
- Ignoring version management. Prompt and model versions must be tracked in the code repository, otherwise online issues cannot be reproduced.
7. Conclusion
The differences between models ultimately show up in the precision of “task–capability” matching, not in a vague sense of high or low. For document processing, the key is to combine schema, evidence traceback, deterministic format operations, and human gates into a pipeline; for code generation, the key is to build quality into the process through test-first, contract constraints, and small-step changes. Make these two main threads solid, and then run continuous regression with your own evaluation set, and model selection and replacement turn from a one-off gamble into a measurable, rollback-able engineering decision. For teams that need to host such capabilities in their own environments, they typically combine general capabilities on a cloud platform—object storage, a container platform, a message queue, logging services, and monitoring and alerting—wrapping model calls into an observable, scalable service layer, so that optimization efforts can focus on prompts and evaluation themselves.
