GoZion commited on
Commit
9d119a8
·
verified ·
1 Parent(s): e6b0bef

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +102 -3
README.md CHANGED
@@ -1,3 +1,102 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ # Rodimus+-Coder
6
+
7
+ <div align="center">
8
+ <img src="https://github.com/codefuse-ai/rodimus/blob/main/assets/CodeFuse-logo.jpg?raw=true" width="80%"/>
9
+ </div>
10
+ <p align="center">
11
+ 🤖 <a href="https://modelscope.cn/organization/codefuse-ai">ModelScope</a>
12
+ 🤗 <a href="https://huggingface.co/codefuse-ai">Hugging Face</a>
13
+ 🖥️ <a href="https://github.com/codefuse-ai/rodimus">GitHub</a>
14
+ <p>
15
+
16
+ ## Introduction
17
+ 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.
18
+
19
+ 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.
20
+
21
+ <div align="center">
22
+ <img src="https://github.com/codefuse-ai/rodimus/blob/main/assets/rodimus-plus-coder-chat-evaluation.png?raw=true" width="80%"/>
23
+ </div>
24
+
25
+ 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.
26
+
27
+ For more details, please refer to our [Paper](https://openreview.net/forum?id=IIVYiJ1ggK) and [Github](https://github.com/codefuse-ai/rodimus).
28
+
29
+ ## Model Downloads
30
+
31
+ 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.
32
+
33
+ <div align="center">
34
+
35
+ | **Model** | **#Total Params** | **Context Length** | **Download** |
36
+ | :----------------: | :---------------: | :-------------------: | :----------: |
37
+ | Rodimus+-Coder-1.6B | 1.6B | 4K | [🤗 HuggingFace](https://huggingface.co/codefuse-ai/Rodimus-Plus-Coder-1.6B) |
38
+ | Rodimus+-Coder-1.6B-Chat | 1.6B | 4K | [🤗 HuggingFace](https://huggingface.co/codefuse-ai/Rodimus-Plus-Coder-1.6B-Chat) |
39
+ | Rodimus+-Coder-4B | 4B | 4K | [🤗 HuggingFace](https://huggingface.co/codefuse-ai/Rodimus-Plus-Coder-4B) |
40
+ | Rodimus+-Coder-4B-Chat | 4B | 4K | [🤗 HuggingFace](https://huggingface.co/codefuse-ai/Rodimus-Plus-Coder-4B-Chat) |
41
+
42
+ </div>
43
+
44
+ ## Usage
45
+
46
+ **Installation**
47
+
48
+ 1. The latest version of [transformers](https://github.com/huggingface/transformers) is recommended (at least 4.42.0).
49
+ 2. We evaluate our models with `python=3.8` and `torch==2.1.2`.
50
+ 3. If you use Rodimus, you need to install [flash-linear-attention](https://github.com/sustcsonglin/flash-linear-attention) 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).
51
+
52
+ ## Generation
53
+ `generate` APi
54
+
55
+ ```python
56
+ import os
57
+ import torch
58
+ from modeling_rodimus import RodimusForCausalLM
59
+ from tokenization_rodimus_fast import RodimusTokenizer
60
+
61
+ # load model
62
+ ckpt_dir = "model_path"
63
+ tokenizer = RodimusTokenizer.from_pretrained(ckpt_dir)
64
+ model = RodimusForCausalLM.from_pretrained(
65
+ ckpt_dir,
66
+ torch_dtype=torch.bfloat16,
67
+ device_map="cuda"
68
+ ).eval()
69
+
70
+ # inference
71
+ input_prompt = "Write a quick sort algorithm in python."
72
+
73
+ messages = [
74
+ {"role": "HUMAN", "content": input_prompt}
75
+ ]
76
+
77
+ text = tokenizer.apply_chat_template(
78
+ messages,
79
+ tokenize=False,
80
+ )
81
+
82
+ model_inputs = tokenizer(text, return_tensors="pt").to(model.device)
83
+ outputs = model.generate(**model_inputs, max_new_tokens=2048)
84
+ response = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
85
+
86
+ print(response)
87
+ ```
88
+
89
+ ## Citation
90
+ If you find our work helpful, feel free to give us a cite.
91
+
92
+ ```markdown
93
+ @inproceedings{
94
+ he2025rodimus,
95
+ title={Rodimus*: Breaking the Accuracy-Efficiency Trade-Off with Efficient Attentions},
96
+ author={Zhihao He and Hang Yu and Zi Gong and Shizhan Liu and Jianguo Li and Weiyao Lin},
97
+ booktitle={The Thirteenth International Conference on Learning Representations},
98
+ year={2025},
99
+ url={https://openreview.net/forum?id=IIVYiJ1ggK}
100
+ }
101
+ ```
102
+