Engineering a Primary LLM for Both Intelligence and Efficiency

    Deploying a large language model as your primary workhorse is not about winning a single benchmark—it is about reliably handling high-volume, repetitive, and moderately difficult tasks like reading documents, editing code, aligning business rules, and processing text-and-image materials. This article explains how to do that in practice. It covers how to classify tasks before choosing reasoning strategies, how to set acceptance criteria for code, knowledge, and multimodal work, how to treat computer operations as tightly controlled tools, how to reduce token consumption without sacrificing quality, how to handle knowledge cutoffs, how to build security into the workflow, and how to integrate, observe, and roll out the system step by step.

    A Primary Model Is Built for Throughput, Not Stunts

    A primary model is usually not designed for one-off extreme reasoning. Its job is to steadily absorb large volumes of repetitive yet non-trivial work: reading documentation, modifying code, aligning business rules, processing text and image materials, and returning results to the system. Calling it a “primary” model emphasizes throughput, consistency, and unit cost—not leaderboard rankings. From an engineering standpoint, you should first classify task types, then decide whether a heavier reasoning strategy is warranted, rather than sending every request down the longest reasoning chain by default.

    1. Define the Task Before Discussing Model Capability

    Complex work falls roughly into four categories:

    1. Code and refactoring: writing tests, migrating interfaces, explaining diffs, and generating reviewable patches.
    2. Knowledge work: summarizing policies, comparing clauses, extracting fields with cited evidence.
    3. Multimodal understanding: table screenshots, UI sketches, scanned documents cross-referenced with body text.
    4. Processes requiring external actions: querying internal systems, filling in structured results, triggering authorized automation steps.

    These four categories place different demands on the model. Code tasks are judged by compilability, regression risk, and style consistency. Knowledge tasks are judged by whether citations are traceable and whether uncertainty is acknowledged. Multimodal tasks are judged by whether layout and numbers are read correctly. Action tasks are judged by permissions, idempotency, and failure rollback.

    If you cover all scenarios with the same prompt and the same temperature setting, you may appear to have “one model for everything,” but errors will amplify at the boundaries. A more robust approach is to unify the model access layer and configure different system prompts, tool whitelists, output modes, and human review checkpoints per scenario.

    2. How to Accept Code, Knowledge, and Multimodal Outputs

    Code

    Code capability cannot be judged by “produces a plausible-looking function.” Break acceptance into automatically checkable layers: static formatting, unit tests, behavior comparison against the old implementation, and human reading of critical paths. For migration tasks in particular, keep golden samples of the old behavior—fix the inputs and outputs first, then allow the model to propose refactors. The model is suited to generating candidate patches and explanations, not to merging code directly without tests.

    Knowledge

    The key to knowledge work is not recall, but tying conclusions to evidence. For policies, contract highlights, and product documentation, require output in three parts: “conclusion, evidence excerpts, unresolved questions.” Evidence excerpts must come from the materials provided in the current session or from retrieval results—not from the model’s free improvisation. When conflicting clauses appear, list the conflicts explicitly rather than picking whichever reading sounds smoother.

    Multimodal

    Multimodal work also needs protection against “describes the picture convincingly” hallucinations. Numbers, units, seal positions, and merged table cells are all high-risk points. In practice, restrict image understanding to extraction and delegate computation to deterministic programs: the model outputs only structured fields, while amount totals, date conversion, and unit conversion are done by code. This leverages visual understanding while keeping arithmetic errors out of business results.

    A typical output constraint can be written as a stable structure rather than free prose:

    1. {
    2. "conclusion": "string",
    3. "evidence": [{"source_id": "string", "quote": "string"}],
    4. "unknowns": ["string"],
    5. "needs_human_review": true
    6. }

    Keep the field names generic. One point worth emphasizing: schema constraints reduce drift, but they do not replace business validation. Missing required fields, out-of-range enums, and negative amounts should still be rejected on the server side.

    3. Treat Computer Operations as Controlled Tools, Not Delegated Authority

    Letting a model “operate a computer” by clicking freely is very risky. The reasonable form is a built-in or external set of tools with clear permissions: reading specified documents, querying read-only interfaces, running tests in a sandbox, generating tickets from templates. Every step should have input/output schemas, timeouts, retry limits, and audit logs.

    Actions must be reversible or compensable. Read-only queries can run automatically; writes, deletions, and outbound sends must pass confirmation or be restricted to a test environment. Tool responses should be short and structured—avoid stuffing entire pages of irrelevant text back into context, which makes subsequent reasoning expensive and prone to being led astray by noise. On failure, return a clear error code and a retryable flag, and let the orchestration layer decide whether to switch tools, degrade, or escalate to a human—rather than letting the model guess repeatedly.

    A minimal tool description shows where the boundaries lie:

    1. name: run_readonly_query
    2. input: { "query_id": "string", "params": {} }
    3. output: { "rows": [], "truncated": false }
    4. policy: no_side_effects, timeout_ms limited, audit required

    Never ask the model in the prompt to “find a way around the restrictions.” The restrictions themselves are part of the product capability.

    4. Do the Same Work with Fewer Tokens

    Token consumption typically comes from three sources: overly long system prompts, indiscriminately included history, and redundant text returned by tools. Cost reduction should come from pruning, not from dropping key constraints.

    • System prompts: keep only the role, prohibitions, output format, and two rules for the current scenario; put the manual into retrieval.
    • Conversation history: summarize by task phase, keeping decisions and open questions while dropping pleasantries.
    • Tool results: filter fields and truncate oversized cells on the program side before handing them to the model.
    • Repetitive classification and extraction tasks: prefer short outputs or labels over long explanations; generate explanations only during spot checks or on failure.

    When evaluating, look at quality and usage together. If a strategy slightly improves accuracy but doubles token count, calculate cost per successful completion rather than chasing the highest score. Run ablations too: after removing a prompt section or a context category, does the error rate rise meaningfully? Only information that errors are sensitive to deserves a place in context.

    5. Knowledge Cutoff and Update Strategy

    Every model has a temporal boundary in its training data. Never assume it knows about subsequent API changes, regulatory revisions, or internal policy updates. The correct approach is to move “freshness” out of the model weights and into an updatable knowledge layer: authoritative documents go into retrieval, version numbers are written into citations, and outdated documents are down-weighted or retired.

    On the query side, explicitly provide “the policy text as of a given date” or “the current API specification,” and forbid the model from overriding these materials with memory. If retrieval comes up empty, the system should answer “unknown” and list the materials needed. For code repositories, treat the current repo state and tests as the source of truth—not the model’s memory of old framework usage. This turns knowledge updates into an operations problem of content and indexing, and release cadence becomes independent of model upgrades.

    6. Security Must Live in the Workflow, Not in Slogans

    Strengthening security means at least three checkpoints: input, tools, and output. On the input side, detect unauthorized requests, prompt injection (e.g., documents embedding “ignore previous rules”), and attempts to extract secrets. On the tool side, use least-privilege accounts and keep secrets in the orchestration layer, never in prompts. On the output side, run sensitive-information scanning, dangerous-operation interception, and format validation.

    For code scenarios, also prevent the generation of unreviewably large patches, disabled validations, or dependencies from unknown sources. Limit the scope of each change, mandate accompanying tests, and require human review of the diff before merge. For financial and HR data, apply masking by default before sending to the model, and never store full ID numbers or secrets in logs. Security policies should be configurable, auditable, and tenant-isolated.

    7. How Typical Scenarios Land in Practice

    Financial analysis suits an “extraction plus rule-based computation” pattern: the model extracts line items, periods, and anomaly descriptions from reports or statements, while calculations, thresholds, and cross-checks are done by programs; anomalies go into a review queue. Do not let the model produce unverified investment advice or final journal entries.

    Code migration suits a “small-step comparison” pattern: split by module, generate a patch each step, run the original tests, and record behavioral differences. Differences are classified as acceptable cleanups versus compatibility requirements, confirmed by a human. Feed failure samples back into prompts or rules to prevent the same class of error from recurring.

    Creative or internal tool building suits a “skeleton by humans, filling by the model” pattern: interaction flows, permission models, and data tables are designed first; the model handles copy variants, sample data, initial interface documentation, and test cases. Generated artifacts must go into version control, not stay in chat history.

    The common customer value across these scenarios is shortening first-draft time and focusing expert attention on exceptions and risks. The model is not the accountable party; release and sign-off remain with humans and existing processes.

    8. Integration, Observability, and Regression

    Use a unified gateway to wrap model calls: log scenario identifiers, input summaries, output modes, token counts, latency, tool traces, and whether output was human-edited. Object storage is a good fit for evaluation samples and masked logs; monitoring and alerting should track error rates, timeouts, and cost spikes. If your organization already uses Baidu AI Cloud, you can use its general object storage, logging service, and monitoring/alerting to handle the above, without hard-coding business logic into one proprietary call format.

    Evaluation sets should be layered by scenario and include adversarial samples: empty documents, conflicting clauses, blurry screenshots, oversized tables, injected instructions, and unauthorized tool requests. Every time you adjust prompts, tools, or model versions, run the same regression suite and compare quality, latency, and usage—rather than relying on isolated success stories. Human spot checks should focus on high-impact errors: amounts, permissions, deletion-type operations, and outbound text.

    9. Trade-offs at Implementation Time

    The value of a primary model is doing most requests “good enough, fast enough, affordable, and accountable.” Harder edge cases can be escalated to stronger reasoning, multi-turn tool use, or a human. Do not let extreme cases negate everyday usability, and do not let demo performance substitute for regression data.

    The implementation order can be concrete: pick one well-bounded read-only scenario first, and fix the output structure and evaluation set; then wire in a minimal tool set and auditing; then do context pruning and cost observation; and only then expand write access. Each step should be independently rollbackable. What you are building is a sustainable workflow, not a one-off model demo that cannot be reproduced.