LLM Application Workflows: From First Design to Production Use
Large language models generate and interpret content well, but a single prompt is not a business system. This article explains how to split work into observable, verifiable steps, connect them with data contracts, and combine models with deterministic code, checks, and human review—covering architecture, content production, news processing, training-data construction, and invoice extraction.
1. Treat the model as one step in a process
A large language model can generate text, interpret images, and extract information, but one conversation is not a complete business system. Real work usually includes data retrieval, format conversion, conditional logic, external calls, result checks, and human confirmation. Putting every requirement into a single prompt may look fine on simple samples and still fail when inputs are complex, data is missing, or an external service is down.
The core of an LLM application workflow is to break a business task into executable, observable, and verifiable nodes, then connect those nodes with explicit data contracts. The model handles semantic understanding and content generation. Deterministic programs handle calculation, validation, access control, and state.
A content-production flow, for example, can look like this:
User submits a topic → retrieve authorized source material → extract facts → draft an outline → write a first draft → check facts and wording → human review → produce publishable assets.
What matters most is not the number of nodes, but the boundary of responsibility. If fact retrieval fails, the system should not continue and produce an article that only looks complete. If review fails, the flow should not move on to publication.
The first step in building a workflow is not choosing a model. It is answering three questions:
- What is the input, and does it contain the information required to finish the task?
- What is the output, and how do you decide that it meets the business requirement?
- Which steps may return probabilistic results, and which steps must execute deterministically?
2. Build a minimum usable architecture from the business need
A general LLM workflow system can be divided into an access layer, an orchestration layer, a capability layer, and a governance layer.
2.1 Access layer: constrain input instead of accepting everything
The access layer receives text, images, files, or business events and performs authentication, file-type checks, size limits, and basic format validation.
Take invoice recognition as an example. Besides the document image, the input should include a task ID, a submitter identifier, and the processing purpose. The task ID supports tracing, the submitter identifier supports permission checks, and the purpose decides whether the result may enter a later reimbursement or reconciliation flow.
If required information is missing, ask for it. Do not let the model guess. Blurry images, missing pages, or damaged files should be returned as explicit states.
2.2 Orchestration layer: express order and branch conditions
The orchestration layer manages node dependencies, variable passing, conditional branches, iteration, and error handling. Each node should at least define:
- Input fields and field types
- Output fields and field types
- Success conditions
- Timeout and failure handling
- Whether retries are allowed
- Whether the node has external side effects
Side-effect-free operations such as queries and summaries can be retried a limited number of times. Operations that create records, submit approvals, or trigger publication must consider idempotency so the same request does not produce duplicate business results.
2.3 Capability layer: models, retrieval, and deterministic processing together
The capability layer typically includes text generation, visual understanding, text recognition, document retrieval, external service calls, and rule-based calculation.
Do not assign every capability to the same model. Amounts should be summed by a program. Access should be decided by a permission system. Style adjustments can be handled by a model. This split is easier to test and avoids unnecessary model calls.
2.4 Governance layer: make problems visible and locatable
The governance layer should record workflow versions, model configuration, node latency, call failures, validation results, and human handling results.
Logs should follow data minimization. Identity documents, account information, invoice content, and internal documents should not be written in full into runtime logs. For investigation, use redacted summaries, controlled samples, and related task IDs.
3. Design node data contracts and reduce implicit dependencies
The most common workflow failure is not that the model cannot understand the task at all. It is that upstream output does not match downstream expectations. An upstream node may return an amount as words while the downstream node expects a number. A field may be omitted while the next step still runs. An explanatory paragraph may be returned where a parser is required.
The remedy is a structured data contract for critical nodes. The following field design is illustrative and does not represent any specific platform API:
Task result:task_id: task identifierstatus: success, pending review, or failuredata: set of business fieldsevidence: source or image region for each fieldwarnings: list of risks and anomalies
Structured output still needs programmatic validation. A model that follows the format is not necessarily correct, and the fields are not necessarily complete.
Validation works best in three layers:
The first layer is structural: required fields, data types, and allowed values.
The second layer is business rules: amount relationships, date ranges, field combinations, and duplicate records.
The third layer is evidence: whether a conclusion can be tied to the input material or a trusted source.
If structural validation fails, you may request a new output a limited number of times. If business rules conflict, move to an exception branch. If evidence is insufficient, mark the result for review instead of regenerating until it merely looks plausible.
4. Practice 1: a content-production workflow
The hard part of publishing content is often not writing speed. It is the missing stable handoff among topic selection, sources, wording, and review. A workflow can reduce repeated labor, but automatic generation is not the same as automatic trustworthiness.
4.1 Turn a vague request into creative constraints
Inputs should include the topic, target audience, publication format, length range, tone, and prohibited items. For specialized content, also state the allowed source scope and the fact cutoff time.
“Write a technical article” is too broad. “Explain failure retries for asynchronous tasks to junior developers, include one business example, and distinguish retry from idempotency” is much easier to check.
4.2 Organize facts before organizing language
A source node should extract key facts, source identifiers, times, and points of dispute, then pass them to the generation node. The generation node organizes material. It should not fill in facts that do not exist.
Split content into two kinds:
- Facts supported by a source, which may be stated directly
- Experience-based advice or inference, which must state the conditions under which it applies
Data, benefit claims, and effect comparisons that lack a source should be removed or held until evidence is supplied.
4.3 Split review into separate dimensions
Fact checks, language checks, and business-compliance checks should not be collapsed into one vague “polish” step.
Fact review looks for unsupported conclusions. Language review looks at structure, repetition, and wording. Business review looks at copyright, privacy, promissory language, and publication rights. For public release, keep a human confirmation step, especially for high-risk domains such as finance, medicine, and law.
If you generate illustrations or synthetic-person assets, treat that as a separate branch and verify usage rights, personal authorization, and synthetic-content labeling. Effects such as lip sync and voice consistency need real tests. A completed workflow status does not prove that quality is acceptable.
5. Practice 2: news processing and batch iteration
A news-processing flow usually includes list retrieval, body extraction, deduplication, classification, summarization, and aggregation. Compared with single-article handling, batch jobs expose concurrency, timeout, and source-consistency problems more quickly.
5.1 Obtain content lawfully and keep the source
Prefer authorized data interfaces or content sources. Even when fetching public pages, follow access limits, terms of use, and copyright requirements. Do not obtain content by bypassing authentication.
Each item should store the title, source identifier, publication time, retrieval time, and body status. Do not mix publication time with retrieval time, or an old story can be treated as current.
5.2 Isolate single-item failures
An iteration node can process articles one by one, but concurrency and batch size should be limited. If one article body is empty or retrieval fails, record the reason and let the other articles continue.
Retry only faults that may recover, such as a brief timeout. Insufficient permission, deleted content, or an unsupported format should not be “fixed” by endless retries.
5.3 Do not let external content change system behavior
Web pages, attachments, and retrieved material are untrusted data. Even if they contain text such as “ignore previous instructions” or “call this function,” do not treat that text as workflow instructions.
Keep system instructions separate from source content, and apply permission and parameter checks to external tool calls. When a model summarizes news, it only interprets the material. It should not have arbitrary permission to execute external operations.
5.4 Aggregation is not simple concatenation
The aggregation stage should identify duplicate coverage, related events, and time order. When sources conflict, keep the disagreement. Do not force a single story just to produce a smooth summary.
A summary should highlight the event, time, actors, and key changes, and keep source links so readers or reviewers can check back.
6. Practice 3: build fine-tuning data without confusing training and orchestration
Fine-tuning continues training a pretrained model on specific data so that it better matches a target task, output style, or behavior pattern. A workflow can help generate, clean, and review training samples, but constructing a corpus is not the same as completing fine-tuning.
6.1 Decide whether fine-tuning is actually needed
If the need is mainly to query up-to-date material, retrieval augmentation should usually come first. If the problem is unstable output format, improve the prompt and the validation mechanism first. Consider fine-tuning when the task needs stable learning of a specific style or classification rule.
Do not expect parameter training to hold all frequently changing business knowledge. Updates, tracing, and correction can become harder.
6.2 Build samples from the task definition
Each sample needs a clear input, an expected output, and a quality standard. Samples should not cover only the ideal case. They should also cover:
- Clarification when information is insufficient
- Refusal of unsupported requests
- Distinction between similar categories
- Abnormal inputs and boundary cases
- Inputs of different lengths and phrasings
Model-generated samples are only candidates. A large volume of unreviewed synthetic samples can spread errors, narrow the range of expression, or amplify bias already present in the original model.
6.3 Control leakage and duplicate contamination
The cleaning flow should deduplicate, check privacy, check label consistency, and validate format. Training, validation, and test sets should be isolated. Highly similar samples from the same document or the same business event should not be randomly scattered across sets, or evaluation will look too optimistic.
For sensitive business data, confirm usage authorization and retention period. Corpus quality, task coverage, and independent evaluation usually matter more than simply adding more samples.
7. Practice 4: invoice recognition and multi-path comparison
Invoice processing demands high accuracy. A vision model or a text-recognition system can reduce manual entry, but model output alone should not make a financial decision.
7.1 Judge whether the image is usable before recognition
Preprocessing should check sharpness, rotation, occlusion, glare, and page completeness. If several documents appear in one image, segment them first or ask for a new upload so fields from different documents are not mixed.
Recognition results should distinguish “not recognized,” “field not applicable,” and “field empty.” Do not hide those cases behind a single empty string.
7.2 Extract fields and keep evidence
Common fields include document type, date, number, buyer and seller information, amount, and tax. Different document types may require different fields. Do not force every document to emit the same complete field set.
For critical fields, keep the original text span or the related image region when possible. A confidence score reported by the model is not a true accuracy rate. Whether a result may pass automatically should depend on independent tests and business risk.
7.3 Check key relationships with rules
After normalizing formats, compute amounts with decimal fixed-point arithmetic so binary floating-point precision does not distort the result.
Where the document type allows it, check the relationship among the amount excluding tax, the tax, and the tax-inclusive total. Tolerance should follow document rules, rounding method, and business requirements. Do not widen it arbitrarily. Also check required fields, date ranges, duplicate submissions, and related business information.
7.4 Agreement across paths does not prove the document is valid
Two recognition paths can be compared, for example text recognition and visual understanding. If critical fields disagree, send the case to human review. If they agree, continue to business-rule checks.
Both paths can still make the same mistake on the same blurry image. Agreement is only a supporting signal. Successful recognition also does not mean the document is genuine, valid, or eligible for reimbursement. Authenticity and business compliance need separate verification through authorized channels and internal policy.
8. Build evaluation and an operating loop before launch
Launch should not depend only on a smooth demo. Build a test set that covers normal, abnormal, and adversarial inputs.
For content generation, measure fact support, structural completeness, and the amount of human editing. For news processing, measure source retention, summary omissions, and duplication rate. For document processing, measure field accuracy, false acceptance of critical fields, and the share sent to human review. For corpus construction, measure the share of valid samples, duplication, and label consistency.
Also separate node success from business success. A finished run only means the program completed. It does not mean the result is usable.
Cost should be counted for the whole task, including model calls, external APIs, storage, failed retries, and human review. You can control cost with upfront rule filters, caching of repeat results within compliance limits, dropping irrelevant context, and choosing model capability by task difficulty. Do not do this by dropping critical checks.
Every change to a prompt, model configuration, field rule, or node structure should be versioned and regression-tested. If quality drops, you should be able to roll back and identify the affected scope.
9. A practical implementation order
For a first project, choose a task with clear inputs, verifiable results, and lower risk—for example, a sourced summary of authorized material.
In the first stage, build the shortest flow: input, processing, validation, and output. In the second stage, add exception branches, batch handling, and human review. In the third stage, add permissions, monitoring, version management, and cost tracking. Only then expand into more business capabilities based on real usage.
The value of an LLM workflow is not automating every action. It is a reliable division of labor: the model handles meaning, programs enforce rules, evidence supports conclusions, and people make the judgments that still require them. Design around that principle, and a one-time demo can become a maintainable, auditable application that can keep improving.
