The Journey to Your First LLM: A Full Training Pipeline from Base Model Release
This article walks through the end-to-end pipeline behind releasing a first in-house large language model, using a January 2024 base model release as the reference point. It covers architecture choices made under compute constraints, the data engineering layers that set the capability ceiling, training stability and large-scale compute engineering, layered evaluation and alignment, and inference deployment cost controls. Readers will get a practical, time-ordered view of the pitfalls every team hits on the way from zero to one.
1. Background and Why It Matters
On January 5, 2024, an AI team publicly released its first in-house large language model, with parameter counts spanning several tiers, alongside a technical report and open weights. Setting the specific name aside, the event carries general engineering significance: it marks a team closing the full loop on a base model from scratch, with all five stages working end to end — data, architecture, training, evaluation, and release.
For developers and enterprise users, the release itself is not the interesting part. What matters is the set of problems any “first base model” inevitably runs into: a limited compute budget, uneven data quality, sudden loss spikes mid-training, and evaluation results that cannot be reproduced. This article reconstructs that chain in chronological order.
2. Architecture Selection: Subtract Under Constraints
The first principle for a first model is “convergent and reproducible,” not structural novelty. The mainstream approach is a decoder-only causal language model combined with the following engineering components:
- Pre-Norm normalization to suppress gradient explosion in deep stacks;
- Rotary position embeddings to improve long-context extrapolation;
- SwiGLU-style gated feed-forward layers, which improve convergence efficiency at the same parameter count;
- Width ratios between attention and MLP set from empirical values, avoiding basic mistakes such as a head count that does not divide evenly.
Illustrative configuration (pseudocode, expressing ratios only):
config = {"hidden_size": 4096,"num_layers": 32,"num_heads": 32, # hidden_size % num_heads == 0"ffn_ratio": 8/3, # common range for gated feed-forward"max_seq_len": 4096,"norm": "pre_rmsnorm","pos_embed": "rope",}
The key judgment in selection: every increment in structural complexity multiplies debugging cost. A first model should leave the budget for data and compute.
3. Data Engineering: The Stage That Sets the Ceiling
Most of the variance in model capability comes from data rather than architecture. A pipeline that actually ships has four layers:
- Collection and deduplication: dual document-level and paragraph-level deduplication to reduce memorization caused by repeated corpora;
- Quality filtering: rules (length, symbol ratio, language identification) combined with a lightweight classifier score, using stratified sampling rather than a single hard threshold;
- Mixing and curriculum: general corpora as the main body, with code and math data weighted up in stages, and high-quality instruction data added late in the run;
- Contamination prevention: dual n-gram and semantic similarity comparison against evaluation sets, avoiding inflated scores from test leakage.
Data versions must be bound one-to-one with training runs, recording hashes and mixture manifests; otherwise experimental conclusions are not reproducible.
4. Training Stability and Compute Engineering
At thousand-GPU scale, the main risks are hardware failures and numerical anomalies. Engineering essentials:
- Parallelism strategy: a combination of data, tensor, and pipeline parallelism, tuned from measured memory and bandwidth;
- Mixed precision: BF16 as the default, with normalization and loss accumulation kept in FP32;
- Gradient clipping plus learning rate warmup and cosine decay, with warmup steps at roughly 1%–2% of total steps;
- Periodic checkpoints that support automatic resume after a failure;
- Full-pipeline observability: collect loss, gradient norm, throughput, temperature, and memory usage into a logging service, with alerting thresholds configured.
On Baidu AI Cloud, workloads of this kind typically run on a container platform, with training data in object storage, the task queue decoupled by a message queue, and logs and metrics handled separately by the logging service and the monitoring and alerting service — forming a reusable training foundation.
5. Evaluation and Alignment
Evaluation should be layered into three tiers: core capabilities (language understanding, reasoning, code), safety and values, and a custom set for business scenarios. Requirements include fixed decoding parameters, fixed prompt templates, averaging over multiple samples, and retaining raw outputs for review.
In the alignment stage, start with supervised fine-tuning, then use preference optimization methods to converge on style and refusal boundaries. One caveat: alignment sacrifices some of the base model’s diversity, so the strength should be weighed against business risk.
6. Inference Deployment and Cost
Release is only the start. On the deployment side, the focus is balancing throughput and latency: continuous batching, KV cache reuse, and quantization (weights to 8-bit or 4-bit) are the three measures with the clearest payoff. For capacity planning, reserve 1.5x peak QPS, and put degradation and rate-limiting policies in place.
7. Conclusion
The value of a first base model lies in closing the loop and building a durable pipeline. Keep the architecture simple, make the data solid, and make observability complete — and the marginal cost of every subsequent iteration drops significantly.
