Constructing a Tiered Open-Source LLM System: A Fine-Tuning Guide from Coding Assistants to Agents

    This article explores how individual developers and small teams can build a production-ready, tiered open-source large language model (LLM) system. It covers the engineering logic behind a three-tier model architecture, dual enhanced reasoning modes for agentic tasks, layered security defenses, automated red-teaming, and prompt caching strategies to optimize performance and cost.

    1. Background: Why Individual Developers Choose Fine-Tuning Open-Source Models

    In recent years, the open-source community has seen an influx of high-quality pre-trained and instruction-tuned base models, offering unprecedented opportunities for individual developers and small teams. Without training from scratch, they can fine-tune a base model on domain-specific data to achieve excellent performance in specific scenarios. Take coding assistance and agentic tasks as an example: while general base models possess broad language understanding capabilities, they often require additional domain data to reach production-ready levels in tool calling specifications, multi-turn task planning, and structured code output.

    A typical practice path is to first perform initial code capability fine-tuning based on an open-source instruction model (referred to as the V1 Code Version) to validate core abilities like code completion, refactoring suggestions, and bug fixing. Then, based on V1, developers can supplement tool calling trajectories and multi-step planning data to evolve it into a V2 version tailored for Agent scenarios. This iterative approach of “vertical first, then agent” significantly reduces the complexity of data construction and evaluation, making it a common model evolution strategy in the industry.

    2. Three-Tier Model System: Engineering Logic of Tiered Design

    A single model struggles to simultaneously balance inference quality, response latency, and cost. Therefore, mature model series typically adopt a tiered architecture, forming three levels: flagship, standard, and lite.

    • Flagship (Sol class): Designed for complex Agent tasks and frontier research. With a larger parameter scale, these models excel at handling high-difficulty scenarios such as long-chain task planning, cross-file code understanding, and complex tool orchestration. Tasks that are insensitive to latency but demand extreme quality should be routed to this tier first.
    • Standard (Terra class): Aims to match top-tier closed-source model performance while gaining significant cost advantages through parameter reduction and inference optimization. It serves as the “default tier” for most business requests, providing a balance of quality and cost for medium-complexity tasks like code generation, unit test writing, and document summarization.
    • Lite (Luna class): Covers high-frequency lightweight tasks at a low cost, such as simple completion, format conversion, keyword extraction, and short text rewriting. These requests usually account for the majority of overall traffic, and using a lightweight model to handle them can significantly reduce total costs.

    In engineering implementation, tiered routing is typically paired with a lightweight “intent complexity classifier” that automatically selects the tier based on input length, task type, and historical context. A schematic routing logic is as follows:

    1. def route(request):
    2. complexity = classifier.score(request)
    3. if complexity >= HIGH:
    4. return flagship_model # Complex agent tasks
    5. elif complexity >= MID:
    6. return standard_model # Regular coding tasks
    7. else:
    8. return lite_model # High-frequency lightweight requests

    3. Dual Enhanced Reasoning Modes: Deep Thinking and Parallel Acceleration

    In Agent scenarios, the design of reasoning modes directly determines the task success rate. Two complementary enhanced modes are worth noting:

    Max Deep Reasoning Mode: By relaxing the limits on thinking steps and token budget, the model is allowed to perform longer internal deductions before providing the final answer—including task breakdown, alternative comparison, and error backtracking. This mode is suitable for tasks with high one-time investment and high trial-and-error costs, such as architecture design and difficult bug localization. The trade-off is increased latency and compute overhead, so it should be an optional setting rather than the default.

    Ultra Parallel Acceleration Mode: This mode breaks through the capability ceiling of a single Agent. The core idea is to split the main task into multiple independently executable sub-tasks, distribute them to several sub-Agents for parallel processing, and finally have the main Agent aggregate the results. For example, in a large codebase refactoring, the migration work of different modules can be dispatched in parallel, compressing the total time from a serial N×T to near a T magnitude. During implementation, attention must be paid to context isolation between sub-Agents and the strategy for merging result conflicts.

    These two modes are not mutually exclusive: you can first use parallel mode to quickly generate candidate solutions, and then enable deep reasoning for key branches to make refined decisions.

    4. Layered Security Defense: From Model Level to Account Level

    Once an open-source model is exposed as a service, security defense must be systematically designed rather than relying on a single method. Mature layered defense in the industry typically includes four layers:

    1. Model-Level Refusal: Through safety fine-tuning, the model is given an inherent ability to reject high-risk requests (such as malicious code generation or vulnerability exploitation guidance). This is the first line of defense, but it can be bypassed by carefully crafted prompts.
    2. Real-Time Classifier Review: Deploy independent classifiers on both the input and output sides of the model to perform real-time risk scoring on request content and generated results, intercepting high-risk content that slips through the model-level defense.
    3. Account-Level Risk Signal Monitoring: Aggregate behavioral features from an account perspective, such as request frequency, failure retry patterns, and anomalous prompt construction patterns, to identify repeated abuse and automated attacks.
    4. Differentiated Access Control: Allocate different model tiers, rate limits, and feature toggles based on the account’s trust level. High-risk accounts can only access restricted capabilities, forming a closed loop of “capabilities increase with trust.”

    5. Automated Red Teaming: Large-Scale Jailbreak Discovery

    The coverage of manual security testing is naturally limited. In practice, an automated red team pipeline can be adopted: using another model to act as an attacker, batch-generating jailbreak attempts across various prompt templates and context scenarios. If the tested model produces non-compliant outputs, it is recorded as a successful attack sample. Through large-scale iteration—for example, investing an equivalent of hundreds of thousands of GPU hours—universal jailbreak patterns can be systematically discovered. Defense samples are then fed back into safety fine-tuning and classifier training, forming a continuous closed loop of “attack—fix—regression verification.”

    6. Flexible Prompt Caching: Key to Reducing Long Context Costs

    Agent application prompts usually contain a large number of system instructions and tool descriptions. Repeatedly transmitting these prefixes wastes compute and drives up costs. Solutions supporting explicit cache breakpoints allow developers to mark reusable prompt prefix segments. The cache validity period can be as low as a minute level (e.g., a minimum of 30 minutes), thereby significantly reducing repeated computation in conversational interactions and batch tasks. When designing, breakpoint positions and refresh strategies should align with business rhythms—for example, setting stable system prompts as long caches while placing frequently changing context outside the cache segment.

    7. Conclusion

    From base model selection, tiered architecture, and reasoning enhancement to security defense, red teaming, and caching optimization, this chain forms a complete engineering closed loop for open-source models transitioning from “functional” to “operational.” For individual developers, fine-tuning is just the starting point; the real competitiveness lies in the comprehensive engineering and security capabilities built around the model.