From Weights to the Full Pipeline: Engineering Practices for Full-Stack Open-Source LLMs
A consortium of research institutions has jointly open-sourced a language model family in 7B and 32B parameter sizes, spanning four variants: Base, Think, Instruct, and RL-Zero. What stands out is not the parameter counts but the way it was open-sourced — beyond the weights, the release also publishes pretraining data, midtraining data, long-context data, post-training data, training code, intermediate checkpoints, and training logs, a package the authors call "Model Flow." This article starts from Model Flow to break down the design choices in the data pipeline, base-model training, and the post-training recipe, then distills general engineering lessons you can apply to your own model development.
Recently, several research institutions jointly open-sourced a language model family. It comes in two parameter sizes — 7B (7 billion) and 32B (32 billion) — and spans four variants: Base, Think, Instruct, and RL-Zero. The most notable aspect is not the parameter counts but how it was open-sourced. Beyond the weights, the release also publishes the pretraining data, midtraining data, long-context data, and post-training data, as well as the training code, intermediate checkpoints, and training logs. This combination is called “Model Flow” — delivering the complete pipeline from data construction and pretraining through midtraining and post-training, together with all artifacts and records. This article starts from “Model Flow,” breaks down the design choices in the data pipeline, base-model training, and post-training recipe, and extracts general engineering lessons you can transfer to your own model development.
1. Background: Open Source Moving from “Open Weights” to “Full-Stack Open Source”
Over the past two years, the mainstream open-source approach has been “open weights”: providing model files and model cards that allow downloading, fine-tuning, and even commercial use. But weights are only the end product; training data, data mixtures, hyperparameters, and the intermediate process are usually not disclosed. This leads to three common problems:
- Not reproducible: Training twice with the same code and hyperparameters can still yield different results, because of differences in parallel partitioning, random seeds, and data-stream order — and it gets worse when training details are missing.
- Not auditable: It is hard for outsiders to tell whether the pretraining corpus has mixed in benchmark text verbatim, or whether the sources and licenses are compliant.
- Not inheritable: If you want to continue pretraining on top of it, or do research on the architecture or algorithms, you often lack the necessary data and tooling.
“Full-stack open source” is a direct response to these three problems. Beyond “open weights,” it also requires:
- Open code: data-cleaning, training, and evaluation scripts that actually run;
- Open data: transparent data mixtures at each stage, with data that can be obtained directly or reconstructed via public scripts;
- Open process: intermediate checkpoints and training logs made public.
The costs are equally obvious. Data curation, deduplication and decontamination, document parsing, and training records all require extra effort, and once published, any oversight gets amplified. But the benefits are direct too: research and engineering can build on “a complete foundation” rather than guessing at the training process from a pile of weights.
2. What “Model Flow” Actually Delivers
2.1 The Four Variants of the Model Family
This series is not a single model but a family that shares the same base capabilities:
- Base: pretrained and midtrained only, with no alignment. Suitable for capability evaluation, continued pretraining, and domain adaptation.
- Instruct: after instruction tuning and preference optimization, it can complete tasks according to user intent and is aimed directly at applications.
- Think: builds on instruction following with stronger chain-of-thought reasoning, focusing on math, code, and logic tasks — the flagship variant of the series.
- RL-Zero: skips SFT and preference alignment, starting directly from the base and training with reinforcement learning using only verifiable rewards. It answers a research question: to what extent is reasoning ability “learned” rather than merely “taught”?
These four variants form a progression of capabilities: Base → Instruct → Think, with RL-Zero existing as a control branch. For users, you can choose a variant by task: Instruct for general dialogue and extraction tasks, Think for complex reasoning and code tasks, and Base and RL-Zero for research experiments. For researchers, the fact that all four share the same base means the differences between variants can be attributed fairly cleanly to the post-training methods themselves.
2.2 The Full-Pipeline Artifacts
The deliverables of “Model Flow” fall into roughly four layers:
| Layer | Main artifacts | Value to downstream |
|---|---|---|
| Code | Data construction and cleaning scripts, pretraining and post-training implementations, evaluation scripts | Reproduce or modify the pipeline yourself |
| Data | Pretraining mixture, midtraining mixture, long-context mixture, post-training data | Support continued pretraining, domain adaptation, and alignment experiments |
| Artifacts | Intermediate checkpoints at each stage | Enable analysis of how capabilities change with training volume |
| Records | Training logs, learning curves, ablation results | Make “why it was configured this way” verifiable |
Only when the four layers combine does “reproducibility” turn from a slogan into an engineering convention that can be executed and checked.
3. The Base Model: The Data Pipeline Is the Core Asset
The base stage is the result of pretraining on 5.9T tokens. The official description emphasizes a “token-constrained mixing” and “quality-aware upsampling” strategy, and uses about 100B tokens for midtraining. Below we break down the key designs.
3.1 Quality-Aware Upsampling Beats Flat Filtering
Quality varies widely across a pretraining corpus: web text is mixed with navigation and ads, academic text with references and formulas, and code repositories with generated files and core implementations. There are two common approaches to handling this:
- Flat filtering: set a single threshold for each quality metric and discard any sample below it;
- Quality-aware upsampling: keep more samples to maintain domain coverage, then repeat samples differentially according to quality score.
The idea behind the latter is that, under a fixed token budget, samples in different quality ranges should not be treated equally. High-quality samples are repeated multiple times, low-quality samples are repeated less or not at all, so the model “reads more good books and less noise.”
Its published result is worth noting: in data-constrained scenarios, quality-aware upsampling yields significantly more benefit than simple threshold truncation. Intuitively, this makes sense: once the total available corpus is insufficient, aggressive filtering also compresses the supply of high-quality data, so the model is “underfed” in the later stages of training. Upsampling effectively reallocates the limited tokens along the quality dimension.
When implementing this, start by scoring sample quality, then bucket samples by score and map them to repetition coefficients:
import math# Illustrative code: quality-aware upsampling weights# score: a quality score normalized to [0, 1] (e.g., perplexity, rule-based score, classifier output)def upsampling_weight(score: float, alpha: float = 4.0) -> float:# A larger alpha concentrates more weight on the high-quality range;# alpha = 0 is equivalent to uniform samplingreturn (score + 1e-6) ** alpha# Bucket weight = sum of sample weights in the bucket / original token count in the bucket,# then normalized to the total budgetdef bucket_weights(scores, lengths, total_budget_tokens, alpha=4.0):weights = [upsampling_weight(s, alpha) for s in scores]raw = [w * n for w, n in zip(weights, lengths)]scale = total_budget_tokens / sum(raw)return [r * scale / n for r, n in zip(raw, lengths)] # repetition count for each sample
Two points must be heeded in practice:
- Deduplicate first. Upsampling is essentially controlled repetition, so near-duplicate web templates and mirrored code repositories get amplified further through repetition. You typically need near-duplicate removal such as MinHash or SimHash at the document and paragraph levels; otherwise the model will overfit to template text.
- Calibrate scores. Quality scores come from heuristic rules or a classifier, and if the scorer itself is biased (e.g., preferring long text or a certain writing style), upsampling amplifies that bias too. Spot-checking the length and domain distribution of the sampled data is a low-cost, high-return safeguard.
3.2 Midtraining: Domain Trade-offs and Bringing Post-Training Data Forward
After the base completes the main pretraining, the series uses about 100B tokens for midtraining, focusing on strengthening code, math, and question-answering abilities, while introducing scientific PDFs processed via OCR and document parsing. The latter shows that high-quality domain knowledge is often “locked” in PDFs, scans, and formula typesetting — without this step, all the model encounters is garbled, incorrectly parsed text.
The lessons from midtraining can be summarized in three points:
1) Domain weighting is a zero-sum game. Raising the proportion of math and code data clearly improves the corresponding abilities, but general question-answering and multiple-choice abilities decline accordingly. The reason is not hard to understand: in the later stages of training the model’s memorization ability strengthens, so incremental tokens mostly “solidify” existing knowledge rather than broaden it. Incremental tokens across domains compete for the same learning capacity; math and code have higher reasoning density and faster returns, so they squeeze out question-answering data.
2) The mixture must be tuned across multiple evaluation dimensions at once. You cannot declare success just because math and code scores rise; you need to bring general abilities into the constraints and search for a Pareto optimum across multiple benchmarks. The official final midtraining mixture is exactly the result of repeatedly adjusting along this line of thinking.
3) Post-training data can be “used in advance”. Mixing in some instruction data and chain-of-thought data during midtraining — even without any SFT — improves the base’s performance across various benchmarks. This shows that instruction formats and reasoning paradigms do not have to be “learned” only in the post-training stage; early exposure makes the base more amenable to subsequent alignment, effectively paving the way for post-training.
In practice, you can refer to the following mixture approach:
# Illustrative code: midtraining domain mixture (pseudo-config)MIDTRAIN_MIX = {"code": 0.35, # code"math": 0.20, # math"qa": 0.15, # general question-answering, to preserve general abilities"long_doc": 0.15, # long documents and books"sci_pdf": 0.10, # scientific material after document parsing"instruction_think": 0.05, # instruction and chain-of-thought data introduced early}# Note: the ratios are illustrative only. The final mixture should be# determined via small-scale proxy experiments and evaluated on both# math/code and general question-answering metrics.
3.3 Long-Context Data
Long-context ability cannot be obtained by simply “turning up the context-window parameter.” If the vast majority of samples in the corpus are only a few hundred tokens, the model rarely sees dependencies spanning large spans of text during training, so its long-distance retrieval and coreference abilities at inference time are naturally weak. A dedicated long-context data mixture typically includes long documents, repository-level code samples, and concatenated samples, combined with position-encoding extension and long-sequence training techniques, so the model truly “sees” long inputs. Publishing this kind of data and its construction scripts means downstream teams don’t have to grope their way to a long-context training recipe from scratch.
4. Decontamination: A Challenge Full-Stack Open Source Must Confront
Once a benchmark is published, it almost inevitably enters internet corpora and gets crawled into various open-source datasets. The officials note that benchmark text is widely present in many public instruction-tuning and synthetic datasets. The problems that follow are:
- Scores on the relevant benchmarks are inflated, and rankings become distorted;
- The model may memorize answers rather than master abilities, and its performance falls back on real distributions after deployment.
The standard approach to decontamination is n-gram overlap matching against the evaluation set, then deleting or scrambling matched training samples:
from collections import defaultdictdef normalize(text):# Lowercase, keep only word characters, unify whitespacereturn re.findall(r"\w+", text.lower())def ngrams(tokens, n=13):return (tuple(tokens[i:i + n]) for i in range(len(tokens) - n + 1))def build_index(benchmark_docs, n=13):index = defaultdict(list)for doc_id, doc in enumerate(benchmark_docs):for gram in ngrams(normalize(doc), n):index[gram].append(doc_id)return indexdef is_contaminated(sample, index, max_overlap=1):hits = defaultdict(int)for gram in ngrams(normalize(sample)):for doc_id in index.get(gram, ()):hits[doc_id] += 1if hits[doc_id] >= max_overlap:return Truereturn False
The official results reveal a counterintuitive phenomenon: after decontamination, scores on some benchmarks actually drop. For example, on a question-answering benchmark like DROP that requires discrete reasoning, scores fall back after removing contaminated data. This doesn’t mean the model got weaker; on the contrary, part of the previous score came from memorization, and the post-decontamination numbers are closer to true ability. So evaluation reports need to give both “before and after decontamination” results and clearly label the evaluation-set version and matching strategy; otherwise scores across different teams lack comparability.
Decontamination has its own engineering difficulties:
- Threshold trade-offs: too strict a threshold wrongly deletes normal domain text; too loose, and contaminated samples that change a few words slip through.
- Derivative data: synthetic instruction data is often generated by rewriting benchmark questions as seeds, so the derivative chain needs to be included in matching.
- Dynamic benchmarks: private test sets and periodically rotated question sets can reduce contamination probability but require ongoing maintenance.
5. Post-Training: From Instruction Following to Reinforcement Learning with Verifiable Rewards
The flagship reasoning model in this series adopts a three-stage post-training recipe of SFT → DPO → RLVR. Each stage has its role:
- SFT (supervised fine-tuning): uses high-quality “instruction — reasoning process — answer” samples to teach the model the format and basic paradigm of reasoning;
- DPO (direct preference optimization): uses paired “better/worse response” data so the model learns to choose the better one among multiple reasonable answers;
- RLVR (reinforcement learning with verifiable rewards): on tasks like math and code that have standard answers or runnable tests, it gives rewards directly via rules or execution results, letting the model improve itself through many rounds of sampling, scoring, and updating.
5.1 Preference Data: The Delta Learning Approach Disclosed by the Official
The quality of preference data largely determines the effectiveness of the DPO stage. The official disclosed a construction approach based on “differences,” whose core can be summarized in three points:
- Same-source sampling: for the same instruction, have the model (or multiple different versions / sampling temperatures) generate multiple responses, ensuring the compared objects differ only in “quality”;
- Difference localization: find judgeable quality differences between responses — such as whether reasoning steps are complete, whether format constraints are followed, and whether the final answer is correct — to construct (chosen, rejected) pairs;
- Controllable difficulty: the difference between a preference pair should be neither too large (the model learns no fine-grained signal) nor nearly nonexistent (large annotation noise).
The value of this approach is scalability: you don’t need to have humans annotate each sample individually; you just need to define a clear “good” and “bad” to generate preference data in batches. A common practice is a three-tier combination of “rule filtering + small-model scoring + human spot-checking” to balance cost and quality.
5.2 Reinforcement Learning: Removing KL Divergence and Using Token-Level Loss
The official disclosed two improvements to the accompanying reinforcement learning framework:
1) Removing the KL divergence penalty term. Classic PPO-like algorithms add a KL penalty between the current policy and the reference policy to the reward, preventing the policy from drifting too far from the initial model. But in RLVR scenarios, the training data itself is sampled by the model (on-policy) and the reward comes from verifiable rules, so removing the KL term both reduces the per-step cost of computing the reference model’s log-probabilities and avoids over-constraining the policy’s evolution.
It should be noted that removing KL is not cost-free: the policy may gradually collapse into a few output modes, and entropy may drop too quickly. In practice, this is usually combined with sufficient data diversity, appropriate sampling temperature and learning-rate control, and monitoring of diagnostic metrics such as generation length, answer distribution, and entropy.
2) Introducing token-level loss. The traditional approach averages a whole response’s sequence loss at the sequence level, diluting the contribution of individual tokens in long responses. In reasoning tasks, the key reasoning steps often occupy only a few tokens, so sequence-level loss can “average away” the gradient signal. With token-level loss, each token’s contribution to the optimization objective is explicitly counted, so the key steps in long chain-of-thought reasoning are more likely to receive effective gradients.
From a systems perspective, both changes point to the same goal: reducing the inconsistency between training and inference. The probability distribution computed during training should be aligned as much as possible with the distribution used during inference sampling, to avoid the “trains well, runs poorly” bias.
5.3 RL-Zero: A Pure Reinforcement Learning Control
RL-Zero starts directly from the base model, without SFT or preference alignment, using only verifiable rewards for reinforcement learning. It answers a fundamental question: how much of reasoning ability comes from “the format that was taught,” and how much comes from “reasoning processes self-organized under a reward signal.” This kind of control experiment is very valuable for understanding the necessity of the post-training recipe, and it offers a path for resource-constrained teams: if a task can be verified automatically (math answer comparison, code unit-test pass rate, format checks), you can prioritize RLVR.
6. A Reusable Engineering Practice Checklist
Abstracting the above designs yields a practice checklist that applies to most teams.
1. Data
- Establish a standard pipeline of “collect — parse — clean — deduplicate — quality-score — mix — decontaminate,” keeping traceable metadata (source, license, processing version) at every step;
- Prefer low-cost heuristics and lightweight classifiers for quality scoring, reserving expensive quality judgments for post-sampling spot-checks;
- Determine mixtures on small-scale proxy experiments (e.g., 1B–10B tokens) and then scale to the full amount, which significantly saves compute;
- Complete decontamination before training starts, and re-check after every mixture change.
2. Training
- Fix random seeds, record the full configuration and data version, and save intermediate checkpoints at fixed token intervals, to enable analysis of capability curves versus training volume;
- Training logs should record not only loss but also the actual consumption ratio of each domain’s data, gradient norms, and the learning-rate curve, so that when problems arise you can pinpoint whether it’s a data issue or an optimization issue;
- In the post-training stage, monitor KL (if retained), entropy, response length, and reward distribution to detect policy collapse early.
3. Evaluation
- Report both “before and after decontamination” numbers, and label the evaluation-set version and matching threshold;
- Beyond standard benchmarks, prepare internal evaluation sets close to real business, and calibrate public scores against the real distribution;
- For RLVR-type tasks, prefer designing rewards that can be verified automatically, to reduce the noise and cheating room introduced by reward models.
4. Infrastructure
On the cloud, you can reuse mature general-purpose capability combinations: object storage to hold datasets and checkpoints, container platforms to host distributed training and inference, and logging and monitoring services to track training metrics. The general product stacks of cloud providers such as Baidu AI Cloud can also cover these steps. Focusing your attention on the model and data themselves, rather than repeatedly building the underlying foundation, is the more cost-effective choice for most teams.
7. Limitations and Risks
Full-stack open source does not mean zero-cost reusability. At least four kinds of risk must be noted:
- Licensing and compliance: the license terms of data and code need to be checked layer by layer, especially for corpora crawled from the internet; evaluate source legitimacy before commercial use;
- Compute barrier: 5.9T-token-level pretraining requires a fairly large compute cluster, so most teams are better off taking the “midtraining + post-training” route, doing domain adaptation on top of a public base;
- Engineering complexity from data scale: managing, deduplicating, and sampling trillions of tokens is itself a systems-engineering effort, and small teams need to carefully weigh the return on investment;
- Contamination is hard to eliminate: as long as benchmarks are public, contamination cannot be fully avoided, so continuously maintaining private, dynamic evaluation sets is a necessary hedge.
Conclusion
What is most worth learning from this open-source series is not any specific number, but that it turns LLM development from “alchemy” into “a decomposable engineering discipline”: data mixtures have a rationale, the training process is recorded, and the post-training recipe is reproducible. For developers and businesses, the real opportunity lies in this: rather than training a base from scratch, build your own model capabilities on top of the public full pipeline, using domain data, verifiable rewards, and rigorous evaluation. The value of open source has never been just a downloadable set of weights, but a whole methodology that can be understood, questioned, and improved.
