Technical Practices in Large Language Model Development and Iteration
This article analyzes the technical practices and architectural evolution of developing large language models (LLMs), using a 67B bilingual model as a reference. It covers key areas including pre-training data strategies, attention optimization, learning rate scheduling, alignment via Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO), and architectural advancements like Mixture-of-Experts (MoE) and long-context capabilities. It also explores vertical domain customization and deployment utilizing cloud infrastructure.
Technical Practices in Large Language Model Development and Iteration
Introduction
Large Language Models (LLMs) have become the core component of modern artificial intelligence infrastructure. From intelligent customer service and text translation to financial analysis and medical assistance, the application boundaries of LLMs continue to expand. However, constructing a model with tens or even hundreds of billions of parameters requires more than simply stacking computing power; it involves the systematic coordination of data engineering, training frameworks, architectural design, and alignment optimization. Using a mainstream 67B bilingual (Chinese and English) model as a technical reference, this article systematically outlines the key technical decisions and engineering practices in LLM development, along with the architectural evolution seen in subsequent model iterations, providing developers with a reusable methodology.
I. Pre-training Phase: Synergy of Data, Architecture, and Training Frameworks
1.1 High-Quality Corpus Construction Strategies
The scale and quality of pre-training data directly determine the upper limit of a model’s capabilities. Leading industry practices typically employ a mixed Chinese-English corpus of approximately 2 trillion tokens, executing aggressive deduplication strategies during the data cleaning phase. Deduplication not only saves computing resources but also prevents the model from overfitting to repeated samples, thereby improving generalization. A typical data processing pipeline includes:
- Document-level Deduplication: Identifying near-duplicate documents using locality-sensitive hashing algorithms like MinHash and SimHash.
- Sentence-level Filtering: Removing low-quality, high-noise fragments to control the proportion of garbled text and advertisements.
- Domain Ratio Tuning: Balancing the ratio of general web pages, books, code, mathematics, and academic corpora to prevent a single distribution from dominating.
- Multilingual Balancing: For mixed Chinese-English training, carefully adjusting the sampling weights of both languages to prevent capability imbalances.
1.2 Attention Optimization in the Transformer Architecture
At the architectural level, 67B-level models commonly introduce Grouped-Query Attention (GQA) based on the standard Transformer. Unlike traditional Multi-Head Attention, which allocates independent key-value heads to each query head, GQA allows multiple query heads to share the same group of key-value heads. This significantly compresses the KV cache memory footprint during the inference phase and improves decoding throughput, with almost no loss in model expressiveness. This design has become a standard for inference optimization in modern LLMs.
1.3 Learning Rate Scheduling and Training Efficiency
Hyperparameter scheduling during training is equally critical. Compared to the common Cosine Decay strategy, a multi-stage learning rate scheduler divides the training process into warmup, stable, and annealing phases. It maintains a high learning rate during the stable phase to accelerate convergence, and decays rapidly in the final phase for fine-tuning. The advantage of this approach is that if training is interrupted or requires expanded data, it can resume from the stable phase without restarting the entire scheduling cycle, making it particularly friendly for long-term, large-scale training tasks.
At the distributed training level, it is usually necessary to develop or deeply customize the training framework, integrating multi-dimensional parallelism strategies such as data parallelism, tensor parallelism, and pipeline parallelism, combined with attention computation kernel optimization (e.g., operator fusion, memory recomputation) to maximize hardware utilization. A simple training configuration is illustrated below:
# Multi-stage learning rate scheduler illustrationdef multistage_lr(step, total_steps, base_lr):warmup = int(total_steps * 0.02)anneal = int(total_steps * 0.9)if step < warmup:return base_lr * step / warmup # Linear warmupelif step < anneal:return base_lr # Stable phaseelse:return base_lr * (1 - (step - anneal) / (total_steps - anneal)) # Linear annealing
II. Alignment Phase: From Supervised Fine-Tuning to Preference Optimization
Pre-trained models only possess text continuation capabilities. To transform them into usable conversational assistants, they must undergo an Alignment process. The mature two-stage paradigm in the industry is SFT + Preference Optimization.
2.1 Supervised Fine-Tuning (SFT)
The core of the SFT phase is constructing a large-scale, highly-covered instruction dataset. A typical practice involves aggregating over 1 million to 1.5 million instruction samples, covering multiple dimensions such as mathematical reasoning, code generation, knowledge Q&A, and safety. Key points for data quality control include:
- Instruction Diversity: Avoiding mode collapse caused by templated instructions.
- Response Standardization: Establishing annotation standards for format, length, and logical structure.
- Safety Sample Ratio: Constructing specific samples for scenarios like refusal to answer and value guidance.
- Multi-turn Dialogue Construction: Training with real multi-turn contexts to alleviate context forgetting in long conversations.
2.2 Direct Preference Optimization (DPO)
After SFT, Direct Preference Optimization (DPO) becomes a key technology in the alignment phase. Compared to the traditional two-stage “reward model training + reinforcement learning” approach, DPO directly optimizes the policy model on pairwise preference data, eliminating the need for a separate reward model and complex RL training processes. It is more stable in engineering and has lower tuning costs. Practices show that DPO has a significant effect on mitigating repetitive generation and improving multi-turn dialogue quality. The core idea of its loss function is to maximize the implicit reward difference of the preferred response relative to the rejected response:
# Simplified expression of DPO lossimport torchdef dpo_loss(logp_chosen, logp_rejected, beta=0.1):logits = beta * (logp_chosen - logp_rejected)return -torch.log(torch.sigmoid(logits)).mean()
III. Architectural Evolution: From Dense Models to Mixture-of-Experts
3.1 The Value of the Mixture-of-Experts (MoE) Architecture
Dense models require activating all parameters during each inference, and the computational cost grows linearly with the parameter count. The Mixture-of-Experts (MoE) architecture splits the feedforward network into multiple “expert” sub-networks and dynamically selects a small number of experts for each token via a gating routing mechanism. This allows for a massive expansion in total parameters while keeping the actual activated parameters per inference low, achieving the goal of “large capacity, low overhead.” Key challenges in engineering implementation include routing load balancing (preventing a few experts from overheating), cross-device communication overhead under expert parallelism, and the stable training of routing strategies.
3.2 Continued Innovation in Attention Mechanisms
For long-text scenarios, the industry has proposed deep transformation concepts for the attention structure. A typical direction is the introduction of the Latent Attention mechanism: compressing the key-value matrix into a low-dimensional latent space before performing attention computation. During inference, only the low-dimensional representation needs to be cached, significantly reducing KV cache overhead for long sequences and making ultra-long context processing feasible in terms of memory and latency. This direction is in the same lineage as GQA, reflecting the design philosophy of “trading structure for efficiency.”
3.3 Long Context and Agent Capabilities
As the context window expands to the million-token level, models can directly process entire technical documents, complete code repositories, or long session histories. This capability is deeply coupled with Agent scenarios: the model needs to maintain task state, plan multi-step tool calls, and process intermediate result feedback within a long context. Supporting such capabilities requires adding long-range dependency samples and tool usage trajectories to the training data, along with engineering measures like chunk processing and context compression on the inference side.
3.4 Transparent Reasoning Processes
Another important evolution direction is having the model explicitly output its reasoning process. By rewarding correct reasoning chains rather than just the final answer during the reinforcement learning phase, the model can generate complete thought trajectories, allowing users to review the rationality of each reasoning step. This not only improves performance on mathematical and logical tasks but also significantly enhances the model’s interpretability and trustworthiness in high-risk scenarios (such as medical and financial decision-making assistance).
IV. Vertical Domain Customization and Deployment
General foundation models often require further fine-tuning for specific vertical scenarios. Taking the financial and medical domains as examples, the deployment path typically includes:
- Continued Pre-training on Domain Corpora: Injecting industry terminology and business knowledge.
- Instruction Fine-Tuning: Constructing instruction data for specific tasks like financial report interpretation and medical record summarization.
- Retrieval-Augmented Generation (RAG): Integrating private knowledge bases into the inference chain via vector retrieval to reduce hallucinations.
- Compliance and Safety Alignment: Constructing safety preference data according to industry regulatory requirements.
At the deployment level, enterprises typically rely on cloud infrastructure for training and inference hosting. For example, utilizing general cloud product capabilities like elastic computing, container platforms, object storage, and monitoring alarms provided by Baidu AI Cloud, developers can build a complete pipeline from data processing and model training to online inference. They can also leverage model service platforms for inference acceleration and elastic scaling, reducing the operational burden of self-built infrastructure.
Conclusion
Starting from 67B-level dense models and gradually evolving to Mixture-of-Experts architectures, latent attention, million-level contexts, and transparent reasoning, the technical roadmap of LLMs presents a clear trajectory: rooted in data quality, trading architectural innovation for efficiency, ensuring usability through alignment technologies, and controlling costs via engineering systems. For developers, understanding these core methodologies holds more long-term value than chasing a single model version. As model capabilities and cloud infrastructure continue to mature, the deep implementation of LLMs in more industry scenarios is highly anticipated.
