File size: 6,082 Bytes
35697c2
e02416c
 
 
 
 
 
 
cc5f046
e02416c
35697c2
97fa10c
e02416c
97fa10c
e02416c
97fa10c
e02416c
97fa10c
e02416c
97fa10c
e02416c
97fa10c
e02416c
cc5f046
e02416c
 
35697c2
e02416c
35697c2
e02416c
35697c2
e02416c
 
 
 
cc5f046
e02416c
 
 
 
35697c2
e02416c
35697c2
 
 
 
e02416c
35697c2
 
e02416c
 
35697c2
 
 
 
 
 
 
 
e02416c
35697c2
 
 
 
 
e02416c
97fa10c
 
 
 
35697c2
 
 
 
 
 
 
 
 
97fa10c
e02416c
35697c2
e02416c
35697c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97fa10c
 
 
 
35697c2
 
97fa10c
 
35697c2
 
e02416c
97fa10c
e02416c
 
 
 
 
 
 
 
 
35697c2
e02416c
35697c2
e02416c
 
 
 
 
 
35697c2
 
 
 
 
e02416c
 
 
 
35697c2
e02416c
35697c2
e02416c
35697c2
e02416c
 
 
 
 
 
 
 
35697c2
 
97fa10c
e02416c
97fa10c
e02416c
 
 
 
 
35697c2
 
 
e02416c
35697c2
e02416c
 
 
 
35697c2
 
 
 
 
e02416c
 
 
35697c2
cc5f046
e02416c
35697c2
 
97fa10c
 
 
 
 
 
35697c2
97fa10c
 
35697c2
97fa10c
 
 
35697c2
 
e02416c
35697c2
e02416c
 
 
 
 
35697c2
 
 
 
 
 
 
 
97fa10c
e02416c
 
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
<p align="center">
  <a href="https://github.com/my-ai-stack/stack-2.9">
    <img src="https://img.shields.io/badge/GitHub-View%20Repo-blue?style=flat-square&logo=github" alt="GitHub">
  </a>
  <a href="https://huggingface.co/spaces/my-ai-stack/stack-2-9-demo">
    <img src="https://img.shields.io/badge/HF%20Space-Demo-green?style=flat-square&logo=huggingface" alt="HuggingFace Space">
  </a>
  <img src="https://img.shields.io/badge/Parameters-1.5B-purple?style=flat-square" alt="Parameters">
  <img src="https://img.shields.io/badge/Context-128K-orange?style=flat-square" alt="Context">
  <img src="https://img.shields.io/badge/License-Apache%202.0-yellow?style=flat-square" alt="License">
</p>

---

# Stack 2.9

> A fine-tuned code assistant built on Qwen2.5-Coder-1.5B, trained on Stack Overflow data

Stack 2.9 is a specialized code generation model fine-tuned from [Qwen/Qwen2.5-Coder-1.5B](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B) on Stack Overflow Q&A data for improved programming assistance.

## Key Features

- **Specialized for Code**: Trained on Stack Overflow patterns for better code generation
- **128K Context**: Handle larger codebases and complex documentation
- **Efficient**: Runs on consumer GPUs (RTX 3060+)
- **Open Source**: Apache 2.0 licensed

---

## Model Details

| Attribute | Value |
|-----------|-------|
| **Base Model** | Qwen/Qwen2.5-Coder-1.5B |
| **Parameters** | 1.5B |
| **Context Length** | 131,072 tokens (128K) |
| **Fine-tuning Method** | LoRA (Rank 8) |
| **Precision** | FP16 |
| **License** | Apache 2.0 |
| **Release Date** | April 2026 |

### Architecture

| Specification | Value |
|--------------|-------|
| Architecture | Qwen2ForCausalLM |
| Hidden Size | 1,536 |
| Num Layers | 28 |
| Attention Heads | 12 (Q) / 2 (KV) |
| GQA | Yes (2 KV heads) |
| Intermediate Size | 8,960 |
| Vocab Size | 151,936 |
| Activation | SiLU (SwiGLU) |
| Normalization | RMSNorm |

---

## Quickstart

### Installation

```bash
pip install transformers>=4.40.0 torch>=2.0.0 accelerate
```

### Code Example

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "my-ai-stack/Stack-2-9-finetuned"

# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Chat interface
messages = [
    {"role": "system", "content": "You are Stack 2.9, a helpful coding assistant."},
    {"role": "user", "content": "Write a Python function to calculate fibonacci numbers"}
]

# Apply chat template
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)

# Generate
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=512,
    temperature=0.7,
    do_sample=True
)

# Decode response
response = tokenizer.decode(
    generated_ids[0][len(model_inputs.input_ids[0]):],
    skip_special_tokens=True
)
print(response)
```

### Interactive Chat

```bash
python chat.py
```

---

## Training Details

| Specification | Value |
|--------------|-------|
| **Method** | LoRA (Low-Rank Adaptation) |
| **LoRA Rank** | 8 |
| **LoRA Alpha** | 16 |
| **Target Modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| **Epochs** | ~0.8 |
| **Final Loss** | 0.0205 |
| **Data Source** | Stack Overflow Q&A |

### Training Data

Fine-tuned on Stack Overflow code Q&A pairs including:
- Python code solutions and snippets
- Code explanations and documentation
- Programming patterns and best practices
- Bug fixes and debugging examples
- Algorithm implementations

---

## Evaluation

| Benchmark | Score | Notes |
|-----------|-------|-------|
| **HumanEval** | ~35-40% | Based on base model benchmarks |
| **MBPP** | ~40-45% | Python-focused evaluation |

> **Note**: Full benchmark evaluation is in progress. The model inherits strong coding capabilities from Qwen2.5-Coder and is specialized for Stack Overflow patterns.

---

## Hardware Requirements

| Configuration | GPU | VRAM |
|---------------|-----|------|
| FP16 | RTX 3060+ | ~4GB |
| 8-bit | RTX 3060+ | ~2GB |
| 4-bit | Any modern GPU | ~1GB |
| CPU | None | ~8GB RAM |

---

## Capabilities

- **Code Generation**: Python, JavaScript, TypeScript, SQL, Go, Rust, and more
- **Code Completion**: Functions, classes, and entire snippets
- **Debugging**: Identify and fix bugs with explanations
- **Code Explanation**: Document and explain code behavior
- **Programming Q&A**: Answer technical questions

---

## Limitations

- **Model Size**: At 1.5B parameters, smaller than state-of-the-art models (7B+)
- **Training Data**: Python-heavy; other languages may have lower quality
- **Hallucinations**: May occasionally generate incorrect code; verification recommended
- **Tool Use**: Base model without native tool-calling (see enhanced version)

---

## Comparison

| Feature | Qwen2.5-Coder-1.5B | Stack 2.9 |
|---------|-------------------|-----------|
| Code Generation | General | Stack Overflow patterns |
| Python Proficiency | Baseline | Enhanced |
| Context Length | 128K | 128K |
| Specialization | General code | Stack Overflow Q&A |

---

## Citation

```bibtex
@misc{my-ai-stack/stack-2-9-finetuned,
  author = {Walid Sobhi},
  title = {Stack 2.9: Fine-tuned Qwen2.5-Coder-1.5B on Stack Overflow Data},
  year = {2026},
  publisher = {HuggingFace},
  url = {https://huggingface.co/my-ai-stack/Stack-2-9-finetuned}
}
```

---

## Related Links

- [GitHub Repository](https://github.com/my-ai-stack/stack-2.9)
- [HuggingFace Space Demo](https://huggingface.co/spaces/my-ai-stack/stack-2-9-demo)
- [Base Model](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B)
- [Qwen2.5-Coder-7B](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct)
- [Qwen2.5-Coder-32B](https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct)

---

## License

Licensed under the Apache 2.0 license. See [LICENSE](LICENSE) for details.

---

*Model Card Version: 2.0*
*Last Updated: April 2026*