File size: 15,306 Bytes
9d119a8 73e6fb7 07f68db 9d119a8 00366a8 9ad63fa 00366a8 9d119a8 3dd46a8 9d119a8 1aa58c5 9d119a8 1aa58c5 9d119a8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
---
license: apache-2.0
---
# Rodimus+-Coder
<div align="center">
<img src="https://github.com/codefuse-ai/rodimus/blob/main/assets/CodeFuse-logo.jpg?raw=true" width="80%"/>
</div>
<p align="center">
π€ <a href="https://modelscope.cn/organization/codefuse-ai">ModelScope</a>
π€ <a href="https://huggingface.co./codefuse-ai">Hugging Face</a>
π₯οΈ <a href="https://github.com/codefuse-ai/rodimus">GitHub</a>
<p>
## Introduction
Rodimus* is a new series of efficient large language models designed to address the challenges of computational complexity in Transformer-based architectures. The Rodimus* includes the base Rodimus model and its enhanced version, Rodimus+. Rodimus leverages a novel Data-Dependent Tempered Selection (DDTS) mechanism within a purely recurrent, linear attention-based framework, achieving high performance.
Building on this, Rodimus+ combines the strengths of Rodimus and the innovative Sliding Window Shared-Key Attention (SW-SKA) in a hybrid approach. This combination effectively integrates semantic, token, and head compression techniques, enabling a balance between accuracy and efficiency.
<div align="center">
<img src="https://github.com/codefuse-ai/rodimus/blob/main/assets/rodimus-plus-coder-chat-evaluation.png?raw=true" width="80%"/>
</div>
Beyond academic validation, we train and open-source the lightweight Rodimus+-Coder code LLM, based on the Rodimus architecture. It comes in sizes of 1.6B and 4B, and achieves outstanding results that surpass state-of-the-art (SOTA) models of the same size.
For more details, please refer to our [Paper](https://openreview.net/forum?id=IIVYiJ1ggK) and [Github](https://github.com/codefuse-ai/rodimus).
## Model Downloads
You can download the following table to see the various parameters for your use case. If you are located in mainland China, we also provide the model on modelscope.cn to speed up the download process.
<div align="center">
| **Model** | **#Total Params** | **Training Tokens** | **Context Length** | **Download** |
| :----------------: | :---------------: | :----------------: | :-------------------: | :----------: |
| Rodimus+-Coder-1.6B-Base | 1.6B | 8.2T | 4K | [π€ HuggingFace](https://huggingface.co./codefuse-ai/Rodimus-Plus-Coder-1.6B-Base) |
| Rodimus+-Coder-1.6B-Chat | 1.6B | - | 4K | [π€ HuggingFace](https://huggingface.co./codefuse-ai/Rodimus-Plus-Coder-1.6B-Chat) |
| Rodimus+-Coder-4B-Base | 4B | 8.2T | 4K | [π€ HuggingFace](https://huggingface.co./codefuse-ai/Rodimus-Plus-Coder-4B-Base) |
| Rodimus+-Coder-4B-Chat | 4B | - | 4K | [π€ HuggingFace](https://huggingface.co./codefuse-ai/Rodimus-Plus-Coder-4B-Chat) |
</div>
## Rodimus+-Coder Evaluation
We re-evaluate the metrics of the Qwen series models, and the metrics of other series models are quoted from the original paper. For detailed evaluation code, please refer to the evaluation method of Ling-Coder-Lite in [CodeFuse-Evaluation](https://github.com/codefuse-ai/codefuse-evaluation).
### Rodimus+-Coder-Base
<table>
<tr align="center">
<th>Datasets</th>
<th>Qwen2.5-Coder-1.5B</th>
<th>Rodimus+-Coder-1.6B-Base</th>
<th>Gemma2-2B-PT</th>
<th>Qwen2.5-Coder-3B</th>
<th>Rodimus+-Coder-4B-Base</th>
<th>Gemma3-4B-PT</th>
<th>Qwen2.5-Coder-7B</th>
</tr>
<tr align="center">
<td colspan="8">Coding Tasks</td>
</tr>
<tr align="center">
<td>HumanEval</td>
<td>41.5</td>
<td>51.2</td>
<td>19.5</td>
<td>51.8</td>
<th>60.4</th>
<td>36.0</td>
<th>60.4</th>
</tr>
<tr align="center">
<td>HumanEval+</td>
<td>34.8</td>
<td>45.1</td>
<td>-</td>
<td>40.9</td>
<th>52.4</th>
<td>-</td>
<td>50.6</td>
</tr>
<tr align="center">
<td>MBPP</td>
<td>57.2</td>
<td>51.2</td>
<td>31.0</td>
<td>62.6</td>
<td>64.6</td>
<td>46.0</td>
<th>70.0</th>
</tr>
<tr align="center">
<td>MBPP+</td>
<td>66.1</td>
<td>62.2</td>
<td>-</td>
<td>65.9</td>
<th>71.4</th>
<td>-</td>
<td>70.1</td>
</tr>
<tr align="center">
<td>BCB<sub>COMPLETION</sub></td>
<td>21.6</td>
<td>17.9</td>
<td>-</td>
<td>26.2</td>
<th>30.8</th>
<td>-</td>
<td>30.4</td>
</tr>
<tr align="center">
<td>MultiPL-E</td>
<td>46.1</td>
<td>52.5</td>
<td>-</td>
<td>49.4</td>
<th>60.7</th>
<td>-</td>
<td>56.9</td>
</tr>
<tr align="center">
<td>CRUXEval</td>
<td>38.5</td>
<td>45.1</td>
<td>-</td>
<td>44.6</td>
<td>56.4</td>
<td>-</td>
<th>56.8</th>
</tr>
<tr align="center">
<th>Coding Avg.</th>
<td>43.7</td>
<td>46.5</td>
<td>-</td>
<td>48.8</td>
<th>56.7</th>
<td>-</td>
<td>56.4</td>
</tr>
<tr align="center">
<td colspan="8">General Tasks</td>
</tr>
<tr align="center">
<td>C-EVAL</td>
<td>55.2</td>
<td>56.7</td>
<td>-</td>
<td>65.3</td>
<th>70.2</th>
<td>-</td>
<td>69.1</td>
</tr>
<tr align="center">
<td>CMMLU</td>
<td>54.5</td>
<td>52.3</td>
<td>-</td>
<td>65.4</td>
<td>68.3</td>
<td>-</td>
<th>72.7</th>
</tr>
<tr align="center">
<td>MMLU</td>
<td>55.5</td>
<td>51.1</td>
<td>52.2</td>
<td>63.3</td>
<td>62.6</td>
<td>59.6</td>
<th>70.5</th>
</tr>
<tr align="center">
<td>BBH</td>
<td>21.8</td>
<td>46.8</td>
<td>42.4</td>
<td>32.5</td>
<td>61.9</td>
<td>50.9</td>
<th>67.3</th>
</tr>
<tr align="center">
<th>General Avg.</th>
<td>46.8</td>
<td>51.7</td>
<td>-</td>
<td>56.6</td>
<td>65.8</td>
<td>-</td>
<td>69.9</td>
</tr>
<tr align="center">
<td colspan="8">Mathematics Tasks</td>
</tr>
<tr align="center">
<td>GSM8K</td>
<td>60.4</td>
<td>68.7</td>
<td>25.0</td>
<td>72.1</td>
<td>78.5</td>
<td>38.4</td>
<td>83.4</td>
</tr>
<tr align="center">
<td>MATH</td>
<td>23.7</td>
<td>29.0</td>
<td>16.4</td>
<td>31.9</td>
<td>37.0</td>
<td>24.2</td>
<td>42.2</td>
</tr>
<tr align="center">
<th>Math Avg.</th>
<td>41.9</td>
<td>48.9</td>
<td>20.7</td>
<td>52.0</td>
<td>57.8</td>
<td>31.3</td>
<td>62.8</td>
</tr>
<tr align="center">
<td colspan="8">Overall</td>
</tr>
<tr align="center">
<th>Overall</th>
<td>44.4</td>
<td>48.4</td>
<td>-</td>
<td>51.7</td>
<th>59.6</th>
<td>-</td>
<th>61.6</th>
</tr>
</table>
### Rodimus+-Coder-Chat
<table>
<tr align="center">
<th>Datasets</th>
<th>Qwen2.5-Coder-1.5B-Instruct</th>
<th>Rodimus+-Coder-1.6B-Chat</th>
<th>Gemma2-2B-IT</th>
<th>Qwen2.5-Coder-Instruct</th>
<th>Phi-4-Mini-3.8B</th>
<th>Rodimus+-Coder-4B-Chat</th>
<th>Gemma3-4B-IT</th>
<th>Qwen2.5-Coder-7B-Instruct</th>
</tr>
<tr align="center">
<td colspan="9">Coding Tasks</td>
</tr>
<tr align="center">
<td>HumanEval</td>
<td>64.6</td>
<td>76.8</td>
<td>20.1</td>
<td>79.9</td>
<td>74.4</td>
<td>86.6</td>
<td>71.3</td>
<td>87.2</td>
</tr>
<tr align="center">
<td>HumanEval+</td>
<td>63.4</td>
<td>73.8</td>
<td>-</td>
<td>80.5</td>
<td>68.3</td>
<td>82.9</td>
<td>-</td>
<td>82.3</td>
</tr>
<tr align="center">
<td>MBPP</td>
<td>51.0</td>
<td>59.0</td>
<td>36.6</td>
<td>59.2</td>
<td>65.3</td>
<td>68.0</td>
<td>63.2</td>
<td>75.8</td>
</tr>
<tr align="center">
<td>MBPP+</td>
<td>53.0</td>
<td>66.4</td>
<td>-</td>
<td>61.9</td>
<td>63.8</td>
<td>68.5</td>
<td>-</td>
<td>75.1</td>
</tr>
<tr align="center">
<td>LCB<sub>(24.08-24.11)</sub></td>
<td>4.0</td>
<td>10.9</td>
<td>-</td>
<td>13.0</td>
<td>-</td>
<td>13.9</td>
<td>-</td>
<td>22.8</td>
</tr>
<tr align="center">
<td>BCB<sub>INSTRUCT</sub></td>
<td>10.8</td>
<td>21.5</td>
<td>-</td>
<td>21.7</td>
<td>33.8</td>
<td>26.6</td>
<td>-</td>
<td>30.6</td>
</tr>
<tr align="center">
<td>HumanEval-Mul</td>
<td>50.8</td>
<td>57.3</td>
<td>-</td>
<td>67.4</td>
<td>-</td>
<td>70.6</td>
<td>-</td>
<td>76.1</td>
</tr>
<tr align="center">
<td>MBPP-Mul</td>
<td>43.4</td>
<td>52.4</td>
<td>-</td>
<td>53.4</td>
<td>-</td>
<td>59.6</td>
<td>-</td>
<td>61.4</td>
</tr>
<tr align="center">
<td>MBXP-EN</td>
<td>55.8</td>
<td>75.5</td>
<td>-</td>
<td>76.0</td>
<td>-</td>
<td>87.3</td>
<td>-</td>
<td>87.7</td>
</tr>
<tr align="center">
<td>MBXP-CN</td>
<td>48.8</td>
<td>75.0</td>
<td>-</td>
<td>68.7</td>
<td>-</td>
<td>84.3</td>
<td>-</td>
<td>83.5</td>
</tr>
<tr align="center">
<td>CRUXEval</td>
<td>28.6</td>
<td>55.0</td>
<td>-</td>
<td>51.6</td>
<td>-</td>
<td>63.2</td>
<td>-</td>
<td>69.3</td>
</tr>
<tr align="center">
<td>HumanEvalFix</td>
<td>38.9</td>
<td>52.6</td>
<td>-</td>
<td>55.5</td>
<td>-</td>
<td>68.8</td>
<td>-</td>
<td>69.3</td>
</tr>
<tr align="center">
<td>Spider</td>
<td>61.2</td>
<td>71.4</td>
<td>-</td>
<td>71.8</td>
<td>42.2</td>
<td>73.5</td>
<td>-</td>
<td>82.0</td>
</tr>
<tr align="center">
<th>Coding Avg.</th>
<td>44.2</td>
<td>57.5</td>
<td>-</td>
<td>58.5</td>
<td>-</td>
<th>65.7</th>
<td>-</td>
<th>69.5</th>
</tr>
<tr align="center">
<td colspan="9">General Tasks</td>
</tr>
<tr align="center">
<td>C-EVAL</td>
<td>51.5</td>
<td>50.8</td>
<td>-</td>
<td>62.0</td>
<td>-</td>
<td>61.6</td>
<td>-</td>
<td>66.4</td>
</tr>
<tr align="center">
<td>CMMLU</td>
<td>45.2</td>
<td>50.5</td>
<td>-</td>
<td>60.1</td>
<td>-</td>
<td>62.0</td>
<td>-</td>
<td>64.9</td>
</tr>
<tr align="center">
<td>MMLU</td>
<td>52.0</td>
<td>49.3</td>
<td>56.1</td>
<td>61.7</td>
<td>67.3</td>
<td>57.5</td>
<td>58.1</td>
<td>66.1</td>
</tr>
<tr align="center">
<td>BBH</td>
<td>24.2</td>
<td>58.7</td>
<td>41.4</td>
<td>57.3</td>
<td>70.4</td>
<td>63.7</td>
<td>72.2</td>
<td>59.1</td>
</tr>
<tr align="center">
<th>General Avg.</th>
<td>43.2</td>
<td>52.3</td>
<td>-</td>
<td>60.3</td>
<td>-</td>
<td>61.2</td>
<td>-</td>
<td>64.1</td>
</tr>
<tr align="center">
<td colspan="9">Mathematics Tasks</td>
</tr>
<tr align="center">
<td>GSM8K</td>
<td>54.4</td>
<td>68.5</td>
<td>62.6</td>
<td>73.5</td>
<td>88.6</td>
<td>79.2</td>
<td>89.2</td>
<td>79.5</td>
</tr>
<tr align="center">
<td>MATH</td>
<td>38.1</td>
<td>33.5</td>
<td>27.2</td>
<td>44.1</td>
<td>64.0</td>
<td>44.1</td>
<td>75.6</td>
<td>60.8</td>
</tr>
<tr align="center">
<th>Math Avg.</th>
<td>46.2</td>
<td>51.0</td>
<td>44.9</td>
<td>58.8</td>
<td>68.8</td>
<td>61.7</td>
<td>82.4</td>
<td>70.1</td>
</tr>
<tr align="center">
<td colspan="9">Overall</td>
</tr>
<tr align="center">
<th>Overall</th>
<td>44.2</td>
<td>55.8</td>
<td>-</td>
<td>58.9</td>
<td>-</td>
<th>64.3</th>
<td>-</td>
<th>68.4</th>
</tr>
</table>
## Usage
**Installation**
1. The latest version of [transformers](https://github.com/huggingface/transformers) is recommended (at least 4.42.0).
2. We evaluate our models with `python=3.8` and `torch==2.1.2`.
3. If you use Rodimus, you need to install [flash-linear-attention](https://github.com/sustcsonglin/flash-linear-attention), [causal_conv1d](https://github.com/Dao-AILab/causal-conv1d) and [triton>=2.2.0](https://github.com/triton-lang/triton). If you use Rodimus+, you need to further install [flash-attention](https://github.com/Dao-AILab/flash-attention).
## Generation
`generate` APi
```python
import os
import torch
from modeling_rodimus import RodimusForCausalLM
from tokenization_rodimus_fast import RodimusTokenizer
# load model
ckpt_dir = "model_path"
tokenizer = RodimusTokenizer.from_pretrained(ckpt_dir)
model = RodimusForCausalLM.from_pretrained(
ckpt_dir,
torch_dtype=torch.bfloat16,
device_map="cuda"
).eval()
# inference
input_prompt = "Write a quick sort algorithm in python."
messages = [
{"role": "HUMAN", "content": input_prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
)
model_inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**model_inputs, max_new_tokens=2048)
response = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
print(response)
```
## Citation
If you find our work helpful, feel free to give us a cite.
```
@inproceedings{
he2025rodimus,
title={Rodimus*: Breaking the Accuracy-Efficiency Trade-Off with Efficient Attentions},
author={Zhihao He and Hang Yu and Zi Gong and Shizhan Liu and Jianguo Li and Weiyao Lin},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025},
url={https://openreview.net/forum?id=IIVYiJ1ggK}
}
```
|