Update README.md
Browse files
README.md
CHANGED
@@ -9,7 +9,7 @@ metrics:
|
|
9 |
- code_eval
|
10 |
library_name: transformers
|
11 |
model-index:
|
12 |
-
- name:
|
13 |
results:
|
14 |
- task:
|
15 |
type: text-generation
|
@@ -20,7 +20,6 @@ model-index:
|
|
20 |
- name: pass@1
|
21 |
type: pass@1
|
22 |
value: 32.4
|
23 |
-
verified: false
|
24 |
- task:
|
25 |
type: text-generation
|
26 |
dataset:
|
@@ -30,7 +29,6 @@ model-index:
|
|
30 |
- name: pass@1
|
31 |
type: pass@1
|
32 |
value: 30.9
|
33 |
-
verified: false
|
34 |
- task:
|
35 |
type: text-generation
|
36 |
dataset:
|
@@ -40,7 +38,6 @@ model-index:
|
|
40 |
- name: pass@1
|
41 |
type: pass@1
|
42 |
value: 32.1
|
43 |
-
verified: false
|
44 |
- task:
|
45 |
type: text-generation
|
46 |
dataset:
|
@@ -50,7 +47,6 @@ model-index:
|
|
50 |
- name: pass@1
|
51 |
type: pass@1
|
52 |
value: 32.1
|
53 |
-
verified: false
|
54 |
- task:
|
55 |
type: text-generation
|
56 |
dataset:
|
@@ -60,7 +56,6 @@ model-index:
|
|
60 |
- name: pass@1
|
61 |
type: pass@1
|
62 |
value: 24.2
|
63 |
-
verified: false
|
64 |
- task:
|
65 |
type: text-generation
|
66 |
dataset:
|
@@ -70,56 +65,64 @@ model-index:
|
|
70 |
- name: pass@1
|
71 |
type: pass@1
|
72 |
value: 23.0
|
73 |
-
verified: false
|
74 |
---
|
75 |
-
# **Stable Code Instruct 3B**
|
76 |
|
77 |
-
|
78 |
|
79 |
-
|
|
|
80 |
|
81 |
-
|
82 |
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
- General purpose Code/Software Engineering like conversations.
|
89 |
-
- SQL related generation and conversation.
|
90 |
|
91 |
-
|
|
|
|
|
|
|
92 |
|
93 |
-
|
94 |
-
Here's how you can run the model use the model:
|
95 |
|
96 |
-
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
import torch
|
99 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
model =
|
|
|
|
|
104 |
|
105 |
messages = [
|
106 |
-
{
|
107 |
-
|
108 |
-
"content": "You are a helpful and polite assistant",
|
109 |
-
},
|
110 |
-
{
|
111 |
-
"role": "user",
|
112 |
-
"content": "Write a simple website in HTML. When a user clicks the button, it shows a random joke from a list of 4 jokes."
|
113 |
-
},
|
114 |
]
|
115 |
|
116 |
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
117 |
-
|
118 |
inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
|
119 |
|
120 |
tokens = model.generate(
|
121 |
**inputs,
|
122 |
-
max_new_tokens=
|
123 |
temperature=0.5,
|
124 |
top_p=0.95,
|
125 |
top_k=100,
|
@@ -127,56 +130,20 @@ tokens = model.generate(
|
|
127 |
use_cache=True
|
128 |
)
|
129 |
|
130 |
-
output = tokenizer.batch_decode(tokens[:, inputs.input_ids.shape[-1]:], skip_special_tokens=
|
|
|
131 |
```
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
## Performance
|
147 |
-
### Multi-PL Benchmark:
|
148 |
-
| Model | Size | Avg | Python | C++ | JavaScript | Java | PHP | Rust |
|
149 |
-
|------------------------------|------|------|--------|------|------------|------|------|------|
|
150 |
-
| Codellama Instruct | 7B | 0.30 | 0.33 | 0.31 | 0.31 | 0.29 | 0.31 | 0.25 |
|
151 |
-
| Deepseek Instruct | 1.3B | 0.44 | 0.52 | **0.52** | 0.41 | **0.46** | 0.45 | 0.28 |
|
152 |
-
| Stable Code Instruct (SFT) | 3B | 0.44 | 0.55 | 0.45 | 0.42 | 0.42 | 0.44 | 0.32 |
|
153 |
-
| Stable Code Instruct (DPO) | 3B | **0.47** | **0.59** | 0.49 | **0.49** | 0.44 | **0.45** | **0.37** |
|
154 |
-
|
155 |
-
### MT-Bench Coding:
|
156 |
-
| Model | Size | Score |
|
157 |
-
|-----------------------------|------|-----------------|
|
158 |
-
| DeepSeek Coder | 1.3B | 4.6 |
|
159 |
-
| Stable Code Instruct (DPO) | 3B | **5.8**(ours) |
|
160 |
-
| Stable Code Instruct (SFT) | 3B | 5.5 |
|
161 |
-
| DeepSeek Coder | 6.7B | **6.9** |
|
162 |
-
| CodeLlama Instruct | 7B | 3.55 |
|
163 |
-
| StarChat2 | 15B | 5.7 |
|
164 |
-
|
165 |
-
### SQL Performance
|
166 |
-
| Model | Size | Date | Group By | Order By | Ratio | Join | Where |
|
167 |
-
|-----------------------------|------|-------|----------|----------|-------|-------|-------|
|
168 |
-
| Stable Code Instruct (DPO) | 3B | 24.0% | 54.2% | 68.5% | 40.0% | 54.2% | 42.8% |
|
169 |
-
| DeepSeek-Coder Instruct | 1.3B | 24.0% | 37.1% | 51.4% | 34.3% | 45.7% | 45.7% |
|
170 |
-
| SQLCoder | 7B | 64.0% | 82.9% | 74.3% | 54.3% | 74.3% | 74.3% |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
## How to Cite
|
176 |
-
```bibtex
|
177 |
-
@misc{stable-code-instruct-3b,
|
178 |
-
url={[https://huggingface.co/stabilityai/stable-code-3b](https://huggingface.co/stabilityai/stable-code-instruct-3b)},
|
179 |
-
title={Stable Code 3B},
|
180 |
-
author={Phung, Duy, and Pinnaparaju, Nikhil and Adithyan, Reshinth and Zhuravinskyi, Maksym and Tow, Jonathan and Cooper, Nathan}
|
181 |
-
}
|
182 |
-
```
|
|
|
9 |
- code_eval
|
10 |
library_name: transformers
|
11 |
model-index:
|
12 |
+
- name: dgtalbug/stable-code-instruct-3b
|
13 |
results:
|
14 |
- task:
|
15 |
type: text-generation
|
|
|
20 |
- name: pass@1
|
21 |
type: pass@1
|
22 |
value: 32.4
|
|
|
23 |
- task:
|
24 |
type: text-generation
|
25 |
dataset:
|
|
|
29 |
- name: pass@1
|
30 |
type: pass@1
|
31 |
value: 30.9
|
|
|
32 |
- task:
|
33 |
type: text-generation
|
34 |
dataset:
|
|
|
38 |
- name: pass@1
|
39 |
type: pass@1
|
40 |
value: 32.1
|
|
|
41 |
- task:
|
42 |
type: text-generation
|
43 |
dataset:
|
|
|
47 |
- name: pass@1
|
48 |
type: pass@1
|
49 |
value: 32.1
|
|
|
50 |
- task:
|
51 |
type: text-generation
|
52 |
dataset:
|
|
|
56 |
- name: pass@1
|
57 |
type: pass@1
|
58 |
value: 24.2
|
|
|
59 |
- task:
|
60 |
type: text-generation
|
61 |
dataset:
|
|
|
65 |
- name: pass@1
|
66 |
type: pass@1
|
67 |
value: 23.0
|
|
|
68 |
---
|
|
|
69 |
|
70 |
+
# **Stable Code Instruct 3B — Base Model**
|
71 |
|
72 |
+
> This repository stores an **unchanged** copy of `stabilityai/stable-code-instruct-3b`
|
73 |
+
> for use as a **base model** in future fine‑tuning projects (including Stephen).
|
74 |
|
75 |
+
---
|
76 |
|
77 |
+
## 📌 About the Model
|
78 |
|
79 |
+
`stable-code-instruct-3b` is a **2.7B parameter decoder-only transformer** from Stability AI, tuned for multi‑language code generation and conversational coding assistance.
|
80 |
+
It is suitable as a **starting point** for specialized code assistants,
|
81 |
+
including fine‑tuned variants with domain‑specific datasets.
|
|
|
|
|
82 |
|
83 |
+
**Key Features:**
|
84 |
+
- General purpose code generation across multiple programming languages.
|
85 |
+
- Instruction‑tuned for better conversational performance.
|
86 |
+
- Strong performance on [MultiPL-E](https://github.com/nuprl/MultiPL-E) benchmarks.
|
87 |
|
88 |
+
---
|
|
|
89 |
|
90 |
+
## 📊 Performance (MultiPL-E Benchmark)
|
91 |
|
92 |
+
| Language | pass@1 |
|
93 |
+
|--------------|--------|
|
94 |
+
| Python | 32.4% |
|
95 |
+
| C++ | 30.9% |
|
96 |
+
| Java | 32.1% |
|
97 |
+
| JavaScript | 32.1% |
|
98 |
+
| PHP | 24.2% |
|
99 |
+
| Rust | 23.0% |
|
100 |
+
|
101 |
+
---
|
102 |
+
|
103 |
+
## 🚀 Usage
|
104 |
+
|
105 |
+
```python
|
106 |
import torch
|
107 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
108 |
+
|
109 |
+
model_id = "dgtalbug/stable-code-instruct-3b"
|
110 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
111 |
+
model = AutoModelForCausalLM.from_pretrained(
|
112 |
+
model_id, torch_dtype=torch.bfloat16, trust_remote_code=True
|
113 |
+
).cuda().eval()
|
114 |
|
115 |
messages = [
|
116 |
+
{"role": "system", "content": "You are a helpful coding assistant."},
|
117 |
+
{"role": "user", "content": "Write a Python function to reverse a string."}
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
]
|
119 |
|
120 |
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
|
|
121 |
inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
|
122 |
|
123 |
tokens = model.generate(
|
124 |
**inputs,
|
125 |
+
max_new_tokens=200,
|
126 |
temperature=0.5,
|
127 |
top_p=0.95,
|
128 |
top_k=100,
|
|
|
130 |
use_cache=True
|
131 |
)
|
132 |
|
133 |
+
output = tokenizer.batch_decode(tokens[:, inputs.input_ids.shape[-1]:], skip_special_tokens=True)[0]
|
134 |
+
print(output)
|
135 |
```
|
136 |
|
137 |
+
---
|
138 |
+
|
139 |
+
## 📜 License
|
140 |
+
|
141 |
+
This model follows the **[Stability AI Community License](https://huggingface.co/stabilityai/stable-code-instruct-3b/blob/main/LICENSE.md)**.
|
142 |
+
For commercial use, refer to [Stability AI licensing terms](https://stability.ai/license).
|
143 |
+
|
144 |
+
---
|
145 |
+
|
146 |
+
## 📌 Note for Fine‑Tuning
|
147 |
+
|
148 |
+
This repository is **not modified** — it is kept as a **clean base model** for derivative works.
|
149 |
+
Fine‑tuned versions (e.g., Stephen) will be released in **separate repositories**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|