Fully Open LLM Training Pipeline: Practical Lessons from Pretraining to Reinforcement Learning

    A fully open approach to large language model training exposes every stage of the model lifecycle—pretraining, mid-training, post-training, and reinforcement learning—including data, code, intermediate checkpoints, and logs. This article summarizes the key practices behind such a pipeline: quality-aware upsampling, token-budget-based data mixing, structured parsing of scientific documents, three-stage post-training for reasoning models, and common RL algorithm modifications. It also covers practical considerations such as contamination removal and evaluation trade-offs, offering a transferable playbook for teams building their own training workflows. Note that the original material did not specify model names, versions, or experimental conditions, so no specific figures are cited here; all numbers should be verified against the original report.

    1. Overview and Value

    Over the past few years, open-source language models have typically been released with only their final weights and a brief model card. Users can run inference and fine-tune, but it is difficult to determine which training stage contributed a given capability, or under what data conditions a particular behavior emerged.

    A fully open approach is different. The model lifecycle is broken into four stages—base training, mid-training, reasoning-oriented post-training, and reinforcement learning—and the data, training code, intermediate checkpoints, and logs for each stage are released publicly. Researchers can therefore trace where capability changes come from and run controlled experiments by swapping out any single stage along the same pipeline.

    For enterprise algorithm and platform teams, the value of this methodology lies in its transferability. Data recipes, stage divisions, and evaluation protocols can all be applied to in-house scenarios. The required infrastructure is also model-agnostic: object storage holds different versions of datasets, container platforms orchestrate distributed training, and logging and monitoring services track metric curves across stages.

    The rest of this article covers pretraining and mid-training, three-stage post-training, reinforcement learning modifications, and a practical checklist. Since the original material provides no model names, versions, report links, or experimental conditions, this article does not cite specific values. All figures should be verified against the original report.

    2. Pretraining and Mid-Training

    2.1 Quality-Aware Upsampling Beats Simple Truncation

    Pretraining corpora are usually scored for quality first. The most straightforward approach is to set a threshold and keep only documents above it—a method known as flat filtering. When the available data volume is limited, high-quality documents are quickly exhausted, low-scoring documents are discarded entirely, and corpus diversity suffers.

    Quality-aware upsampling instead designs a sampling curve based on quality scores. High-quality documents are sampled multiple times, medium-quality documents moderately, and low-quality documents are retained in small amounts. The shape of the curve determines the effective number of training epochs for each quality range, so it should be tuned together with data scale and training budget.

    The following code illustrates the idea only; it is not the real interface of any framework:

    1. import math
    2. def upsample_weight(quality: float, k: float = 4.0, cap: float = 3.0) -> float:
    3. """Map a quality score to a sampling weight: higher scores get higher weights, capped to limit repetition."""
    4. return min(math.exp(k * (quality - 0.5)), cap)
    5. for q in [0.0, 0.2, 0.55, 0.9]:
    6. print(f"Quality score {q:.2f} -> sampling weight {upsample_weight(q):.2f}")

    The output: a quality score of 0.00 maps to weight 0.14, 0.20 to 0.30, 0.55 to 1.22, and 0.90 to 3.00, where the last value is truncated by the cap. The parameters k and cap are illustrative. cap should be determined through small-scale experiments, observing how validation loss changes after repeated sampling of the same document.

    2.2 Mixing Data by Token Budget

    When a corpus draws from many sources, mixing by document count lets long documents dominate. A more robust approach is to allocate proportions across source types using a token budget. Setting a clear token cap for each data type ties the mixing ratio directly to training objectives and makes it easier to compare different mixtures.

    2.3 Structured Parsing of Scientific Documents

    Formulas, tables, and multi-column layouts in academic papers are rarely found in ordinary web text. Extracting plain text directly loses this structural information. Document parsing and OCR pipelines can convert PDFs into structure-preserving text, allowing mathematical expressions and tables to enter the training data.

    Such data requires separate evaluation. It is recommended to stratify samples by source and check three error rates: formula transcription errors, table row-column alignment errors, and reading-order errors. Poorly parsed data can hurt mathematical capability even in large quantities. Use sampling as a starting point and adjust the sample size based on confidence requirements.

    2.4 Domain Mixing Ratios in Mid-Training

    Mid-training typically uses a smaller but more targeted dataset—in the original material, on the order of 100 billion tokens. Its experiments showed that increasing the share of math and code data noticeably improves those two capabilities, but may weaken general question answering and multiple-choice QA. The table below summarizes the qualitative trends reported in the original material; specific values should follow the original report.

    Adjustment Math & Code General QA Multiple-Choice QA
    Increase math/code share Clear improvement Declines Declines
    Maintain general data share Limited improvement Mostly stable Mostly stable
    Final mixture Some improvement Preserved as much as possible Preserved as much as possible

    In practice, the goal is not to maximize any single metric but to find a balance across capabilities. Adjust one ratio at a time while monitoring all sub-metrics.

    2.5 Introducing Instruction and Chain-of-Thought Data Early

    The original material highlights one finding: adding instruction-following and chain-of-thought data during mid-training improves the base model’s evaluation on multiple benchmarks even without any subsequent supervised fine-tuning. This shows that the boundaries between training stages are not fixed. Instruction and reasoning formats can be mixed in at appropriate ratios earlier, rather than waiting until post-training.

    Three points to watch in practice. First, start the mixing ratio small and increase it gradually. Second, the quality of chain-of-thought samples directly affects output length and style—low-quality samples teach the model verbose reasoning. Third, check whether formats solidify too early, making the model rigid on open-ended questions.

    2.6 The Cost and Documentation of Decontamination

    Many public datasets contain benchmark questions, which inflates evaluation scores. Decontamination removes these overlapping samples. After decontamination, some reading-comprehension metrics may drop. A score drop does not mean the model got worse—it may simply reflect the removal of inflated scores, bringing results closer to true generalization ability.

    Keep a record of every decontamination run for review and comparison.

    Record Item What to Document
    Decontamination rules Matching method (exact match, n-gram overlap, or semantic similarity) and thresholds
    Benchmarks covered All benchmark names and versions
    Removal volume Document and token counts, by data source and benchmark
    Metric changes Benchmark scores before and after processing
    Conclusion Whether metric changes came from removing inflated samples; whether target capabilities were affected

    3. Three-Stage Post-Training for Reasoning Models

    Post-training for reasoning models typically proceeds in three stages: supervised fine-tuning, preference optimization, and reinforcement learning with verifiable rewards. These respectively address format imitation, preference alignment, and capability improvement.

    3.1 Supervised Fine-Tuning

    Supervised fine-tuning uses high-quality instruction-response pairs to teach the model the target format and basic reasoning habits. Data quality at this stage sets the starting point for everything that follows. When screening samples, check the following:

    • Consistent formatting: tags, paragraphs, and terminators.
    • Complete reasoning steps with no skipped logic.
    • Verifiable answers; incorrect answers must be removed.
    • Deduplication and decontamination checks passed.
    • A reasonable response-length distribution, avoiding excessive skew toward very long or very short samples.

    3.2 Preference Optimization

    Preference optimization commonly uses Direct Preference Optimization (DPO), which requires paired preferred and dispreferred responses. The key requirement for paired data is that the difference between the two responses should come from the target dimension, such as factual accuracy or instruction adherence. If the preferred response is chosen merely because it is longer, the model learns to “get longer” rather than “get better.” During training, monitor how response length changes across steps.

    3.3 Reinforcement Learning with Verifiable Rewards

    In the RL stage, rewards come from rules or tests rather than human scoring. Common tasks include math problems (answers can be compared), coding problems (unit tests can be run), and format-constrained instructions (formatting can be checked). Reward functions must be stable, otherwise the model will learn to exploit loopholes. For example, merely checking whether the answer appears in the output can be gamed by repeating the answer.

    4. RL Algorithm Modifications and Metrics

    4.1 Training Steps

    1. Build a problem bank, stratified by difficulty, and remove questions overlapping with evaluation sets.
    2. Sample a group of responses per problem; a group size of around 8 is a reasonable default, adjusted for GPU memory and throughput.
    3. Score each response with a verifier; the verifier itself needs separate testing.
    4. Normalize within each group to obtain relative advantages. Problems where all responses are correct or all are wrong provide weak signal and can be filtered out.
    5. Update the model with clipped policy gradients, adding a KL constraint relative to a reference model, with the coefficient determined experimentally.
    6. Evaluate on a held-out set at fixed intervals and save checkpoints for rollback.

    4.2 Common Algorithm Modifications

    Below are common modification ideas. Each should be validated through its own ablation experiments before adoption:

    • Replace an independent value model with group-relative advantages, reducing the number of models that need to be trained.
    • Normalize response lengths, or penalize overly long responses, to prevent the model from being rewarded for verbosity.