Fully Open-Source LLM Training: A Complete Pipeline from Data to Post-Training

    Fully open-source LLM training goes beyond releasing model weights: it exposes data, code, checkpoints, logs, and configurations so that results can be reproduced and audited. This article walks through the main stages—pretraining data strategy, mid-training trade-offs, benchmark decontamination, and a three-stage post-training recipe from SFT and DPO to RLVR—and distills practical lessons for teams building on open models.

    1. Why “Fully Open Source” Is More Valuable Than “Open Weights”

    The number of open-source large models has grown rapidly in recent years, but most so-called open-source models release only their final weights. True “fully open source” means making the entire model-training lifecycle transparent, typically across several layers:

    • Data layer: pretraining corpora, mid-training data, long-context extension data, and post-training instruction and preference data;
    • Code layer: data-cleaning pipelines, distributed training frameworks, and reinforcement learning training frameworks;
    • Process layer: intermediate checkpoints, training logs, hyperparameter configurations, and ablation experiment records.

    This approach matters for three reasons. First, reproducibility: researchers can verify conclusions under the same data and configurations instead of probing a “data black box.” Second, auditability: only when training data is fully public can independent parties check for benchmark contamination, copyright risk, and toxic content. Third, educational value: intermediate checkpoints and training logs let the community observe how model capabilities emerge, which is extremely valuable for academic research on training dynamics.

    For enterprise users, this transparency also reduces model-selection risk: you can know exactly what data the model has seen and where benchmark scores may be inflated.

    2. Base Model Training: Data Strategy Sets the Ceiling

    2.1 Quality-Aware Upsampling Beats Flat Filtering

    A common practice in pretraining data processing is to set a quality-score threshold and discard data below it. This is flat filtering. But the approach has a clear drawback: a large amount of “medium-quality” data is wasted, and in data-constrained settings, the total volume of high-quality data is often insufficient to support enough training scale.

    A better strategy is quality-aware upsampling: instead of a hard cutoff, build a continuous upsampling curve based on quality scores, so high-quality data is repeated more often during training, medium-quality data is retained with lower sampling weight, and low-quality data is heavily downweighted rather than completely removed.

    The logic is that language modeling is fundamentally about learning from a data distribution, and a smooth sampling distribution is closer to an optimal data-weight configuration than an abrupt cutoff boundary. Experimental evidence shows that under the same compute budget, this strategy can significantly improve model performance on multiple downstream benchmarks, especially at the decision point of “training for another epoch but with a limited total data volume.”

    Illustrative pseudocode logic:

    1. # Flat filtering vs. quality-aware upsampling
    2. # Flat: discard samples with score < threshold
    3. keep = score >= threshold
    4. # Quality-aware: bucket by score and build a sampling-weight curve
    5. buckets = bin_by_score(score, n_bins=100)
    6. weights = upsampling_curve(bucket_means) # high-score buckets weight > 1; low-score buckets approach 0
    7. sampler = WeightedRandomSampler(weights)

    2.2 Domain Trade-Offs in Mid-Training

    Mid-training refers to supplementary training on the order of tens of billions of tokens for specific capabilities such as code, math, and question answering, after the main pretraining stage and around the annealing phase. This stage shows clear domain trade-off phenomena:

    • Increasing the share of math data → math capability improves significantly, but general QA and multiple-choice QA performance drops;
    • Increasing the share of code data → code capability improves, but it likewise squeezes general capabilities.

    This suggests that different capabilities compete to some extent in parameter space rather than being fully orthogonal. In practice, the best mid-training mix is not simply assigning the highest weight to the strongest domain data. Instead, it means finding a Pareto balance across domains. One actionable rule of thumb is to treat the “average composite benchmark score” from ablation experiments as the optimization target, adjust domain ratios item by item, and monitor whether general capabilities fall below an acceptable baseline.

    2.3 Benefits of Bringing Post-Training Data Forward

    A counterintuitive but validated finding: introducing instruction-following data and chain-of-thought data already during mid-training can improve the base model’s evaluation performance across benchmarks, even if the base model does not undergo any supervised fine-tuning.

    This can be understood as a kind of “format warm-up”—the model encounters structured formats for question answering and reasoning late in pretraining, allowing it to converge faster in subsequent post-training and making the base model’s own evaluation results more reliable. The practical implication is: do not treat pretraining and post-training data as two completely isolated pools; moderate cross-pollination has positive returns.

    2.4 Benchmark Contamination and Decontamination

    Benchmark leakage is a widespread problem in open datasets: some common instruction-tuning datasets, such as large instruction collections, contain samples highly similar to public evaluation benchmarks. This leads models to “memorize the test” rather than genuinely acquire the capability.

    Decontamination faces two practical difficulties:

    1. Detection is hard: n-gram overlap detection can catch only surface-level copying, while semantically paraphrased contamination is difficult to identify;
    2. The cost is high: after cleaning, scores on some benchmarks—especially cloze-style benchmarks that depend on reading comprehension—may drop noticeably, which can create the misunderstanding that “the model got worse.”

    The correct attitude is: a score drop caused by decontamination precisely shows that the earlier score contained inflation, and true capability is the foundation of evaluation. When releasing a model, teams should disclose metrics before and after decontamination so users have a complete understanding of model capability.

    3. Post-Training: A Three-Stage Recipe from SFT to Reinforcement Learning

    Flagship reasoning models typically use a three-stage post-training pipeline:

    Stage 1: Supervised Fine-Tuning (SFT). High-quality instruction–answer pairs are used to train the model to master basic task formats and response styles. The key is data quality rather than quantity; reasoning data in particular requires strictly verified solution processes.

    Stage 2: Direct Preference Optimization (DPO). The model’s output tendencies are adjusted based on pairwise preference data. One engineering detail worth noting is how preference data is constructed: rather than asking annotators to label good and bad from scratch, it is better to collect output differences from the same model before and after training—an “incremental learning” idea—so that preference pairs reflect real changes in the model’s capability boundary and reduce noisy labels.

    Stage 3: Reinforcement Learning with Verifiable Rewards (RLVR). For tasks such as math and code that have objective correctness criteria, executable verifiers such as answer matching and unit tests can be used as reward signals for reinforcement learning. Compared with reward models trained on human preferences, verifiable rewards avoid the “gray zone” of reward hacking.

    At the algorithm level, there are several important practical improvement directions:

    • Remove the KL divergence constraint term: in traditional RLHF, the KL penalty prevents the policy from deviating too far from the reference model. But in scenarios where verifiable rewards are controllable, the KL term can limit sufficient exploration of correct solutions; removing it usually yields a higher task pass rate;
    • Token-level loss: allocate sequence-level advantage signals at token granularity to improve the signal-to-noise ratio of gradient signals, with a particularly clear efficiency gain for long reasoning chains.

    At the infrastructure level, the bottleneck in reinforcement learning training often lies in sample-generation throughput: weight synchronization between the inference engine and the training engine, and the pipeline design for trajectory sampling and gradient updates directly determine training efficiency. Open-sourcing the complete RL training framework code is exactly what allows the community to reproduce and improve these system-level optimizations.

    4. The Significance and Engineering Details of a Full Data Stack

    A complete open data stack usually includes four layers:

    1. Pretraining mixture data: at the trillions-of-tokens level, including web pages, code, scientific literature, and other sources. Structured parsing of scientific PDFs is a difficult point—converting raw PDFs to text loses tables, formulas, and two-column layout information, requiring dedicated OCR and layout-understanding pipelines;
    2. Mid-training data: domain-strengthening sets around math, code, and question answering, with ratios validated through ablations;
    3. Long-context data: alignment data used in the context-length extension stage;
    4. Post-training data: the complete set of instruction data, chain-of-thought data, preference data, and RL verification tasks.

    The lesson for enterprises is: if you continue training or perform domain fine-tuning based on open weights, understanding the original data composition helps you judge the model’s knowledge coverage boundary, avoid duplicating investment in domains the model has already fully trained on, and anticipate areas at risk of catastrophic forgetting.

    5. Implications for Practitioners

    Taken together, this wave of fully open-source practice offers several transferable lessons:

    • Data weighting can be more granular than data filtering: moving from binary filtering to continuously weighted upsampling is a low-cost direction for improving performance;
    • Capabilities involve trade-offs: any domain strengthening must be monitored with a composite benchmark system, and single-point optimization should be treated with caution;
    • Verifiable rewards are the most reliable signal source for reinforcement learning: for any task where an automatic verifier can be built, prefer RLVR over pure preference learning;
    • Transparency itself is a competitive advantage: a reproducible and auditable training pipeline not only serves the community but is also the best endorsement of model quality.

    As training methodologies become more public, large-model R&D is moving from “alchemy” toward engineering. For teams, understanding these public technical reports and training logs has far more long-term value than chasing a particular set of model weights.