SuperAPI AI Directory

Qwen2.5-Coder - Alibaba Qwen team's open-source full-series code models, covering six mainstream model sizes

Author: AI小集 · Original source: AI工具集

What is Qwen2.5-Coder

Qwen2.5-Coder is a full series of code generation models launched by the Alibaba Qwen team, promoting the development of open-source code language models. It performs excellently on tasks such ascode generation, code reasoning, and code repair. The series covers six mainstream model sizes at different scales, 1.5B/7B/0.5B/3B/14B/32B, meeting the needs of different developers.

Qwen2.5-Coder's flagship model, Qwen2.5-Coder-32B-Instruct, has achieved the best performance among open-source models on multiple popular code generation benchmarks, with code capabilities comparable to GPT-4o. It demonstrates strong performance in code generation, code repair, and code reasoning, supports more than 40 programming languages, and has achieved impressive results on the McEval and MdEval benchmarks.

Qwen2.5-Coder focuses on human preference alignment and was evaluated through the internally annotated code preference evaluation benchmark Code Arena, showing alignment advantages in human preferences. The model family's parameter configurations and licensing information are also listed in detail, among which the 0.5B, 1.5B, 7B, 14B, and 32B models use the Apache 2.0 license, while the 3B model uses a research-use license.

Qwen2.5-Coder

Qwen2.5-Coder's main features

  • Code generation: Qwen2.5-Coder generates code snippets based on given programming prompts and supports multiple programming languages.
  • Code reasoning: The model has code reasoning capabilities, understands code logic, and provides relevant code suggestions.
  • Code repair: Helps identify and fix errors in code.
  • Multilingual support: Supports up to 92 programming languages, including common ones such as Python, Java, C++, as well as niche languages.
  • Diversity of model sizes: Qwen2.5-Coder provides six mainstream model sizes ranging from 0.5B to 32B, meeting the needs of different developers.
  • Instruction tuning: Qwen2.5-Coder-Instruct further improves performance on multiple tasks through instruction fine-tuning.
  • Mathematical ability: Qwen2.5-Coder-Instruct performs excellently on code and math tasks, combining programming and mathematical capabilities.

Qwen2.5-Coder's technical principles

  • Autoregressive language model: Qwen2.5-Coder adopts an autoregressive mechanism, meaning the model predicts the next most likely token based on the existing text sequence, enabling the model to perform excellently in text generation and completion tasks.
  • Model architecture: Qwen2.5-Coder is based on the Qwen2.5 architecture and adopts a variant of the Transformer model, with different parameter scales such as 1.5B, 7B, and 32B. The models differ in aspects such as hidden layer size, number of layers, number of query heads, number of key-value heads, head size, intermediate layer size, and embedding layer tying.
  • Pretraining data processing: Qwen2.5-Coder's pretraining data includes source code data, text-code mixed data, synthetic data, mathematical data, and text data. These data are carefully cleaned and formatted to ensure quality and consistency. The data ratio is 70% code, 20% text, and 10% mathematical data.
  • Training strategy:
    • File-level pretraining: At this stage, the model learns the basic knowledge and structure of programming languages by processing the contents of individual files, and the data used are cleaned code files.
    • Repository-level pretraining: This stage enhanced the model's long-context processing capability, expanded the context length to 32K tokens, adjusted the base frequency of Rotary Position Embedding (RoPE), and used the YARN mechanism to handle longer sequences.
  • Post-training and Instruction Tuning:
    • Instruction Data Generation: By building language-specific agents, collaborative discussion protocols, adaptive memory systems, etc., high-quality instruction data is generated.
    • Training Strategy: A coarse-to-fine fine-tuning strategy is adopted, first using a large number of diverse instruction samples for fine-tuning, and then using high-quality instruction samples through rejection sampling and supervised fine-tuning to improve performance.
  • Introduction of Special Tokens: To help the model better understand code, Qwen2.5-Coder introduced several special tokens during training, and these tokens play specific roles in the code processing pipeline.
  • Multilingual Support: Qwen2.5-Coder supports multiple programming languages. Through unique data cleaning and mixing ratios in the pretraining stage, the model performs excellently across multiple programming languages.
  • Long-Context Capability: By adjusting the base frequency of RoPE and applying the YaRN mechanism, Qwen2.5-Coder can handle longer contexts, which is crucial for code completion and understanding the entire codebase.
  • Code Generation Capability: Qwen2.5-Coder achieved the best performance among open-source models on multiple popular code generation benchmarks and reached performance competitive with GPT-4o.

Qwen2.5-Coder Project Address

Application Scenarios of Qwen2.5-Coder

  • Daily Programming Work: Developers use Qwen2.5-Coder to assist in writing code, improve work efficiency, and reduce repetitive work.
  • Code Learning and Practice: Programming beginners use Qwen2.5-Coder to learn programming language syntax and best practices, and improve programming skills through practice.
  • Education and Training: In programming education, Qwen2.5-Coder serves as a teaching aid to help students understand complex concepts and provide immediate feedback on programming exercises.
  • Code Review and Quality Assurance: During code review, Qwen2.5-Coder helps identify potential code issues, provide improvement suggestions, and ensure code quality.
  • Automated Testing: Qwen2.5-Coder generates test cases, helps automate the testing process, and improves the coverage and efficiency of software testing.