Scaling Large Language Models: Technical Practices and Long-Term Strategies
Scaling large language models (LLMs) requires more than just accumulating compute power; it demands a profound understanding of scaling laws and rigorous engineering practices. From a long-term perspective, building open-source, commercially viable foundation models necessitates deep investments in data quality, architecture design, and training frameworks. Using the public technical practices of an industry open-source model (available in 7B and 67B parameter scales) as a case study, this article dissects the complete technical pipeline from data construction to model alignment, offering developers actionable architectural references.
The evolution of large language models (LLMs) goes beyond merely accumulating compute power; it requires a profound understanding of scaling effects and rigorous engineering practices. From a long-term perspective, building an open-source, commercially viable foundation model necessitates deep investments in data quality, architecture design, and training frameworks. Using the public technical practices of an industry open-source model (offering both 7B and 67B parameter specifications) as an example, this article deeply dissects its complete technical pipeline from data construction to model alignment, providing developers with actionable architectural references.
1. Data Engineering: Constructing Trillion-Level High-Quality Corpora
Data defines the cognitive boundary of a model. High-quality datasets directly determine the upper limit of a model’s foundational capabilities. During the pre-training phase, this open-source model constructed a massive corpus containing 2 trillion Chinese-English bilingual tokens, backed by rigorous data preprocessing strategies to ensure corpus quality.
1.1 Three-Stage Data Preprocessing Strategy
To eliminate data noise and redundancy, the research team designed a three-stage processing flow consisting of deduplication, filtering, and remixing:
- Deduplication: Removes exactly duplicated or highly similar documents to prevent the model’s generalization ability from degrading due to over-memorizing specific texts. MinHash and similar algorithms are typically used for approximate deduplication of large-scale corpora.
- Filtering: Combines rule-based methods with lightweight models to remove texts containing garbled characters, poor formatting, or harmful content. This step is critical for improving the data’s signal-to-noise ratio.
- Remixing: Re-proportions the data based on different domains and languages (Chinese and English) to ensure balanced development in cross-lingual understanding and domain-specific knowledge.
1.2 Tokenizer Design
The tokenizer converts text into discrete symbols understandable by the model. This model adopts the BBPE (Byte-level Byte-Pair Encoding) algorithm with a vocabulary size of 102,400. A larger vocabulary effectively reduces the token sequence length of complex corpora like Chinese and English, lowering computational overhead while improving compatibility with rare characters and multilingual symbols.
2. Model Architecture: Micro-Inheritance and Macro-Deepening
In terms of model architecture design, the research demonstrates a strategy of “inheriting mainstream experience at the micro level while conducting deep exploration at the macro level,” pursuing ultimate performance while maintaining training stability.
2.1 Component Optimization at the Micro Level
At the micro level, the architecture extensively draws on mainstream open-source foundation designs with refined adjustments:
- RMSNorm: Replaces traditional LayerNorm by omitting the centering operation, improving normalization efficiency while reducing computational overhead.
- SwiGLU Activation Function: Combines the GLU gating mechanism with the Swish function, providing stronger nonlinear expression capabilities to help the model fit complex features.
- RoPE (Rotary Position Embedding): Integrates positional information into Query and Key vectors, which not only supports long-sequence extension but also effectively captures relative positional relationships.
2.2 Deep Extension and Attention Mechanism Evolution at the Macro Level
At the macro level of layer design, the research team conducted deep extensions: the 7B model is designed with 30 layers, while the 67B model is deepened to 95 layers. Deeper networks help the model extract higher-order abstract features.
Regarding the attention mechanism, differentiated designs were applied based on parameter scales:
- 7B Model: Adopts Multi-Head Attention (MHA) to maximize feature capture capabilities at a smaller parameter scale.
- 67B Model: Adopts Grouped-Query Attention (GQA). At a massive parameter scale, GQA significantly reduces the KV Cache memory footprint during inference by allowing multiple Queries to share the same group of Keys and Values, substantially improving the throughput of long-text generation.
3. High-Performance Training Framework and Hyperparameter Optimization
Training trillion-token LLMs relies on efficient distributed training frameworks. This model utilizes a self-developed high-performance training framework, deeply integrating various parallelism technologies and acceleration operators.
3.1 Hybrid Parallelism Strategy and Operator Optimization
Faced with hundreds of billions of parameters and long-sequence inputs, a single parallelism strategy is insufficient. The framework integrates the following technologies:
- Data Parallelism (DP) and Tensor Parallelism (TP): Used to accelerate matrix calculations in forward and backward propagation.
- Sequence Parallelism (SP): Splits the sequence dimension across different devices for long sequences, reducing single-card memory pressure.
- Pipeline Parallelism (PP): Assigns different model layers to different devices, using micro-batch pipelines to mask communication latency.
Furthermore, the framework deeply integrates I/O-aware operators like Flash Attention, significantly improving hardware utilization by reducing read/write operations to HBM (High Bandwidth Memory).
Below is conceptual pseudocode for hybrid parallelism, demonstrating the internal coordination logic of the framework:
def train_step(model, batch, dp_group, tp_group, pp_group):# 1. Input data is split within the data parallel groupinput_batch = scatter_data(batch, dp_group)# 2. Forward propagation: combining tensor parallelism and pipeline parallelismfor layer in model.layers:# Tensor parallelism internally splits weights and aggregates gradients automaticallyhidden_states = tp_forward(layer, hidden_states, tp_group)# Pipeline parallelism passes activations between different stagesif is_pipeline_boundary(layer):hidden_states = send_recv_pipeline(hidden_states, pp_group)# 3. Compute loss and backpropagationloss = compute_loss(hidden_states)loss.backward()# 4. Gradient synchronization and optimizer updateall_reduce_gradients(dp_group)optimizer.step()
3.2 Hyperparameter Scaling Laws
The research also deeply explored the mapping relationship between hyperparameters (such as learning rate, batch size) and compute scale. It proposed a more precise strategy for model and data scale allocation, avoiding training divergence or suboptimal performance caused by improper hyperparameter settings during massive scaling.
4. Model Alignment: From Instruction Tuning to Preference Optimization
Pre-training endows the model with knowledge, while alignment endows it with “compliance” and “safety” capabilities. The research adopted a two-stage alignment strategy.
4.1 Supervised Fine-Tuning (SFT)
First, supervised fine-tuning was performed using approximately 1.5 million high-quality instruction data points. This data covers multiple tasks such as multi-turn dialogue, code generation, and logical reasoning, aiming to teach the model to understand human intent and follow instruction formats for output.
4.2 Direct Preference Optimization (DPO)
Traditional RLHF (Reinforcement Learning from Human Feedback) requires training a reward model and conducting complex PPO training, which has high engineering complexity and is prone to instability. This model adopts Direct Preference Optimization (DPO) to directly optimize the model using preference data. Through a derived closed-form solution, DPO transforms preference optimization into a simple classification loss function. This not only simplifies the training process but also significantly improves the model’s conversational coherence and safety.
5. Performance Evaluation and Enterprise-Level Practical Insights
In multiple general benchmarks, the 67B parameter version demonstrated excellent performance in mathematical reasoning, code generation, and comprehensive Chinese-English understanding, surpassing some mainstream closed-source models of the same scale. Safety evaluations also proved the effectiveness of the DPO strategy in constraining model outputs.
For enterprise developers, the scaling practices of such open-source models provide valuable experience. In actual business implementation, enterprises can rely on general computing infrastructures and large model platforms, such as Baidu AI Cloud, utilizing elastic GPU clusters, high-performance object storage, and mature distributed training tools to reproduce or fine-tune such LLMs. Long-termism is not just about algorithmic Scaling Laws; it is also about the long-term accumulation and robust support of underlying infrastructure capabilities. Through meticulous data engineering, rational architecture design, and efficient alignment strategies, enterprises are fully capable of building high-performance LLMs tailored to their business needs on top of open-source foundations.
