Vertical Domain vs. General-Purpose LLMs: Technical Selection Considerations
This article explains how vertical domain and general-purpose large language models can work together in a layered architecture. It covers selection criteria, the main difficulties in building vertical models (data distribution and reward design), a production architecture for reinforcement learning post-training, how Group Relative Policy Optimization reduces GPU memory use, and a phased rollout path with common pitfalls.
1. Layered Collaboration Rather Than a Binary Choice
When discussing vertical domain and general-purpose large models, avoid framing them as opposites. The core value of a general-purpose LLM lies in broad semantic understanding, generalization across tasks, open-domain knowledge, and multi-turn interaction. The core value of a vertical domain LLM lies in deep domain knowledge, enforced business process constraints, stable output formats, a closed loop with private data, and controllable cost and latency. The two work more like layers of “foundation capability” and “scenario capability” than substitutes for each other.
General-purpose LLMs suit businesses with diverse requests, many long-tail scenarios, unclear task boundaries, and a need for rapid experimentation. Vertical domain LLMs suit businesses with well-defined tasks, clear evaluation standards, data assets that can accumulate over time, and high requirements for compliance and stability. In practice, the more common pattern is a hybrid architecture. The general model handles open-ended Q&A, intent understanding, and fallback generation. A smaller vertical model handles high-frequency, deterministic, verifiable core tasks. Routing, tool calling, and result validation connect the two.
When choosing a model, focus on five dimensions: task determinism, domain data quality, reproducibility of the evaluation set, unit call cost and latency, and compliance and private deployment requirements. If a task has a clear answer or verifiable rules, such as structured extraction, mathematical reasoning, code repair, process compliance checks, or generating tool call parameters, a small model with reinforcement learning post-training is often cost-effective. If the task is mainly open-ended creation, cross-domain consultation, or complex multi-turn negotiation, a general-purpose LLM is a better fit. For those tasks, domain specialization should start with retrieval-augmented generation, prompt engineering, and light fine-tuning.
2. The Real Difficulties of Vertical Domain LLMs
Building a vertical domain LLM is more than fine-tuning on domain data. The first difficulty is data distribution. Domain data often has a severe long tail, inconsistent labels, varied answer formats, and a mix of noise and duplicates. If training data differs too much from real requests, the model may perform well on the evaluation set and still fail after deployment. A complete data engine is needed. It should cover cleaning, difficulty stratification, deduplication, answer normalization, and strict separation of training and evaluation data.
The second difficulty is reward design. Reinforcement learning post-training depends on computable reward signals. Rule-based rewards are easy to implement but prone to overfitting. Model-based rewards cover more cases but can be exploited through reward hacking. For vertical scenarios, use a hybrid reward. Score answer correctness, format compliance, length constraints, safety constraints, and tool call validity separately. Keep manual spot checks and regression evaluation in place. The reward function is not a one-time engineering task. It is product logic that must keep evolving as the model’s behavior changes.
The third difficulty is coordinating training and inference. Reinforcement learning post-training requires extensive sampling, and inference throughput directly affects training efficiency. If training and inference are tightly coupled in the same compute graph or service, the system is likely to suffer from slow inference, memory pressure, complex scheduling, and difficult checkpoint recovery. Production systems usually separate training, inference, and scheduling. The data engine reads and filters samples. The inference engine generates multiple responses at high throughput. The training engine updates the policy. A distributed coordination layer handles resource orchestration and fault tolerance.
3. Production Architecture for Reinforcement Learning Post-Training
A practical architecture has four layers. The first is the data engine. It reads questions, reference answers, metadata, and difficulty labels from columnar data files or sample queues, then performs deduplication, sampling, and batch construction. The second is the inference engine. It generates multiple responses for each question and must support high concurrency, dynamic batching, length control, and configurable sampling parameters. The third is the training engine. It computes the loss, runs backpropagation, and updates parameters. It typically uses parameter-efficient fine-tuning, mixed precision, and sharding strategies to control memory. The fourth is the distributed coordination layer. It handles task scheduling, failure retries, logging and monitoring, and checkpoint saving.
The simplified data flow is: read samples → generate multiple responses with inference nodes → score with rules or a model → compute advantages → update the policy with training nodes → evaluate on a validation set and save checkpoints. The central idea is to decouple sampling from training. Inference can scale out independently, and training batch sizes can be set based on memory and throughput. The scheduling layer manages resources so that training does not wait on sampling, and sampling does not hold memory for long periods. For vertical domains, add reward auditing and regression evaluation. These steps prevent the model from learning only to satisfy the reward function while drifting away from the real objective.
4. How Group Relative Policy Optimization Saves Memory
Traditional reinforcement learning post-training usually requires a separate value model to estimate the baseline. That model adds memory overhead comparable to the policy model. Group Relative Policy Optimization samples multiple responses for the same question and uses the mean or normalized reward of that group as a relative baseline. This reduces reliance on a separate value model. One model copy and its optimizer state can be removed, which lowers memory usage and simplifies the training pipeline.
The training process has five steps: sampling, reward, advantage computation, policy update, and validation. During sampling, the model generates multiple responses to the same question. During the reward step, rules or a model score each response. During advantage computation, rewards within the same group are normalized to determine each response’s relative quality. During the policy update, parameters change based on the probability ratio between the new and old policies and on the advantages. During validation, the model is re-evaluated on a fixed evaluation set to detect capability drift. Production implementations also need probability ratio clipping, KL constraints, length masking, format validation, and filtering of abnormal samples to keep training stable.
Simplified loss pseudocode:
def compute_group_relative_loss(new_logprobs, old_logprobs, advantages, eps):ratio = exp(new_logprobs - old_logprobs)clipped_ratio = clamp(ratio, 1 - eps, 1 + eps)return -mean(min(ratio * advantages, clipped_ratio * advantages))
Reward extraction pseudocode. The key point is normalizing the final answer instead of relying on a fixed dataset format:
def extract_final_answer(text):match = regex_search("最终答案[::]\s*(-?[0-9.,]+)", text)if match is None:return Nonereturn normalize_number(match)
5. Phased Rollout Path and Common Pitfalls
Roll out the work in phases. Phase one defines the task and evaluation set. This includes input and output formats, rules for judging correct answers, categories of failure cases, and launch metrics. Phase two uses supervised fine-tuning to build a baseline and confirm that the model follows the required format. Phase three runs a small-scale trial of reinforcement learning post-training. Fix the sampling parameters and reward function first, then check whether the reward curve matches real evaluation results. Phase four scales up sampling and training and introduces hybrid rewards, difficulty stratification, and curriculum learning. Phase five deploys with hybrid routing. High-confidence requests go to the vertical small model, and low-confidence or open-ended requests fall back to the general model.
Common pitfalls include the following. An overly simple reward function teaches the model to game the score. Sampling temperature set too low makes the responses within a group too similar, so the advantage signal disappears. Length bias leads the model to prefer longer answers. Inconsistency between training and inference distorts probability ratios. Contamination of the evaluation set inflates metrics. For long-running jobs, missing handling for memory fragmentation and checkpoint recovery causes interruptions. Optimizing a single metric can also degrade format compliance, safety, and readability. To avoid these problems, build reward audits, a fixed regression set, a dashboard for abnormal samples, and joint multi-metric evaluation. Record data versions, reward versions, and model versions together.
When engineering resources are limited, Baidu AI Cloud’s general-purpose container platform, object storage, and logging and monitoring capabilities can help build a training and evaluation pipeline. The core work still centers on task evaluation, reward design, and the data loop.
Overall, general-purpose LLMs provide a generalization foundation, and vertical domain LLMs provide scen
