File size: 12,743 Bytes
48f5e7a
39ebfd9
48f5e7a
 
b52d202
 
 
 
 
 
 
 
 
 
39ebfd9
b52d202
 
48f5e7a
 
660271a
 
 
 
 
 
 
 
48f5e7a
660271a
 
 
 
 
 
 
 
3613942
660271a
 
 
 
 
3613942
 
660271a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3613942
 
660271a
 
 
3613942
 
 
 
660271a
3613942
660271a
 
 
 
 
 
3613942
 
660271a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3613942
660271a
 
 
 
 
 
 
 
 
 
48f5e7a
660271a
48f5e7a
660271a
48f5e7a
660271a
48f5e7a
3613942
48f5e7a
660271a
 
3613942
 
660271a
3613942
660271a
 
3613942
660271a
 
3613942
 
660271a
3613942
660271a
3613942
660271a
3613942
 
660271a
 
3613942
660271a
 
 
3613942
660271a
 
3613942
660271a
 
 
 
 
 
 
 
 
 
 
 
3613942
 
48f5e7a
660271a
 
3613942
 
660271a
 
 
3613942
 
660271a
3613942
 
660271a
3613942
 
 
 
 
 
660271a
 
 
 
 
3613942
 
 
660271a
 
 
 
3613942
48f5e7a
660271a
 
48f5e7a
39ebfd9
48f5e7a
39ebfd9
660271a
 
39ebfd9
660271a
 
 
 
 
 
48f5e7a
660271a
 
3613942
 
660271a
 
 
 
 
3613942
 
660271a
3613942
 
660271a
 
 
 
 
 
3613942
 
660271a
3613942
 
 
 
660271a
3613942
660271a
 
 
 
 
 
 
3613942
660271a
 
 
 
 
 
 
3613942
 
 
660271a
3613942
 
660271a
 
 
 
 
 
 
 
3613942
660271a
 
 
 
 
 
3613942
 
660271a
3613942
 
 
 
 
660271a
 
 
 
 
 
 
 
 
 
 
 
3613942
660271a
 
 
 
 
 
 
3613942
 
 
660271a
3613942
 
660271a
 
 
 
 
 
3613942
 
 
660271a
 
3613942
 
 
 
 
 
 
 
 
660271a
 
3613942
 
660271a
3613942
 
660271a
 
 
 
 
 
 
 
3613942
660271a
 
 
 
 
 
 
3613942
 
660271a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3613942
660271a
3613942
660271a
 
 
 
 
 
48f5e7a
660271a
48f5e7a
660271a
3613942
 
 
660271a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3613942
660271a
 
 
b52d202
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
---
language: en
license: apache-2.0
tags:
- code
- coding-agent
- instruction-tuned
- hermit-code
- qwen2.5-coder
- text-generation
- python
- javascript
- rust
- go
pipeline_tag: text-generation
base_model:
- Qwen/Qwen2.5-Coder-7B-Instruct
---

<div align="center">

<!-- Hero Banner -->
<h1>
  <img src="https://img.shields.io/badge/🐚-Hermit%20Code%207B-2ea44f?style=for-the-badge&logoColor=white" alt="Hermit Code 7B"/>
</h1>

<p><em>The official coding model for the <strong>Hermit AI Agent</strong></em></p>

<!-- Animated-style Status Badges -->
<p>
  <img src="https://img.shields.io/badge/⚑-7.6B%20Parameters-3b82f6?style=flat-square" alt="Parameters"/>
  <img src="https://img.shields.io/badge/πŸ“-128K%20Context-10b981?style=flat-square" alt="Context"/>
  <img src="https://img.shields.io/badge/πŸ”“-Apache%202.0-f59e0b?style=flat-square" alt="License"/>
  <img src="https://img.shields.io/badge/πŸ’Ύ-Safetensors%20BF16-f97316?style=flat-square" alt="Format"/>
  <img src="https://img.shields.io/badge/🐍-Python%203.10%2B-3776ab?style=flat-square" alt="Python"/>
</p>

<p>
  <a href="#-quick-start"><img src="https://img.shields.io/badge/πŸš€%20Quick%20Start-5865F2?style=for-the-badge&logoColor=white" height="28"/></a>
  <a href="#-capabilities"><img src="https://img.shields.io/badge/🎯%20Capabilities-5865F2?style=for-the-badge&logoColor=white" height="28"/></a>
  <a href="#-usage"><img src="https://img.shields.io/badge/πŸ’»%20Usage-5865F2?style=for-the-badge&logoColor=white" height="28"/></a>
  <a href="#-benchmarks"><img src="https://img.shields.io/badge/πŸ“Š%20Benchmarks-5865F2?style=for-the-badge&logoColor=white" height="28"/></a>
</p>

</div>

---

## πŸ“‘ Table of Contents

- [Quick Start](#-quick-start)
- [Capabilities](#-capabilities)
- [Model Details](#-model-details)
- [Usage](#-usage)
  - [Transformers](#transformers)
  - [vLLM (Production)](#vllm-recommended-for-production)
  - [Inference API](#inference-api)
- [Interactive Examples](#-interactive-examples)
- [Benchmarks](#-benchmarks)
- [Acknowledgments](#-acknowledgments)

---

## πŸš€ Quick Start

Get up and running in **3 lines of code**:

```python
from transformers import pipeline

# Initialize the model
pipe = pipeline("text-generation", model="Soloman2002/hermit-code-7b")

# Start coding
chat = [{"role": "user", "content": "Write a Python function to reverse a linked list"}]
response = pipe(chat, max_new_tokens=512)

print(response[0]["generated_text"][-1]["content"])
```

> πŸ’‘ **Tip:** For best results, use `temperature=0.2` and `top_p=0.95` for deterministic code generation.

---

## 🎯 Capabilities

<div align="center">

| πŸ’» **Languages** | πŸ—οΈ **Code Gen** | πŸ“– **Explain** | πŸ› **Debug** | ⚑ **Refactor** | 🧠 **Context** |
|:---:|:---:|:---:|:---:|:---:|:---:|
| Python | Functions | Breakdowns | Bug Finding | Performance | 128K Tokens |
| JavaScript / TypeScript | Classes | Documentation | Fixing | Cleanup | Multi-file |
| Go | Scripts | Architecture | Optimization | Restructuring | Projects |
| Rust | Full Projects | Best Practices | Analysis | Modernization | Understanding |
| C++ | | | | | |
| Java | | | | | |

</div>

### ✨ What Makes Hermit Code Special?

- **🌐 Multi-Language Mastery** β€” Native fluency in 6+ programming languages
- **πŸ“¦ Project-Scale Context** β€” Understand entire codebases with 128K token context
- **πŸ” Debugging Expert** β€” Identifies bugs, explains why they happen, and fixes them
- **πŸŽ“ Educational** β€” Explains complex concepts with clear, step-by-step reasoning
- **βš™οΈ Production-Ready** β€” Optimized for both research and deployment via vLLM

---

## 🧠 Model Details

<div align="center">

| Property | Specification | Notes |
|:---|:---|:---|
| **Base Model** | [Qwen/Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct) | State-of-the-art code foundation |
| **Architecture** | Qwen2.5 Dense Transformer | Optimized for code understanding |
| **Parameters** | 7.61B (6.53B non-embedding) | Efficient size-to-performance ratio |
| **Layers** | 28 | Deep representation learning |
| **Attention** | GQA β€” 28 Q heads, 4 KV heads | Fast inference with grouped queries |
| **Context Length** | 131,072 tokens | ~100K+ lines of code context |
| **License** | Apache 2.0 | Commercial use permitted |
| **Format** | Safetensors (BF16) | Safe, efficient serialization |

</div>

---

## πŸ’» Usage

### Transformers

Perfect for **prototyping** and **local development**:

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

# Load model and tokenizer
model_id = "Soloman2002/hermit-code-7b"
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_id)

# Prepare chat messages
messages = [
    {"role": "system", "content": "You are Hermit Code, an expert coding assistant."},
    {"role": "user", "content": "Write a Rust function that checks if a string is a palindrome."}
]

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

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

# Decode response
response = tokenizer.decode(
    outputs[0][inputs.input_ids.shape[1]:],
    skip_special_tokens=True
)
print(response)
```

---

### vLLM (Recommended for Production)

For **high-throughput** serving and API deployment:

**1. Install & Launch:**
```bash
pip install vllm
vllm serve "Soloman2002/hermit-code-7b" --dtype bfloat16
```

**2. Query via API:**
```bash
curl -X POST "http://localhost:8000/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Soloman2002/hermit-code-7b",
    "messages": [
      {"role": "system", "content": "You are Hermit Code, a coding assistant."},
      {"role": "user", "content": "Explain closures in JavaScript with examples."}
    ],
    "temperature": 0.2,
    "max_tokens": 512
  }'
```

> πŸš€ **vLLM Benefits:** Continuous batching, PagedAttention, and 10-20x throughput improvement over standard Transformers.

---

### Inference API

Use **Hugging Face's hosted infrastructure** for instant access:

```python
from huggingface_hub import InferenceClient

client = InferenceClient(token="hf_YOUR_TOKEN")

response = client.chat_completion(
    model="Soloman2002/hermit-code-7b",
    messages=[
        {"role": "user", "content": "Write a Go function to merge two sorted arrays"}
    ],
    max_tokens=512,
    temperature=0.2,
    stream=False
)

print(response.choices[0].message.content)
```

---

## 🎨 Interactive Examples

Click any language below to expand and see Hermit Code in action:

<details>
<summary><b>🐍 Python</b> β€” Quick Sort Implementation</summary>

```python
def quick_sort(arr: list[int]) -> list[int]:
    """
    Sorts an array using the quicksort algorithm.
    Time Complexity: O(n log n) average, O(nΒ²) worst case
    Space Complexity: O(log n) due to recursion
    """
    if len(arr) <= 1:
        return arr

    pivot = arr[len(arr) // 2]
    left = [x for x in arr if x < pivot]
    middle = [x for x in arr if x == pivot]
    right = [x for x in arr if x > pivot]

    return quick_sort(left) + middle + quick_sort(right)


# Example usage
if __name__ == "__main__":
    data = [3, 6, 8, 10, 1, 2, 1]
    print(f"Original: {data}")
    print(f"Sorted:   {quick_sort(data)}")
```

**Key Features Demonstrated:**
- βœ… Type hints for better code clarity
- βœ… Docstrings with complexity analysis
- βœ… Recursive divide-and-conquer approach
- βœ… Idiomatic Python list comprehensions

</details>

<details>
<summary><b>πŸ¦€ Rust</b> β€” Palindrome Checker</summary>

```rust
/// Checks if a string is a palindrome, ignoring non-alphanumeric characters
/// and case differences.
/// 
/// # Examples
/// ```
/// assert!(is_palindrome("A man, a plan, a canal: Panama"));
/// assert!(!is_palindrome("Hello, World!"));
/// ```
fn is_palindrome(s: &str) -> bool {
    let chars: Vec<char> = s
        .chars()
        .filter(|c| c.is_alphanumeric())
        .map(|c| c.to_ascii_lowercase())
        .collect();

    let len = chars.len();
    for i in 0..len / 2 {
        if chars[i] != chars[len - 1 - i] {
            return false;
        }
    }
    true
}

fn main() {
    let test_cases = vec![
        "racecar",
        "A man, a plan, a canal: Panama",
        "Hello, World!",
    ];

    for case in test_cases {
        println!("'{}' -> {}", case, is_palindrome(case));
    }
}
```

**Key Features Demonstrated:**
- βœ… Memory-safe string processing
- βœ… Functional iterator chains
- βœ… Comprehensive documentation
- βœ… Efficient two-pointer comparison

</details>

<details>
<summary><b>🐹 Go</b> β€” Merge Sorted Arrays</summary>

```go
package main

import "fmt"

// mergeSorted combines two sorted integer slices into a single sorted slice.
// It runs in O(n + m) time where n and m are the lengths of the inputs.
func mergeSorted(a, b []int) []int {
    result := make([]int, 0, len(a)+len(b))
    i, j := 0, 0

    // Merge while both arrays have elements
    for i < len(a) && j < len(b) {
        if a[i] < b[j] {
            result = append(result, a[i])
            i++
        } else {
            result = append(result, b[j])
            j++
        }
    }

    // Append remaining elements
    result = append(result, a[i:]...)
    result = append(result, b[j:]...)

    return result
}

func main() {
    a := []int{1, 3, 5, 7}
    b := []int{2, 4, 6, 8}

    merged := mergeSorted(a, b)
    fmt.Printf("Merged: %v\n", merged) // [1 2 3 4 5 6 7 8]
}
```

**Key Features Demonstrated:**
- βœ… Pre-allocated slices for zero-allocation growth
- βœ… Two-pointer technique for optimal performance
- βœ… Idiomatic Go error-free design
- βœ… Clean, readable control flow

</details>

<details>
<summary><b>⚑ JavaScript</b> β€” Closure Example</summary>

```javascript
/**
 * Creates a counter with private state using closures.
 * Demonstrates lexical scoping and data encapsulation.
 */
function createCounter(initialValue = 0) {
    let count = initialValue; // Private variable

    return {
        increment() {
            count += 1;
            return count;
        },
        decrement() {
            count -= 1;
            return count;
        },
        getValue() {
            return count;
        },
        reset() {
            count = initialValue;
            return count;
        }
    };
}

// Usage
const counter = createCounter(10);
console.log(counter.increment()); // 11
console.log(counter.increment()); // 12
console.log(counter.getValue());  // 12
console.log(counter.reset());     // 10
```

**Key Features Demonstrated:**
- βœ… True private state via closures
- βœ… Clean object interface
- βœ… ES6 method shorthand syntax
- βœ… Default parameter values

</details>

---

## πŸ“Š Benchmarks

<div align="center">

| Benchmark | Score | Status | Comparison to Base |
|:---|:---:|:---:|:---|
| **HumanEval (Python)** | *TBD* | πŸ”„ Pending | vs Qwen2.5-Coder-7B |
| **HumanEval (Multi-Lang)** | *TBD* | πŸ”„ Pending | vs Qwen2.5-Coder-7B |
| **MBPP (Python)** | *TBD* | πŸ”„ Pending | vs Qwen2.5-Coder-7B |
| **DS-1000 (Data Science)** | *TBD* | πŸ”„ Pending | vs Qwen2.5-Coder-7B |

</div>

> πŸ“ˆ **Coming Soon:** Comprehensive evaluation results based on the Qwen2.5-Coder-7B-Instruct baseline with additional fine-tuning for agentic coding workflows.

---

## 🀝 Acknowledgments

<div align="center">

| Contribution | Team / Resource | Link |
|:---|:---|:---|
| **πŸ—οΈ Base Model** | Qwen Team | [Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct) |
| **πŸ€– Hermit AI Agent** | Hermit Team | [GitHub: Soloman2002](https://github.com/Soloman2002) |
| **πŸ“¦ Infrastructure** | Hugging Face | [Transformers](https://github.com/huggingface/transformers) & [vLLM](https://github.com/vllm-project/vllm) |

</div>

---

<div align="center">

## 🌟 Star Us on GitHub!

If you find Hermit Code useful, please consider starring the repository and sharing with your network.

<p>
  <a href="https://github.com/Soloman2002/hermit-code-7b">
    <img src="https://img.shields.io/badge/⭐-Star%20on%20GitHub-181717?style=for-the-badge&logo=github" alt="Star on GitHub"/>
  </a>
  <a href="https://huggingface.co/Soloman2002/hermit-code-7b">
    <img src="https://img.shields.io/badge/πŸ€—-Follow%20on%20HF-FFD21E?style=for-the-badge" alt="Follow on Hugging Face"/>
  </a>
</p>

<sub>Built with ❀️ for the coding community by the Hermit Team</sub>

</div>