Why LLMs with the Same Pre-trained Base Diverge: The Role of Alignment and Reinforcement Learning
While large language models rely on pre-training to establish their foundational capabilities, the final user experience is heavily dictated by post-training processes like alignment and reinforcement learning. This article explores why models with similar base capabilities diverge in practice, detailing the roles of supervised fine-tuning (SFT), preference optimization, and reinforcement learning. It also examines how verifiable rewards enhance coding abilities, the challenges of long-context and multi-constraint handling, and strategies for teams to evaluate and improve model performance.
1. Understanding the Problem: Pre-training Defines the Base, Not the Final Experience
The pre-training objective of large language models is typically to predict the next token. By learning the language distribution across massive amounts of text, the model acquires knowledge, reasoning patterns, and code structures.
A widely accepted principle in the industry is the scaling law: given sufficient data, the model’s loss decreases following a power law as the number of parameters, training data volume, and compute increase. While this illustrates the value of scale, it only describes the trend of “base capability” and cannot explain why two models with similar bases perform differently in real-world applications.
The divergence stems from three main reasons. First, differences in data composition: the proportion of code, mathematics, multilingual text, and high-quality long documents directly impacts the model’s capability in corresponding tasks. Second, differences in post-training methods: the same base model can exhibit vastly different behaviors after undergoing different instruction fine-tuning and preference optimization. Third, the time gap in product and data flywheels: products launched earlier can collect user interactions sooner, accelerating subsequent iteration speed, but this does not equate to the model’s capability ceiling.
Therefore, when evaluating model experience, “base capability” and “post-training capability” should be analyzed separately.
2. From Continuation to Conversation: Supervised Fine-Tuning (SFT)
A base model excels at text continuation but struggles to follow instructions. It might continue a question into an article, repeat the prompt, or veer off-topic. Supervised Fine-Tuning (SFT) teaches the model to “read the instruction and output the expected response.”
SFT training data typically consists of “instruction-response” pairs. Data quality impacts the outcome far more than quantity, hinging on three key factors:
- Task coverage: Samples are needed across tasks like Q&A, rewriting, summarization, reasoning, coding, and format conversion.
- Response normativity: Clear structure, complete steps, and language consistent with the user’s context.
- Boundary handling: When facing uncertain problems, whether the model admits uncertainty or fabricates an answer.
Below is an illustrative structure of an SFT sample:
sample = {"messages": [{"role": "system", "content": "You are a rigorous Python engineer."},{"role": "user", "content": "Count the number of missing values in each column of the CSV."},{"role": "assistant", "content": "You can use the combination of pandas' isna and sum: ""df.isna().sum(), which returns the missing value count by column."},]}
In practice, a common issue with SFT is a monotonous data style. If most training samples contain short answers, the model may provide overly vague conclusions when facing complex engineering problems. Therefore, samples should include multi-turn dialogues, long-context inputs, and tasks requiring step-by-step reasoning.
3. From “Presentable” to “Usable”: Preference Optimization and Reinforcement Learning
While SFT teaches the model formatting and basic capabilities, it struggles to express “which response is better.” Preference optimization addresses exactly this issue.
The common workflow is as follows:
- Generate multiple candidate responses for the same prompt.
- Have human annotators or evaluation models rank the candidates to form preference pairs (chosen and rejected).
- Train a reward model to assign a higher score to the chosen response.
- Use reinforcement learning (such as PPO-type algorithms) or direct preference optimization (DPO-type methods) to adjust the policy model, increasing the probability of high-scoring responses.
The common loss function for the reward model is based on the Bradley-Terry model. An illustrative code snippet is shown below:
import torch.nn.functional as Fdef pairwise_loss(score_chosen, score_rejected):# Objective: maximize the probability that chosen scores higher than rejectedreturn -F.logsigmoid(score_chosen - score_rejected).mean()
The difficulty in this stage lies in the annotation criteria. Common dimensions include helpfulness, accuracy, harmlessness, and honesty. Vague standard definitions lead to chaotic reward signals. Additionally, the following issues must be monitored:
- Length bias: Annotators tend to prefer longer responses, making the model verbose.
- Sycophancy: The model learns to agree with the user’s viewpoint rather than pointing out errors.
- Reward hacking: The model exploits loopholes in the reward model to achieve high scores while actual quality drops.
Countermeasures include length normalization, introducing adversarial samples for factuality and anti-sycophancy, and regularly using independent evaluation sets to verify if the reward aligns with real-world quality.
4. Why Coding Capabilities Easily Diverge
Code tasks possess a unique characteristic: the results are verifiable. Whether a piece of code runs and passes tests is an objective signal. This allows coding capabilities to be trained using “verifiable rewards,” which typically yields more stable results than purely subjective preferences.
The basic idea of verifiable rewards is: the model generates code, executes test cases in a sandbox, and uses the pass rate as the reward. An illustrative code snippet is below, where the sandbox execution function is just a placeholder; actual implementation requires environment isolation and resource limits:
def code_reward(solution: str, tests: list) -> float:if not tests:return 0.0passed = 0for test in tests:# run_in_sandbox is the sandbox execution function, implementation omitted hereif run_in_sandbox(solution, test):passed += 1return passed / len(tests)
Data engineering for coding capabilities is equally critical. Common practices include:
- Code deduplication: Approximate duplicate files amplify the weight of certain patterns, necessitating file-level and function-level deduplication.
- License and quality filtering: Exclude code with unclear licensing and filter out low-quality, auto-generated files.
- Repository-level context: Concatenate multiple related files to train the model to understand cross-file dependencies.
- Synthetic problems: Use existing models to generate problems and test cases, filter them by execution results, and scale up the dataset.
5. Long-Context and Multi-Constraint Following
In engineering scenarios, users often provide long documents, multiple files, and multiple constraints. This places two main requirements on the model.
The first is long-context capability. This relies on position encoding extension methods and training data that includes long text. During evaluation, a common practice is to embed key information within long text to test if the model can accurately locate and reference it.
The second is multi-constraint following. For instance, “list three points, each no more than twenty words, without using technical jargon” requires the model to satisfy multiple rules simultaneously. Training should specifically construct samples with explicit constraints, and use rule functions to automatically check if the output meets those constraints.
6. Performance Under Vague Prompts
Users often provide only vague requirements, such as “help me write a proposal.” The model must infer the goal, audience, and output format from the context. This capability primarily stems from two sources: first, whether the training data includes a large volume of real vague requests paired with reasonable completions; second, whether post-training encourages the model to first clarify or make reasonable assumptions explicit before proceeding.
For users, the most effective approach is to provide three types of information: background, goal, and constraints. In the absence of this information, the model should be asked to list assumptions before starting execution.
7. How Teams Should Evaluate and Improve
Regardless of the chosen model development path, teams need a reproducible evaluation system. The following steps are recommended:
- Split evaluation sets by capability: Set up separate samples for dialogue quality, code correctness, long-document retrieval, instruction following, and refusal boundaries.
- Maintain a private evaluation set: Public benchmarks are easily contaminated by training data; a private set reflects business performance more accurately.
- Conduct controlled variable comparisons: Under the same base, change only one training factor at a time to observe metric shifts.
- Combine manual spot-checks with automated evaluation: Automated metrics are fast, but manual checks are needed for length bias, factual errors, and tone issues.
- Record failure samples: Convert failure cases into new training or evaluation data to form a closed loop.
Conclusion
The gap in model capabilities often lies not in who releases first, but in the quality of data composition, post-training methods, and the evaluation loop. For developers, understanding these elements helps in judging model reliability across different tasks and designing appropriate prompting and validation workflows.
