Architecting the First-Generation Open-Source Dense LLM: Design Choices and Engineering Practices
This article breaks down the core architectural and engineering decisions behind a first-generation open-source dense large language model. It covers the rationale for reusing a proven dense Transformer stack, model size variants (7B and 67B) with MHA vs. GQA attention, a two-trillion-token bilingual data pipeline with deduplication and filtering, post-training via SFT and DPO, and a bilingual evaluation strategy. Practical insights are provided for teams planning to build or customize their own LLM foundation.
Why Start with a Proven Dense Architecture
The first generation of a general-purpose LLM series typically serves as the foundation. A widely validated industry path is to first reproduce a dense architecture that has already been proven effective, then improve performance through data quality, training details, and post-training algorithms — rather than overturning established paradigms from the start.
This approach offers three practical benefits:
- Lower technical risk: The convergence properties of mature components (decoder-only Transformer, RoPE positional encoding, SwiGLU activation, RMSNorm) are well-documented, allowing the team to focus on data and engineering.
- Easier horizontal comparison: By following the community’s mainstream structure, the model can be fairly benchmarked against other open-source models at similar parameter scales, quickly verifying competitiveness.
- Infrastructure reuse: Tokenizers, training frameworks, distributed parallelism strategies, and evaluation pipelines become reusable assets, significantly reducing iteration cost for future versions.
Model Specifications and Versions
The first-generation model typically offers two parameter scales to serve different hardware constraints:
| Scale | Use Case | Typical Attention Design |
|---|---|---|
| Small (~7B parameters) | Single-GPU inference, teaching, research | Multi-Head Attention (MHA) |
| Large (~67B parameters) | High-capacity reasoning and generation | Grouped Query Attention (GQA) |
Each scale is further split into two variants:
- Base model: Pre-trained only, retaining the strongest continuation and general representation abilities, suitable for downstream fine-tuning.
- Chat model: Adds alignment training on top of the base, enabling instruction following and multi-turn conversation, ready for application use.
Pre-Training Data Construction: Deduplication, Filtering, and Shuffling
The first-generation model typically uses about two trillion tokens of bilingual (Chinese and English) corpus. Data engineering is the core variable determining performance upper bound. The typical three-stage pipeline is as follows:
3.1 Deduplication
Web, book, and code corpora contain massive redundancy across sources. Document-level and paragraph-level near-dedup using fingerprinting methods (e.g., MinHash, SimHash) can eliminate roughly 90% of duplicate documents in a large corpus. Deduplication not only saves compute but also prevents overfitting to repeated samples and reduces memorization leakage risks.
3.2 Filtering
Quality filtering is applied to the remaining corpus, commonly using:
- Heuristic rules based on length, symbol ratio, and garbled-text detection;
- Quality scoring with a small classifier model;
- Language identification and harmful content filtering to ensure compliance.
3.3 Shuffling and Mixing
Different domain corpora (web, academic, code, encyclopedia, etc.) are mixed according to empirically determined ratios and thoroughly shuffled, preventing the model from drifting toward one domain distribution during later training stages. The mixing ratio is usually determined through small-scale ablation experiments before scaling up to full training.
Attention Mechanism Selection: MHA vs. GQA Trade-offs
The attention module is a major source of inference cost. In autoregressive generation, each new token reads the entire history of Key/Value caches (KV Cache), whose size is proportional to the number of attention heads.
- MHA (Multi-Head Attention): Each query head has its own Key and Value heads, offering the strongest expressiveness — suitable for small models, where the 7B-scale KV cache is not yet a bottleneck.
- GQA (Grouped Query Attention): Multiple query heads share a group of Key/Value heads, reducing KV cache size several-fold. At 67B scale with long context, this significantly cuts memory and bandwidth, with typically minimal accuracy loss.
Illustrative pseudo-code:
# GQA Key/Value reuse logic (illustrative)def gqa_forward(q, k, v, num_q_heads, num_kv_heads):group_size = num_q_heads // num_kv_heads# Broadcast KV heads to corresponding query groupsk = repeat_interleave(k, group_size, dim=head_axis)v = repeat_interleave(v, group_size, dim=head_axis)return scaled_dot_product_attention(q, k, v)
This differentiated choice — “small model preserves expressiveness, large model reduces cost” — reflects pragmatic engineering thinking in the first-generation design.
Post-Training: Combining SFT and DPO
Pre-training produces a model that “continues text.” To turn it into a conversational assistant, two alignment steps are needed:
- Supervised Fine-Tuning (SFT): Train on high-quality instruction–response pairs to teach the model to understand instructions and structure responses. Data quality matters far more than quantity here; tens of thousands of well-curated examples can yield significant improvement.
- Direct Preference Optimization (DPO): Using human or automatically labeled preference pairs (chosen / rejected), directly optimize the policy with a contrastive loss, without training a separate reward model. The training pipeline is simpler and more stable.
# Core idea of the DPO lossloss = -log(sigmoid(beta * (policy_logp(chosen) - ref_logp(chosen)- policy_logp(rejected) + ref_logp(rejected))))
The reference model (ref) is typically a frozen copy after SFT, preventing the policy from drifting too far.
Evaluation Methodology: Horizontal Comparison on Bilingual Benchmarks
The persuasiveness of a first-generation model comes from reproducible evaluation. A common approach selects public bilingual (Chinese and English) benchmarks covering knowledge QA, reasoning, code, and math, and scores them against same-scale international open-source models under identical settings. Practical lessons include:
- Report separate scores for base and chat models to avoid confounding effects of post-training on benchmarks.
- Report both English and Chinese performance to validate the effectiveness of bilingual data mixing.
- For code and math, use pass@k and exact-match metrics respectively, avoiding misleading conclusions from a single metric.
If the large-scale version consistently outperforms mainstream open-source competitors of the same parameter size on most benchmarks, the “reproduce architecture + better data” approach is validated.
Open-Source Strategy: The Starting Point of an Ecosystem
Releasing the first-generation model as open weights has implications beyond the single version:
- Builds trust: Downloadable, reproducible, and (depending on the license) commercially usable weights let the community quickly verify capabilities.
- Attracts feedback: Real-world usage by researchers and enterprises exposes weaknesses, directly guiding next-generation data and architecture improvements.
- Fosters an ecosystem: Community contributions such as fine-tuning, quantization, and inference acceleration around the model feed back into compatibility for future versions.
For teams looking to deploy such an open-source model in the cloud, a practical path is to use generic cloud services: container platforms host inference workloads, object storage manages model weights and datasets, and logging and monitoring ensure online stability — forming a complete chain from model to application.
Conclusion
The success pattern of the first-generation general-purpose LLM can be summarized in four points: reproduce a proven dense architecture to control risk, build high-quality bilingual corpora through a rigorous data pipeline, choose attention mechanisms differentiated by scale to balance capability and cost, and align via SFT and DPO before releasing as open source. This methodology serves not only as a blueprint for a specific model but also as a reusable engineering guide for any team aiming to develop or deeply customize large language models.
