Text Generation
Transformers
Safetensors
English
qwen2
code
chat
microsoft
nextcoder
selekt
conversational
text-generation-inference
Instructions to use microsoft/NextCoder-32B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/NextCoder-32B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="microsoft/NextCoder-32B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("microsoft/NextCoder-32B") model = AutoModelForCausalLM.from_pretrained("microsoft/NextCoder-32B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use microsoft/NextCoder-32B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/NextCoder-32B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/NextCoder-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/microsoft/NextCoder-32B
- SGLang
How to use microsoft/NextCoder-32B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "microsoft/NextCoder-32B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/NextCoder-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "microsoft/NextCoder-32B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/NextCoder-32B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use microsoft/NextCoder-32B with Docker Model Runner:
docker model run hf.co/microsoft/NextCoder-32B
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
base_model:
|
| 6 |
+
- Qwen/Qwen2.5-Coder-32B-Instruct
|
| 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 |
+
---
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# NextCoder-32B
|
| 21 |
+
<p align="center">
|
| 22 |
+
<a href="https://github.com/microsoft/NextCoder">GitHub</a>   |    <a href="https://arxiv.org/abs/2503.03656">Arxiv</a>
|
| 23 |
+
</p>
|
| 24 |
+
|
| 25 |
+
> Published in ICML'2025
|
| 26 |
+
|
| 27 |
+
## Introduction
|
| 28 |
+
|
| 29 |
+
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.
|
| 30 |
+
Following are the key improvements:
|
| 31 |
+
- 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.
|
| 32 |
+
- No loss of generalizibility, due to our new finetuning method **SeleKT**
|
| 33 |
+
- **Long-context Support** up to 32K tokens.
|
| 34 |
+
|
| 35 |
+
**This repo contains the NextCoder-32B model**, which has the following features:
|
| 36 |
+
- Type: Causal Language Models
|
| 37 |
+
- Training Stage: Post-training with SeleKT
|
| 38 |
+
- Architecture: transformers with RoPE, SwiGLU, RMSNorm, and Attention QKV bias
|
| 39 |
+
- Number of Parameters: 32.5B
|
| 40 |
+
- Number of Paramaters (Non-Embedding): 31.0B
|
| 41 |
+
- Number of Layers: 64
|
| 42 |
+
- Number of Attention Heads (GQA): 40 for Q and 8 for KV
|
| 43 |
+
|
| 44 |
+
For more details, please refer to our [blog](), [GitHub](https://github.com/microsoft/NextCoder), [Arxiv](https://arxiv.org/abs/2503.03656).
|
| 45 |
+
|
| 46 |
+
## Requirements
|
| 47 |
+
|
| 48 |
+
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`.
|
| 49 |
+
|
| 50 |
+
With `transformers<4.37.0`, you will encounter the following error:
|
| 51 |
+
```
|
| 52 |
+
KeyError: 'qwen2'
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
## Quickstart
|
| 56 |
+
|
| 57 |
+
Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 61 |
+
|
| 62 |
+
model_name = "microsoft/NextCoder-32B"
|
| 63 |
+
|
| 64 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 65 |
+
model_name,
|
| 66 |
+
torch_dtype="auto",
|
| 67 |
+
device_map="auto",
|
| 68 |
+
)
|
| 69 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 70 |
+
|
| 71 |
+
prompt = """
|
| 72 |
+
Fix the following function that divides two numbers to handle all the edge cases:
|
| 73 |
+
|
| 74 |
+
def divide(a, b)
|
| 75 |
+
returm a/b
|
| 76 |
+
"""
|
| 77 |
+
messages = [
|
| 78 |
+
{"role": "user", "content": prompt}
|
| 79 |
+
]
|
| 80 |
+
text = tokenizer.apply_chat_template(
|
| 81 |
+
messages,
|
| 82 |
+
tokenize=False,
|
| 83 |
+
add_generation_prompt=True
|
| 84 |
+
)
|
| 85 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 86 |
+
|
| 87 |
+
generated_ids = model.generate(
|
| 88 |
+
**model_inputs,
|
| 89 |
+
max_new_tokens=1024
|
| 90 |
+
)
|
| 91 |
+
generated_ids = [
|
| 92 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 93 |
+
]
|
| 94 |
+
|
| 95 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 96 |
+
```
|
| 97 |
+
## Evaluation and Performanc
|
| 98 |
+
|
| 99 |
+
| Models | HUMANEVALEDIT | CANITEDIT | AIDER | POLYGLOT |
|
| 100 |
+
|--------|---------------|-----------|-------|----------|
|
| 101 |
+
| QwenCoder-2.5-3B | 73.2 | 37.1 | 36.8 | - |
|
| 102 |
+
| QwenCoder-2.5-3B-LoRA | 64.6 | 36.2 | 35.8 | - |
|
| 103 |
+
| QwenCoder-2.5-3B-SFT | 76.2 | 32.4 | 30.1 | - |
|
| 104 |
+
| **NextCoder-3B** | 75.6 | 42.4 | 37.6 | - |
|
| 105 |
+
| QwenCoder-2.5-14B | 87.8 | 58.1 | 66.9 | 9.3 |
|
| 106 |
+
| QwenCoder-2.5-14B-LoRA | 78.0 | 50.9 | 66.2 | 5.3 |
|
| 107 |
+
| QwenCoder-2.5-14B-SFT | 79.9 | 42.4 | 36.8 | 3.1 |
|
| 108 |
+
| **NextCoder-14B** | 89.8 | 60.2 | 72.2 | 12.2 |
|
| 109 |
+
| QwenCoder-2.5-32B | **90.2** | 61.0 | 72.9 | 16.4 |
|
| 110 |
+
| QwenCoder-2.5-32B-LoRA | 82.3 | 52.4 | 60.2 | 6.7 |
|
| 111 |
+
| QwenCoder-2.5-32B-SFT | 81.7 | 49.5 | 66.9 | 8.4 |
|
| 112 |
+
| **NextCoder-32B** | 88.9 | **62.4** | **74.7** | **23.6** |
|
| 113 |
+
|
| 114 |
+
*Comparison of base QwenCoder-2.5 models of different sizes and their SELEKT-enhanced versions across three code editing benchmarks.*
|
| 115 |
+
|
| 116 |
+
**Detailed evaluation results are reported in this [📑 paper](https://arxiv.org/abs/2503.03656).**
|
| 117 |
+
|
| 118 |
+
## Citation
|
| 119 |
+
|
| 120 |
+
If you find our work helpful, feel free to give us a cite.
|
| 121 |
+
|
| 122 |
+
```
|
| 123 |
+
// todo
|
| 124 |
+
```
|