Large and Small Model Collaboration in Programming: Practices for Instruction Following and Execution Efficiency

    This article explores the practice of using layered agent workflows in software development to collaborate between large and small models. It details the basic patterns of model collaboration, the two core dimensions affecting execution quality (instruction following and execution speed), how to write effective implementation guidance documents, general model evaluation methods, multimodal costs, and practical recommendations for teams adopting this approach.

    1. Background: Why Differentiate Model Roles

    In actual software development, teams increasingly adopt layered agent workflows. A strong large language model (LLM) handles requirement understanding, task decomposition, solution design, and outputs structured documentation. A smaller, faster model executes the documentation item by item, completing repetitive tasks like code modifications, boilerplate generation, and unit test writing.

    The core logic of this division is straightforward: planning requires strong reasoning and broad knowledge coverage, while execution prioritizes stability, accuracy, and high throughput. Handling all stages with a single model often leads to significant waste in cost, speed, or quality.

    Understanding this division helps teams avoid two common pitfalls. The first is focusing only on a model’s overall benchmark score while ignoring its performance in specific execution tasks. The second is delegating all tasks to the strongest model, which wastes time and budget on simple tasks.

    2. Basic Patterns of Large and Small Model Collaboration

    Common collaboration patterns can be summarized into three layers.

    The first is the Requirements and Architecture layer, handled by a strong planning model. It reads business context, existing code structures, and constraints, then outputs a technical solution.

    The second is the Implementation Guidance layer, which translates the solution into executable task documents. The document should clearly define each sub-task’s input, output, involved files, dependencies, and acceptance criteria.

    The third is the Execution and Verification layer, where a fast model executes the coding based on the document, followed by automated verification using test scripts or static analysis tools.

    In this pattern, the second layer acts as the interface between the two types of models. The output quality of the planning model directly determines the upper limit of the execution model. If the document vaguely describes the tech stack, directory conventions, API formats, and test boundaries, the execution model can only rely on guesswork, amplifying errors down the line.

    3. Two Core Dimensions Affecting Execution Quality

    When selecting a model for the execution layer, focus on two dimensions: instruction following and execution speed.

    3.1 Instruction Following

    The primary task of an execution model is to faithfully complete instructions. For construction tasks, divergent creativity is not always an advantage. A model that spontaneously expands requirements, arbitrarily rewrites APIs, or casually refactors unrelated code will increase review costs and cause scope creep.

    To judge if an execution model is suitable, consider the following:

    • Strict adherence to file paths, naming conventions, and dependency version constraints.
    • Choosing conservative approaches when encountering ambiguities rather than assuming features.
    • Outputting results in specified formats (e.g., structured logs, patches, test reports).
    • Retaining previous constraints after multiple rounds of modifications.

    Rigorous, predictable behavior is usually more valuable than occasional impressive outputs.

    3.2 Execution Speed and Throughput

    Speed is equally important for the execution layer. If simple tasks require lengthy deep reasoning, overall efficiency drops significantly. This is especially true during the testing phase. When a model repeatedly reads test outputs, locates failed cases, and attempts fixes, the response latency of each round accumulates.

    When measuring speed, don’t just look at single response time; consider the effective output volume per unit time. Teams can record the total time and effective lines of code produced within a complete iteration cycle and compare it with other models.

    For lightweight tasks like UI tweaks, copy replacements, or configuration changes, choosing a fast, low-cost model is more reasonable. Using a heavy reasoning model for such tasks is like calling an entire design team for a minor tweak—both cost and wait time exceed actual needs.

    4. How to Write High-Quality Implementation Guidance Documents

    The implementation guidance document defines the working boundaries of the execution model. A qualified document should include at least the following sections.

    4.1 Tech Stack and Environment Constraints

    Clearly specify language versions, framework versions, dependencies, and runtime environments. Avoid vague terms like “commonly used frameworks.” Specify version numbers and state whether upgrades are allowed.

    4.2 Directory Structure and File Responsibilities

    List files to be added or modified and explain each file’s responsibilities. Explicitly list files that should not be changed to prevent accidental modifications by the execution model.

    4.3 API and Data Conventions

    Provide function signatures, request/response formats, field types, and error codes. Example:

    1. ## Task: User Points Query API
    2. - Files involved: src/api/points.py, tests/test_points.py
    3. - API: GET /api/v1/points/{user_id}
    4. - Input: user_id, positive integer, required
    5. - Output: {"user_id": int, "balance": int}
    6. - Exceptions: Returns 404 when user_id does not exist, error code POINT_USER_NOT_FOUND
    7. - Forbidden: Modifying src/api/auth.py and other modules

    The benefit of this format is clear boundaries, so the execution model doesn’t need to infer.

    4.4 Test Boundaries and Acceptance Criteria

    Every task should have automated executable acceptance conditions, such as scenarios covered by test cases, commands to pass, and performance or memory limits. The more specific the criteria, the easier it is for the execution model to determine if it is done.

    4.5 Handling Rules for Uncertainties

    Define how to handle ambiguities, such as “stop and report, no assumptions allowed.” This significantly reduces the chance of the execution model improvising.

    5. General Model Evaluation Methods

    During selection, teams shouldn’t rely solely on subjective experience. Design a fixed set of evaluation tasks covering common development scenarios and record objective metrics.

    Recommended metrics to focus on include:

    • First pass rate: Proportion of tasks passing acceptance on the first execution.
    • Rework rounds: Average rounds of manual or automated corrections needed.
    • Instruction violation rate: Number of times modifying forbidden areas or deviating from agreed formats.
    • Output per unit time: Effective tasks completed within a given time.
    • Tool calling error rate: Proportion of failures like wrong parameters or paths.

    Below is a simplified Python script example for summarizing multiple task results:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class TaskResult:
    4. passed_first_try: bool
    5. rework_rounds: int
    6. violated_constraints: bool
    7. duration_seconds: float
    8. def summarize(results: list[TaskResult]) -> dict:
    9. total = len(results)
    10. if total == 0:
    11. raise ValueError("Results list is empty")
    12. return {
    13. "first_pass_rate": sum(r.passed_first_try for r in results) / total,
    14. "avg_rework": sum(r.rework_rounds for r in results) / total,
    15. "violation_rate": sum(r.violated_constraints for r in results) / total,
    16. "avg_duration_s": sum(r.duration_seconds for r in results) / total,
    17. }

    Evaluation tasks should closely resemble real business scenarios, and the documents and environments should remain consistent across comparisons to ensure comparable results.

    6. Multimodal Capabilities and Toolchain Costs

    Some models support multimodal capabilities like image generation and understanding. When selecting a model, the value of these capabilities depends on the team’s actual needs.

    If a project frequently requires generating assets (e.g., icons, backgrounds, or placeholder images during prototyping), integrated multimodal capabilities can reduce external tool integration. If each generation requires purchasing additional quotas, deploying local models, or maintaining extra CLI tools and scripts, total costs will rise.

    When evaluating, consider integration complexity, additional fees, and operational burden. Stages completed within the same workflow are usually easier to maintain than those requiring cross-tool stitching. However, teams should also be aware of the risks of relying on a single capability, retaining backups and manual reviews for critical outputs.

    7. Selection for Creative and Knowledge-Based Tasks

    For tasks requiring broad knowledge—such as copywriting, solution design, or tech stack analysis—a model’s parameter scale and training data coverage are more critical. Reasoning helps the model clarify logical chains but cannot replace knowledge itself. Information a model hasn’t learned usually cannot be compensated for by longer thinking processes.

    In these scenarios, combine retrieval tools to supplement the latest information and require the model to cite sources in its output. Content involving factual judgments should be manually reviewed.

    8. Practical Recommendations

    When teams adopt layered workflows, they can refer to the following steps.

    First, select a batch of real but low-risk tasks (e.g., unit test additions or documentation generation) as pilots.

    Second, fix the evaluation set and document templates, changing only one model variable at a time to ensure valid comparisons.

    Third, establish version control mechanisms, storing implementation guidance documents in the code repository and recording reasons for each modification.

    Fourth, set up automated verification for execution results, including tests, static analysis, and format validation, to reduce reliance on manual line-by-line reviews.

    Fifth, regularly review metrics and adjust model combinations based on task types. No single combination fits all scenarios; teams need to make judgments based on their tech stack, task distribution, and budget.

    The value of large and small model collaboration lies in applying different capabilities to the right stages. Planning quality, document quality, and verification mechanisms together determine the final outcome; selecting models is just one part of the equation.