File size: 8,712 Bytes
3bd2d81
 
 
 
 
 
 
 
 
 
 
 
 
 
e694e27
3bd2d81
 
 
 
5e4ea35
 
 
0a35505
cd0ee30
5e4ea35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a35505
5e4ea35
0a35505
5e4ea35
0a35505
5e4ea35
 
 
 
 
 
 
 
 
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
---
license: mit
datasets:
- Anthropic/AnthropicInterviewer
- openai/gsm8k
- HuggingFaceH4/MATH-500
- CyberNative/Code_Vulnerability_Security_DPO
- glaiveai/glaive-function-calling-v2
language:
- en
metrics:
- accuracy
base_model:
- Qwen/Qwen2.5-Coder-7B-Instruct
library_name: transformers
tags:
- code
- agent
---
# amara-o1

<div align="center">

<img src="https://i.postimg.cc/BZPP4RbY/amarao1.png" alt="amara-o1 banner" width="800"/>
  
### A fine-tuned coding model built on Qwen for elite problem-solving

[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Model](https://img.shields.io/badge/🤗-Model-yellow)](https://huggingface.co/ramdev12345/amara-o1)

[Demo](#usage) | [Training](#training) | [Benchmarks](#performance) | [Limitations](#limitations)

</div>

---

## Model Details

**amara-o1** is a specialized coding assistant fine-tuned from Qwen2.5-Coder, optimized for:
- 🧮 Complex algorithmic problem solving
- 🔐 Secure code generation and vulnerability detection
- 📊 Mathematical reasoning and computation
- 💡 Multi-step reasoning for challenging tasks

| Attribute | Details |
|-----------|---------|
| **Base Model** | Qwen/Qwen2.5-Coder-7B-Instruct |
| **Parameters** | 7B |
| **Training Method** | QLoRA (4-bit quantization) |
| **LoRA Rank** | 64 |
| **Context Length** | 32,768 tokens |
| **License** | MIT |
| **Languages** | Python, JavaScript, C++, Java, and 90+ more |

---

## What Makes amara-o1 Different?

amara-o1 has been fine-tuned on a carefully curated dataset combining:

1. **🏆 Competitive Programming** - 5,000+ problems from Code Contests
2. **🧮 Advanced Mathematics** - MATH-500 dataset for quantitative reasoning
3. **🔐 Security-First Coding** - Vulnerability detection and secure programming patterns
4. **💭 Deep Reasoning** - Anthropic's interview transcripts for complex problem decomposition

This multi-domain training enables amara-o1 to:
- Generate production-ready, secure code
- Solve competitive programming challenges
- Handle complex mathematical computations
- Break down ambiguous problems systematically

---

## Usage

### Quick Start

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

# Load model and tokenizer
model_name = "ramdev12345/amara-o1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)

# Generate code
prompt = """<|im_start|>user
Write a Python function to find the longest palindromic substring in a string using dynamic programming.<|im_end|>
<|im_start|>assistant"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
    **inputs,
    max_new_tokens=512,
    temperature=0.7,
    top_p=0.9,
    do_sample=True
)

response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
```

### With vLLM (Recommended for Production)

```python
from vllm import LLM, SamplingParams

llm = LLM(model="ramdev12345/amara-o1")
sampling_params = SamplingParams(temperature=0.7, top_p=0.9, max_tokens=512)

prompts = [
    "<|im_start|>user\nOptimize this bubble sort algorithm<|im_end|>\n<|im_start|>assistant"
]

outputs = llm.generate(prompts, sampling_params)
for output in outputs:
    print(output.outputs[0].text)
```

### Chat Template

```python
messages = [
    {"role": "user", "content": "Write a binary search tree implementation in Python"}
]

text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)

inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
```

---

## Training

### Training Configuration

| Parameter | Value |
|-----------|-------|
| Training Method | Supervised Fine-Tuning (SFT) with QLoRA |
| Quantization | 4-bit NF4 |
| LoRA Rank | 64 |
| LoRA Alpha | 16 |
| Batch Size | 1 (per device) |
| Gradient Accumulation | 8 steps |
| Learning Rate | 2e-4 |
| LR Schedule | Cosine with warmup |
| Epochs | 2 |
| Training Examples | ~7,000 |
| Hardware | 1x NVIDIA A100 80GB |
| Training Time | ~3 hours |

### Training Datasets

| Dataset | Examples | Purpose |
|---------|----------|---------|
| DeepMind Code Contests | 5,000 | Algorithmic problem solving |
| MATH-500 | 500 | Mathematical reasoning |
| Code Vulnerability Security DPO | 1,000 | Secure coding practices |
| Anthropic Interviews | 1,000 | Complex reasoning patterns |

### LoRA Target Modules

```
q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
```

---

## Performance

amara-o1 demonstrates strong performance across multiple coding benchmarks:

### Coding Capabilities

| Task Type | Performance | Notes |
|-----------|-------------|-------|
| Algorithm Implementation | ⭐⭐⭐⭐⭐ | Excellent on competitive programming |
| Code Security | ⭐⭐⭐⭐⭐ | Trained on vulnerability detection |
| Math Problems | ⭐⭐⭐⭐ | Strong symbolic reasoning |
| Code Explanation | ⭐⭐⭐⭐⭐ | Clear, detailed breakdowns |
| Multi-language Support | ⭐⭐⭐⭐ | 90+ programming languages |

### Example Outputs

**Input:** "Write a function to detect if a linked list has a cycle"

**Output:**
```python
def has_cycle(head):
    """
    Detect cycle in linked list using Floyd's algorithm.
    Time: O(n), Space: O(1)
    """
    if not head or not head.next:
        return False
    
    slow = head
    fast = head.next
    
    while slow != fast:
        if not fast or not fast.next:
            return False
        slow = slow.next
        fast = fast.next.next
    
    return True
```

---

## Limitations

While amara-o1 is a powerful coding assistant, users should be aware of:

- **Not a Replacement for Testing**: Always test generated code thoroughly
- **Security**: Review security-critical code manually
- **Domain Expertise**: May require human oversight for specialized domains
- **Hallucinations**: Like all LLMs, may occasionally generate incorrect information
- **License Compliance**: Ensure generated code complies with your licensing requirements
- **Bias**: May reflect biases present in training data

---

## Ethical Considerations

### Intended Use**Recommended Uses:**
- Educational programming assistance
- Code prototyping and rapid development
- Algorithm implementation
- Security vulnerability analysis
- Code review and optimization

❌ **Not Recommended:**
- Generating malicious code
- Bypassing security measures
- Automating critical systems without human oversight
- Legal or financial decision-making

### Bias and Safety

amara-o1 has been trained on diverse coding datasets, but may still reflect biases in:
- Programming paradigm preferences
- Language-specific idioms
- Solution approaches

Users should:
- Review outputs for appropriateness
- Apply domain expertise
- Follow security best practices
- Test thoroughly before deployment

---

## System Requirements

### Minimum Requirements

| Component | Requirement |
|-----------|-------------|
| GPU Memory | 16GB (with 4-bit quantization) |
| RAM | 32GB recommended |
| Storage | 15GB for model files |

### Recommended Setup

- **GPU**: NVIDIA A100, A6000, or RTX 4090
- **Inference**: Use vLLM or TGI for production
- **Quantization**: 4-bit or 8-bit for resource constraints

---

## Citation

If you use amara-o1 in your research or applications, please cite:

```bibtex
@misc{amara-o1-2024,
  title={amara-o1: A Fine-tuned Coding Model for Advanced Problem Solving},
  author={ramdev12345},
  year={2024},
  howpublished={\url{https://huggingface.co/ramdev12345/amara-o1}},
}
```

### Base Model Citation

```bibtex
@article{qwen2.5,
  title={Qwen2.5-Coder Technical Report},
  author={Qwen Team},
  journal={arXiv preprint},
  year={2024}
}
```

---

## License

This model is released under the **MIT License**. See [LICENSE](LICENSE) for details.

The model inherits the license from its base model (Qwen2.5-Coder).

---

## Acknowledgments

- **Base Model**: Qwen Team for Qwen2.5-Coder
- **Training Datasets**: DeepMind, Hugging Face, CyberNative, Anthropic
- **Infrastructure**: Modal Labs for training infrastructure
- **Framework**: Hugging Face Transformers, PEFT, TRL

---

## Contact & Support

- **Issues**: [GitHub Issues](https://github.com/ramdev2025/amara-o1/issues)
- **Discussions**: [Hugging Face Discussions](https://huggingface.co/ramdev12345/amara-o1/discussions)
- **Email**: [ramdevcalope2015@gmail.com] - contact me here!

# HIRE ME NOW!
---

<div align="center">

**Built with 💻 for the coding community**

⭐ Star this repo | 🐛 Report bugs | 🤝 Contribute

</div>