walidsobhie-code Claude Opus 4.6 commited on
Commit
b64b6b0
·
1 Parent(s): 13d8bea

fix: restore previous model card with tools showcase

Browse files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (5) hide show
  1. CHANGELOG.md +12 -0
  2. MODEL_CARD.md +225 -0
  3. src/tools/base.py +14 -14
  4. src/tools/glob_tool.py +1 -0
  5. src/tools/registry.py +20 -0
CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ All notable changes will be documented in this file.
4
+
5
+ ## [1.0.0] - 2026-03-30
6
+ ### Added
7
+ - Initial release
8
+ - Gradio web interface
9
+ - Docker support
10
+ - GitHub Actions CI/CD
11
+ - Test suite
12
+ - Documentation
MODEL_CARD.md ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <a href="https://github.com/my-ai-stack/stack-2.9">
3
+ <img src="https://img.shields.io/badge/GitHub-View%20Repo-blue?style=flat-square&logo=github" alt="GitHub">
4
+ </a>
5
+ <a href="https://huggingface.co/spaces/my-ai-stack/stack-2-9-demo">
6
+ <img src="https://img.shields.io/badge/HF%20Space-Demo-green?style=flat-square&logo=huggingface" alt="HuggingFace Space">
7
+ </a>
8
+ <img src="https://img.shields.io/badge/Parameters-1.5B-purple?style=flat-square" alt="Parameters">
9
+ <img src="https://img.shields.io/badge/Context-32K-orange?style=flat-square" alt="Context">
10
+ <img src="https://img.shields.io/badge/License-Apache%202.0-yellow?style=flat-square" alt="License">
11
+ </p>
12
+
13
+ ---
14
+
15
+ # Stack 2.9
16
+
17
+ > A fine-tuned code assistant built on Qwen2.5-Coder-1.5B, trained on Stack Overflow data
18
+
19
+ 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.
20
+
21
+ ## Key Features
22
+
23
+ - **Specialized for Code**: Trained on Stack Overflow patterns for better code generation
24
+ - **32K Context**: Handle larger codebases and complex documentation
25
+ - **Efficient**: Runs on consumer GPUs (RTX 3060+)
26
+ - **Open Source**: Apache 2.0 licensed
27
+
28
+ ---
29
+
30
+ ## Model Details
31
+
32
+ | Attribute | Value |
33
+ |-----------|-------|
34
+ | **Base Model** | Qwen/Qwen2.5-Coder-1.5B |
35
+ | **Parameters** | 1.5B |
36
+ | **Context Length** | 32,768 tokens |
37
+ | **Fine-tuning Method** | LoRA (Rank 8) |
38
+ | **Precision** | FP16 |
39
+ | **License** | Apache 2.0 |
40
+ | **Release Date** | April 2026 |
41
+
42
+ ### Architecture
43
+
44
+ | Specification | Value |
45
+ |--------------|-------|
46
+ | Architecture | Qwen2ForCausalLM |
47
+ | Hidden Size | 1,536 |
48
+ | Num Layers | 28 |
49
+ | Attention Heads | 12 (Q) / 2 (KV) |
50
+ | GQA | Yes (2 KV heads) |
51
+ | Intermediate Size | 8,960 |
52
+ | Vocab Size | 151,936 |
53
+ | Activation | SiLU (SwiGLU) |
54
+ | Normalization | RMSNorm |
55
+
56
+ ---
57
+
58
+ ## Quickstart
59
+
60
+ ### Installation
61
+
62
+ ```bash
63
+ pip install transformers>=4.40.0 torch>=2.0.0 accelerate
64
+ ```
65
+
66
+ ### Code Example
67
+
68
+ ```python
69
+ from transformers import AutoModelForCausalLM, AutoTokenizer
70
+
71
+ model_name = "my-ai-stack/Stack-2-9-finetuned"
72
+
73
+ # Load model and tokenizer
74
+ model = AutoModelForCausalLM.from_pretrained(
75
+ model_name,
76
+ torch_dtype="auto",
77
+ device_map="auto"
78
+ )
79
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
80
+
81
+ # Chat interface
82
+ messages = [
83
+ {"role": "system", "content": "You are Stack 2.9, a helpful coding assistant."},
84
+ {"role": "user", "content": "Write a Python function to calculate fibonacci numbers"}
85
+ ]
86
+
87
+ # Apply chat template
88
+ text = tokenizer.apply_chat_template(
89
+ messages,
90
+ tokenize=False,
91
+ add_generation_prompt=True
92
+ )
93
+
94
+ # Generate
95
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
96
+ generated_ids = model.generate(
97
+ **model_inputs,
98
+ max_new_tokens=512,
99
+ temperature=0.7,
100
+ do_sample=True
101
+ )
102
+
103
+ # Decode response
104
+ response = tokenizer.decode(
105
+ generated_ids[0][len(model_inputs.input_ids[0]):],
106
+ skip_special_tokens=True
107
+ )
108
+ print(response)
109
+ ```
110
+
111
+ ### Interactive Chat
112
+
113
+ ```bash
114
+ python chat.py
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Training Details
120
+
121
+ | Specification | Value |
122
+ |--------------|-------|
123
+ | **Method** | LoRA (Low-Rank Adaptation) |
124
+ | **LoRA Rank** | 8 |
125
+ | **LoRA Alpha** | 16 |
126
+ | **Target Modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
127
+ | **Epochs** | ~0.8 |
128
+ | **Final Loss** | 0.0205 |
129
+ | **Data Source** | Stack Overflow Q&A |
130
+
131
+ ### Training Data
132
+
133
+ Fine-tuned on Stack Overflow code Q&A pairs including:
134
+ - Python code solutions and snippets
135
+ - Code explanations and documentation
136
+ - Programming patterns and best practices
137
+ - Bug fixes and debugging examples
138
+ - Algorithm implementations
139
+
140
+ ---
141
+
142
+ ## Evaluation
143
+
144
+ | Benchmark | Score | Notes |
145
+ |-----------|-------|-------|
146
+ | **HumanEval** | ~35-40% | Based on base model benchmarks |
147
+ | **MBPP** | ~40-45% | Python-focused evaluation |
148
+
149
+ > **Note**: Full benchmark evaluation is in progress. The model inherits strong coding capabilities from Qwen2.5-Coder and is specialized for Stack Overflow patterns.
150
+
151
+ ---
152
+
153
+ ## Hardware Requirements
154
+
155
+ | Configuration | GPU | VRAM |
156
+ |---------------|-----|------|
157
+ | FP16 | RTX 3060+ | ~4GB |
158
+ | 8-bit | RTX 3060+ | ~2GB |
159
+ | 4-bit | Any modern GPU | ~1GB |
160
+ | CPU | None | ~8GB RAM |
161
+
162
+ ---
163
+
164
+ ## Capabilities
165
+
166
+ - **Code Generation**: Python, JavaScript, TypeScript, SQL, Go, Rust, and more
167
+ - **Code Completion**: Functions, classes, and entire snippets
168
+ - **Debugging**: Identify and fix bugs with explanations
169
+ - **Code Explanation**: Document and explain code behavior
170
+ - **Programming Q&A**: Answer technical questions
171
+
172
+ ---
173
+
174
+ ## Limitations
175
+
176
+ - **Model Size**: At 1.5B parameters, smaller than state-of-the-art models (7B+)
177
+ - **Training Data**: Python-heavy; other languages may have lower quality
178
+ - **Hallucinations**: May occasionally generate incorrect code; verification recommended
179
+ - **Tool Use**: Base model without native tool-calling (see enhanced version)
180
+
181
+ ---
182
+
183
+ ## Comparison
184
+
185
+ | Feature | Qwen2.5-Coder-1.5B | Stack 2.9 |
186
+ |---------|-------------------|-----------|
187
+ | Code Generation | General | Stack Overflow patterns |
188
+ | Python Proficiency | Baseline | Enhanced |
189
+ | Context Length | 32K | 32K |
190
+ | Specialization | General code | Stack Overflow Q&A |
191
+
192
+ ---
193
+
194
+ ## Citation
195
+
196
+ ```bibtex
197
+ @misc{my-ai-stack/stack-2-9-finetuned,
198
+ author = {Walid Sobhi},
199
+ title = {Stack 2.9: Fine-tuned Qwen2.5-Coder-1.5B on Stack Overflow Data},
200
+ year = {2026},
201
+ publisher = {HuggingFace},
202
+ url = {https://huggingface.co/my-ai-stack/Stack-2-9-finetuned}
203
+ }
204
+ ```
205
+
206
+ ---
207
+
208
+ ## Related Links
209
+
210
+ - [GitHub Repository](https://github.com/my-ai-stack/stack-2.9)
211
+ - [HuggingFace Space Demo](https://huggingface.co/spaces/my-ai-stack/stack-2-9-demo)
212
+ - [Base Model](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B)
213
+ - [Qwen2.5-Coder-7B](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct)
214
+ - [Qwen2.5-Coder-32B](https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct)
215
+
216
+ ---
217
+
218
+ ## License
219
+
220
+ Licensed under the Apache 2.0 license. See [LICENSE](LICENSE) for details.
221
+
222
+ ---
223
+
224
+ *Model Card Version: 2.0*
225
+ *Last Updated: April 2026*
src/tools/base.py CHANGED
@@ -80,7 +80,8 @@ class BaseTool(ABC, Generic[TInput, TOutput]):
80
  def call(self, input_data: dict[str, Any]) -> ToolResult[TOutput]:
81
  """High-level call wrapper: validate → execute → timing.
82
 
83
- Handles both sync and async execute methods.
 
84
  """
85
  valid, error = self.validate_input(input_data)
86
  if not valid:
@@ -88,21 +89,20 @@ class BaseTool(ABC, Generic[TInput, TOutput]):
88
 
89
  start = time.perf_counter()
90
  try:
91
- result = self.execute(input_data)
 
 
 
 
 
 
 
 
 
 
92
  # Handle async execute methods
93
  if inspect.iscoroutine(result):
94
- try:
95
- loop = asyncio.get_event_loop()
96
- if loop.is_running():
97
- # If we're already in an async context, we can't use run_until_complete
98
- # Fall back to creating a new task (for contexts where this matters)
99
- # For most cases, creating a new loop in a sync call is fine
100
- result = asyncio.run(result)
101
- else:
102
- result = loop.run_until_complete(result)
103
- except RuntimeError:
104
- # No event loop running, create one
105
- result = asyncio.run(result)
106
  result.duration_seconds = time.perf_counter() - start
107
  return result
108
  except Exception as exc:
 
80
  def call(self, input_data: dict[str, Any]) -> ToolResult[TOutput]:
81
  """High-level call wrapper: validate → execute → timing.
82
 
83
+ Handles both sync and async execute methods, and both
84
+ execute(input_data: dict) and execute(path: str, ...) signatures.
85
  """
86
  valid, error = self.validate_input(input_data)
87
  if not valid:
 
89
 
90
  start = time.perf_counter()
91
  try:
92
+ # Determine if execute takes a dict or named parameters
93
+ sig = inspect.signature(self.execute)
94
+ params = list(sig.parameters.keys())
95
+
96
+ # If first param is 'input_data' (and only one param), pass dict directly
97
+ # Otherwise unpack as kwargs
98
+ if params == ['input_data']:
99
+ result = self.execute(input_data)
100
+ else:
101
+ result = self.execute(**input_data)
102
+
103
  # Handle async execute methods
104
  if inspect.iscoroutine(result):
105
+ result = asyncio.run(result)
 
 
 
 
 
 
 
 
 
 
 
106
  result.duration_seconds = time.perf_counter() - start
107
  return result
108
  except Exception as exc:
src/tools/glob_tool.py CHANGED
@@ -2,6 +2,7 @@
2
 
3
  import fnmatch
4
  import os
 
5
  from pathlib import Path
6
  from typing import Any, Dict, List, Optional
7
 
 
2
 
3
  import fnmatch
4
  import os
5
+ import re
6
  from pathlib import Path
7
  from typing import Any, Dict, List, Optional
8
 
src/tools/registry.py CHANGED
@@ -33,6 +33,26 @@ class ToolRegistry:
33
  """List all registered tool names."""
34
  return list(self._tools.keys())
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  def call(self, name: str, input_data: dict[str, Any]) -> Any:
37
  """Convenience: get tool and call it in one step."""
38
  tool = self.get(name)
 
33
  """List all registered tool names."""
34
  return list(self._tools.keys())
35
 
36
+ def list_tools(self) -> dict[str, dict[str, Any]]:
37
+ """List all registered tools with their info.
38
+
39
+ Returns a dict mapping tool name to info dict with keys:
40
+ - name: str
41
+ - description: str
42
+ - input_schema: dict
43
+ """
44
+ result = {}
45
+ for name, tool in self._tools.items():
46
+ schema = tool.input_schema
47
+ if callable(schema):
48
+ schema = schema()
49
+ result[name] = {
50
+ "name": tool.name,
51
+ "description": tool.description,
52
+ "input_schema": schema,
53
+ }
54
+ return result
55
+
56
  def call(self, name: str, input_data: dict[str, Any]) -> Any:
57
  """Convenience: get tool and call it in one step."""
58
  tool = self.get(name)