gabriellarson commited on
Commit
3be7777
·
verified ·
1 Parent(s): b2a55e1

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +130 -0
README.md ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ base_model:
6
+ - microsoft/NextCoder-32B
7
+ pipeline_tag: text-generation
8
+ library_name: transformers
9
+ tags:
10
+ - code
11
+ - chat
12
+ - microsoft
13
+ - nextcoder
14
+ - selekt
15
+ datasets:
16
+ - microsoft/NextCoderDataset
17
+ - microsoft/NextCoderDataset-Conversational
18
+ - bigcode/commitpackft
19
+ - bigcode/starcoderdata
20
+ ---
21
+
22
+ # NextCoder-32B
23
+ <p align="center">
24
+ <a href="https://github.com/microsoft/NextCoder">GitHub</a>&nbsp&nbsp | &nbsp&nbsp <a href="https://www.microsoft.com/en-us/research/publication/nextcoder-robust-adaptation-of-code-lms-to-diverse-code-edits/">Paper</a>
25
+ </p>
26
+ > NextCoder: Robust Adaptation of Code LMs to Diverse Code Edits (ICML'2025)
27
+
28
+ ## Introduction
29
+
30
+ NextCoder is the latest series of Code-Editing large language models developed using the Qwen2.5-Coder Instruct variants as base and trained with novel Selective Knowledge Transfer finetuning methodology as introduced in the paper. NextCoder family model comes in 3 different sizes 7, 14, 32 billion parameters, to meet the needs of different developers.
31
+ Following are the key improvements:
32
+ - Significantly improvements in **code editing**, NextCoder-32B has performing on par with GPT-4o on complex benchmarks like Aider-Polyglot with performance increment of 44% from their base model.
33
+ - No loss of generalizibility, due to our new finetuning method **SeleKT**
34
+ - **Long-context Support** up to 32K tokens.
35
+
36
+ **This repo contains the NextCoder-32B model**, which has the following features:
37
+ - Type: Causal Language Models
38
+ - Training Stage: Post-training with SeleKT
39
+ - Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
40
+ - Number of Parameters: 32.5B
41
+ - Number of Paramaters (Non-Embedding): 31.0B
42
+ - Number of Layers: 64
43
+ - Number of Attention Heads (GQA): 40 for Q and 8 for KV
44
+
45
+ For more details, please refer to our [blog](), [GitHub](https://github.com/microsoft/NextCoder), [Paper](https://www.microsoft.com/en-us/research/publication/nextcoder-robust-adaptation-of-code-lms-to-diverse-code-edits/).
46
+
47
+ ## Requirements
48
+
49
+ The code of NextCoder is based on Qwen2.5 base models which has been in the latest Hugging face `transformers` and we advise you to use the latest version of `transformers`.
50
+
51
+ With `transformers<4.37.0`, you will encounter the following error:
52
+ ```
53
+ KeyError: 'qwen2'
54
+ ```
55
+
56
+ ## Quickstart
57
+
58
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
59
+
60
+ ```python
61
+ from transformers import AutoModelForCausalLM, AutoTokenizer
62
+ model_name = "microsoft/NextCoder-32B"
63
+ model = AutoModelForCausalLM.from_pretrained(
64
+ model_name,
65
+ torch_dtype="auto",
66
+ device_map="auto",
67
+ )
68
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
69
+ prompt = """
70
+ Fix the following function that divides two numbers to handle all the edge cases:
71
+ def divide(a, b)
72
+ returm a/b
73
+ """
74
+ messages = [
75
+ {"role": "user", "content": prompt}
76
+ ]
77
+ text = tokenizer.apply_chat_template(
78
+ messages,
79
+ tokenize=False,
80
+ add_generation_prompt=True
81
+ )
82
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
83
+ generated_ids = model.generate(
84
+ **model_inputs,
85
+ max_new_tokens=1024
86
+ )
87
+ generated_ids = [
88
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
89
+ ]
90
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
91
+ ```
92
+ ## Evaluation and Performance
93
+
94
+ | Models | HUMANEVALFIX | CANITEDIT | AIDER | POLYGLOT |
95
+ |--------|---------------|-----------|-------|----------|
96
+ | QwenCoder-2.5-3B | 73.2 | 37.1 | 36.8 | - |
97
+ | QwenCoder-2.5-3B-LoRA | 64.6 | 36.2 | 35.8 | - |
98
+ | QwenCoder-2.5-3B-SFT | 76.2 | 32.4 | 30.1 | - |
99
+ | **NextCoder-3B** | 75.6 | 42.4 | 37.6 | - |
100
+ | QwenCoder-2.5-7B | 73.8 | 48.1 | 59.4 | - |
101
+ | QwenCoder-2.5-7B-LoRA | 70.7 | 44.3 | 40.6 | - |
102
+ | QwenCoder-2.5-7B-SFT | 70.1 | 36.7 | 48.9 | - |
103
+ | **NextCoder-7B** | 81.1 | 50.5 | 65.7 | - |
104
+ | QwenCoder-2.5-14B | 87.8 | 58.1 | 66.9 | 9.3 |
105
+ | QwenCoder-2.5-14B-LoRA | 78.0 | 50.9 | 66.2 | 5.3 |
106
+ | QwenCoder-2.5-14B-SFT | 79.9 | 42.4 | 36.8 | 3.1 |
107
+ | **NextCoder-14B** | 89.8 | 60.2 | 72.2 | 12.2 |
108
+ | QwenCoder-2.5-32B | **90.2** | 61.0 | 72.9 | 16.4 |
109
+ | QwenCoder-2.5-32B-LoRA | 82.3 | 52.4 | 60.2 | 6.7 |
110
+ | QwenCoder-2.5-32B-SFT | 81.7 | 49.5 | 66.9 | 8.4 |
111
+ | **NextCoder-32B** | 88.9 | **62.4** | **74.7** | **23.6** |
112
+
113
+ *Comparison of base QwenCoder-2.5 models of different sizes and their SELEKT-enhanced versions across three code editing benchmarks.*
114
+
115
+ **Detailed evaluation results are reported in this [📑 paper](https://www.microsoft.com/en-us/research/publication/nextcoder-robust-adaptation-of-code-lms-to-diverse-code-edits/).**
116
+
117
+ ## Responsible AI Use
118
+ The base models (from the QwenCoder-2.5 family) are suspectible to malicious prompts and may generate or execute harmful code. Our finetuning does not enhance or impede such behaviors. The users should use the models and their outputs responsibly and with caution. Model outputs should be subjected to additional analysis, including manual inspection, and sandboxing before execution.
119
+
120
+ ## Citation
121
+
122
+ ```bibtex
123
+ @inproceedings{aggarwal2025nextcoder,
124
+ author = {Aggarwal, Tushar and Singh, Swayam and Awasthi, Abhijeet and Kanade, Aditya and Natarajan, Nagarajan},
125
+ title = {NextCoder: Robust Adaptation of Code LMs to Diverse Code Edits},
126
+ booktitle = {International Conference on Machine Learning},
127
+ year = {2025},
128
+ url = {https://www.microsoft.com/en-us/research/publication/nextcoder-robust-adaptation-of-code-lms-to-diverse-code-edits/},
129
+ }
130
+ ```