Vertical vs. General LLMs: Choosing the Right Technical Approach

    This article breaks down when to use a general-purpose large language model versus a task-specific vertical model, and explains why reinforcement learning can outperform scaling parameters when answers are automatically verifiable. It covers a four-layer production training architecture, critic-free advantage estimation to reduce GPU memory, rule-based versus model-based reward design, a step-by-step reproduction workflow with common pitfalls, and a layered routing strategy that combines both model types.

    1. The Core Question: Vertical and General Models Are Not Substitutes

    When deploying LLM applications, teams face a common decision: call a general-purpose model with a massive parameter count and broad coverage, or invest resources in training a vertical model that excels at a single scenario. There is no universal answer, but the choice can be broken down along three dimensions: whether the task boundary is clear, whether data can be collected in a closed loop, and whether the per-inference cost is affordable.

    General models offer generalization and zero-shot performance, making them suitable for stages where requirements shift frequently and scenarios have not yet converged. Vertical models offer advantages in unit cost, response latency, and output stability, making them suitable for scenarios with well-defined tasks and quantifiable evaluation criteria, such as solving math word problems, code completion, and structured information extraction. The real dividing line is this: once a task can be scored automatically, model capability no longer depends mainly on “piling on parameters” but on “piling on feedback.”

    2. Why Reinforcement Learning Brings a Qualitative Shift

    Supervised fine-tuning essentially imitates existing answers, so the model’s ceiling is constrained by the quality of labeled data. Reinforcement learning differs in that it replaces the reference answer with a reward signal. The model can explore solution paths not covered by the labeled data, and earns positive feedback as long as the final answer can be verified as correct. This mechanism delivers the largest gains on tasks where results are decidable, such as mathematical reasoning and code generation.

    As a result, a small model in the 1.5B parameter range improved its accuracy on a math reasoning benchmark from roughly 49% to roughly 80% after targeted reinforcement learning training. This is not a victory of parameter scale but a victory of training signal density. It is worth stressing that such gains depend heavily on task verifiability; in scenarios that are hard to score automatically, such as open-ended writing and complex multi-turn dialogue, the same method yields significantly smaller returns.

    3. A Four-Layer Architecture for Production-Grade Training

    On the engineering side, the core tension in LLM reinforcement learning is that inference and training have inconsistent hardware resource demands. Mature production-grade solutions are typically split into four layers:

    • Data engine: handles sample loading, batch splitting, and prompt template management;
    • Inference engine: uses a high-throughput inference backend to generate responses in batches, delivering several times the inference speed of a pure training framework;
    • Training engine: handles parameter updates, commonly using fully sharded data parallelism to spread out GPU memory usage;
    • Distributed coordination layer: orchestrates role lifecycles, resource allocation, and fault recovery in a unified way.

    The data flow simplifies to: load samples → sample multiple responses to the same question → score with rules or a model → compute advantages and update the policy → periodically validate and save checkpoints. Decoupling inference from training is the key design behind the overall throughput gain.

    4. Where GPU Memory Is Saved: Critic-Free Value Function Replacement

    Traditional Proximal Policy Optimization (PPO) requires the policy model, reference model, value model, and reward model to be resident simultaneously, creating enormous GPU memory pressure. The core idea of Group Relative Policy Optimization (GRPO)-style methods is to sample a group of responses to the same question, use the group’s mean reward as the baseline, and use the group-normalized value directly as the advantage. This removes the value model and typically saves 30% to 40% of GPU memory.

    The illustrative code below expresses the computation logic only:

    1. import torch
    2. def group_relative_advantage(rewards, eps=1e-6):
    3. # rewards: [group_size] scores of multiple responses to the same question
    4. mean = rewards.mean()
    5. std = rewards.std()
    6. return (rewards - mean) / (std + eps)
    7. def policy_loss(new_logprobs, old_logprobs, advantages, clip=0.2):
    8. ratio = torch.exp(new_logprobs - old_logprobs)
    9. clipped = torch.clamp(ratio, 1 - clip, 1 + clip)
    10. return -torch.min(ratio * advantages, clipped * advantages).mean()

    The training loop has five steps: sampling and generation, reward computation, advantage estimation, policy update, and validation evaluation. Sampling and updating alternate, which is where throughput bottlenecks and numerical instability most often appear in engineering implementations.

    5. Reward Design: The Real Bottleneck That Determines Success

    The reward function is the first priority in vertical training. Two common types exist: rule-based rewards and model-based rewards. Rule-based rewards are deterministic and zero-cost, suitable for tasks where answers can be extracted with regular expressions. Model-based rewards offer broader coverage but carry the risk of being exploited by “reward hacking.” Taking math problems as an example, the usual convention is to mark the final answer with a fixed delimiter, then extract and compare it:

    1. import re
    2. def extract_final_number(text):
    3. m = re.search(r"####\s*(-?[0-9.,]+)", text)
    4. return m.group(1).replace(",", "") if m else None
    5. def rule_reward(response, ground_truth):
    6. pred = extract_final_number(response)
    7. if pred is None:
    8. return -0.5 # format violation penalty
    9. return 1.0 if pred == ground_truth else 0.0

    The practical recommendation is to keep only two rewards at first, format reward and correctness reward, and introduce process-oriented rewards once training stabilizes. Also keep a KL constraint in place to prevent the model from producing degraded text in pursuit of higher rewards.

    6. Reproduction Workflow and Common Pitfalls

    1. Data preparation: organize samples into a columnar file with fields that include at least the prompt, the reference answer, and decidable metadata;
    2. Resource planning: in single-GPU scenarios, reduce the sampling group size and generation length first, and use gradient accumulation to maintain an effective batch size;
    3. Smoke test: first run a minimal closed loop of fewer than ten steps and confirm the reward distribution is not all zeros;
    4. Formal training: watch whether the reward curve and validation accuracy rise together; if reward rises while accuracy stalls, the reward is being gamed;
    5. Evaluation and retention: evaluate periodically on a fixed validation set and keep the best checkpoint.

    High-frequency pitfalls include: GPU memory overflow is often caused by an overly long generation length; failure to converge is often caused by zero variance in group rewards; and performance regression is often caused by a missing reference model constraint.

    If the task can be scored automatically, data can be collected in a closed loop, and cost is sensitive, prioritize the vertical path of “small model + reinforcement learning,” supported by a containerized training platform, object storage for checkpoints, and logging, monitoring, and alerting services to track metrics. If the scenario is open-ended and requirements change frequently, keep a general model as a fallback and use the vertical model as a cost-reduction layer. Baidu AI Cloud can provide general-purpose compute scheduling, storage, and observability support for this kind of training and inference pipeline. The two paths are not mutually exclusive; the mainstream practice is layered routing, where the general model handles the long tail and the vertical model takes high-frequency deterministic requests.