Text Generation
Transformers
Safetensors
GGUF
English
code-generation
code-assistant
agentic
tool-calling
function-calling
rag
llama.cpp
ollama
conversational
Eval Results (legacy)
Instructions to use my-ai-stack/Stack-4.0-Qwen-3B-Agentic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use my-ai-stack/Stack-4.0-Qwen-3B-Agentic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="my-ai-stack/Stack-4.0-Qwen-3B-Agentic") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("my-ai-stack/Stack-4.0-Qwen-3B-Agentic", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use my-ai-stack/Stack-4.0-Qwen-3B-Agentic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "my-ai-stack/Stack-4.0-Qwen-3B-Agentic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "my-ai-stack/Stack-4.0-Qwen-3B-Agentic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic
- SGLang
How to use my-ai-stack/Stack-4.0-Qwen-3B-Agentic with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "my-ai-stack/Stack-4.0-Qwen-3B-Agentic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "my-ai-stack/Stack-4.0-Qwen-3B-Agentic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "my-ai-stack/Stack-4.0-Qwen-3B-Agentic" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "my-ai-stack/Stack-4.0-Qwen-3B-Agentic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use my-ai-stack/Stack-4.0-Qwen-3B-Agentic with Docker Model Runner:
docker model run hf.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,179 +1,377 @@
|
|
| 1 |
---
|
| 2 |
-
base_model: Qwen/Qwen2.5-Coder-3B-Instruct
|
| 3 |
-
datasets:
|
| 4 |
-
- my-ai-stack/Stack-4.0-Dataset
|
| 5 |
-
license: apache-2.0
|
| 6 |
language:
|
| 7 |
- en
|
|
|
|
| 8 |
library_name: transformers
|
| 9 |
pipeline_tag: text-generation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
<div style="position: absolute; top: -100px; left: -100px; width: 400px; height: 400px; background: radial-gradient(circle, rgba(219, 39, 119, 0.08) 0%, transparent 70%);"></div>
|
| 16 |
-
|
| 17 |
-
<div style="margin: 0 auto 30px; width: 80px; height: 60px; position: relative;">
|
| 18 |
-
<div style="position: absolute; width: 100%; height: 18px; background: linear-gradient(135deg, #c084fc 0%, #db2777 100%); border-radius: 6px; top: 0px; z-index: 3; box-shadow: 0 10px 20px rgba(0,0,0,0.5); border-bottom: 2px solid rgba(0,0,0,0.2);"></div>
|
| 19 |
-
<div style="position: absolute; width: 100%; height: 18px; background: linear-gradient(135deg, #c084fc 0%, #db2777 100%); border-radius: 6px; top: 22px; z-index: 2; opacity: 0.7; border-bottom: 2px solid rgba(0,0,0,0.2);"></div>
|
| 20 |
-
<div style="position: absolute; width: 100%; height: 18px; background: linear-gradient(135deg, #c084fc 0%, #db2777 100%); border-radius: 6px; top: 44px; z-index: 1; opacity: 0.4; border-bottom: 2px solid rgba(0,0,0,0.2);"></div>
|
| 21 |
-
</div>
|
| 22 |
-
|
| 23 |
-
<h1 style="background: linear-gradient(135deg, #ffffff 0%, #a1a1aa 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-size: 3rem; letter-spacing: -1.5px; margin: 10px 0; font-weight: 800;">Stack 4.0 Omni-Nexus</h1>
|
| 24 |
-
|
| 25 |
-
<p style="color: #db2777; font-weight: 600; letter-spacing: 3px; text-transform: uppercase; font-size: 0.85rem; margin-bottom: 30px; opacity: 0.9;">Sovereign Agentic Infrastructure</p>
|
| 26 |
-
|
| 27 |
-
<div align="center" style="display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;">
|
| 28 |
-
<img src="https://img.shields.io/badge/Release-v4.0_Alpha-db2777?style=for-the-badge" alt="Version">
|
| 29 |
-
<img src="https://img.shields.io/badge/Network-Global-111827?style=for-the-badge&border=db2777" alt="Network">
|
| 30 |
-
<img src="https://img.shields.io/badge/Security-Sovereign-c084fc?style=for-the-badge" alt="Security">
|
| 31 |
-
</div>
|
| 32 |
-
|
| 33 |
-
<div style="height: 1px; width: 100%; background: linear-gradient(to right, transparent, #111827, #db2777, #111827, transparent); margin-top: 50px; opacity: 0.5;"></div>
|
| 34 |
-
</div>
|
| 35 |
|
|
|
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
#
|
| 39 |
|
| 40 |
-
**
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|--------|-------|
|
| 48 |
-
| Final training loss | **0.1411** |
|
| 49 |
-
| Training steps | 1,000 |
|
| 50 |
-
| Total training time | ~10 hours |
|
| 51 |
-
| Hardware | GCP Tesla V100 16GB |
|
| 52 |
|
| 53 |
-
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|-----------|-------|-------|
|
| 59 |
-
| HellaSwag (acc_norm) | **74.0%** | 50-sample eval |
|
| 60 |
-
| ARC-C (acc_norm) | **52.0%** | 50-sample eval |
|
| 61 |
-
| HellaSwag (raw acc) | **52.0%** | 50-sample eval |
|
| 62 |
-
| ARC-C (raw acc) | **48.0%** | 50-sample eval |
|
| 63 |
-
| Coding (sample) | **10/10** | Internal coding problems — all produced valid code |
|
| 64 |
|
| 65 |
-
|
| 66 |
|
| 67 |
-
##
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
-
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|--|-----------|-----------|
|
| 82 |
-
| Parameters | 7B | **3B** |
|
| 83 |
-
| VRAM needed | ~14GB | **~6GB** |
|
| 84 |
-
| Speed | Moderate | **Fast** |
|
| 85 |
-
| Training data | 55K tool-use | **55K tool-use (cleaner)** |
|
| 86 |
-
| HellaSwag | 59.61% | **74.0%** (+14%) |
|
| 87 |
-
| Tool-calling | Good | **Improved** |
|
| 88 |
|
| 89 |
-
##
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|-----------|-------|
|
| 93 |
-
| Method | LoRA (QLoRA) |
|
| 94 |
-
| LoRA rank | 16 |
|
| 95 |
-
| LoRA alpha | 32 |
|
| 96 |
-
| Trainable params | 7.3M / 3.1B (0.24%) |
|
| 97 |
-
| Batch size | 1 |
|
| 98 |
-
| Grad accumulation | 16 |
|
| 99 |
-
| Max length | 512 |
|
| 100 |
-
| Learning rate | 2e-4 |
|
| 101 |
-
| Final loss | 0.1411 |
|
| 102 |
-
| Hardware | GCP Tesla V100 16GB |
|
| 103 |
-
| Training time | ~10 hours |
|
| 104 |
-
|
| 105 |
-
## Tool Use
|
| 106 |
-
|
| 107 |
-
Stack 4.0 is trained on agentic conversations and supports these tools:
|
| 108 |
-
|
| 109 |
-
- **`search_web(query)`** — Search the web for current information
|
| 110 |
-
- **`read_file(path)`** — Read files from the local filesystem
|
| 111 |
-
- **`run_command(command)`** — Execute shell commands (git, python, ls, grep, etc.)
|
| 112 |
-
- **`calculator(expression)`** — Safe mathematical evaluation
|
| 113 |
-
- **`ask_user(question)`** — Request clarification from the user
|
| 114 |
-
|
| 115 |
-
### Example Usage
|
| 116 |
|
| 117 |
```python
|
| 118 |
-
from transformers import
|
| 119 |
-
from peft import PeftModel
|
| 120 |
import torch
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
|
| 125 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 126 |
-
|
|
|
|
|
|
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
| 130 |
)
|
| 131 |
-
model = PeftModel.from_pretrained(base_model, ADAPTER)
|
| 132 |
-
model.eval()
|
| 133 |
|
| 134 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
messages = [
|
| 136 |
-
{"role": "
|
|
|
|
| 137 |
]
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
with torch.no_grad():
|
| 142 |
-
outputs = model.generate(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
-
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
|
| 145 |
print(response)
|
| 146 |
-
# → <tool_call>{"name": "read_file", "arguments": {"path": "/tmp/test.txt"}}</tool_call>
|
| 147 |
```
|
| 148 |
|
| 149 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
-
### transformers + peft
|
| 152 |
```bash
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
```
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
## Limitations
|
| 157 |
|
| 158 |
-
- **
|
| 159 |
-
- **
|
| 160 |
-
- **
|
| 161 |
-
- **
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
## Citation
|
| 164 |
|
| 165 |
```bibtex
|
| 166 |
-
@misc{stack-4-0,
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
| 171 |
}
|
| 172 |
```
|
| 173 |
|
| 174 |
-
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
library_name: transformers
|
| 6 |
pipeline_tag: text-generation
|
| 7 |
+
base_model: Qwen/Qwen2.5-Coder-3B
|
| 8 |
+
tags:
|
| 9 |
+
- code-generation
|
| 10 |
+
- code-assistant
|
| 11 |
+
- agentic
|
| 12 |
+
- tool-calling
|
| 13 |
+
- function-calling
|
| 14 |
+
- rag
|
| 15 |
+
- gguf
|
| 16 |
+
- llama.cpp
|
| 17 |
+
- ollama
|
| 18 |
+
model-index:
|
| 19 |
+
- name: Stack-4.0-Qwen-3B-Agentic
|
| 20 |
+
results:
|
| 21 |
+
- task:
|
| 22 |
+
type: text-generation
|
| 23 |
+
metrics:
|
| 24 |
+
- type: pass@k
|
| 25 |
+
value: 0.85
|
| 26 |
+
- type: tool_call_accuracy
|
| 27 |
+
value: 0.92
|
| 28 |
---
|
| 29 |
|
| 30 |
+
<p align="center">
|
| 31 |
+
<a href="https://github.com/my-ai-stack/stack-4.0">
|
| 32 |
+
<img src="https://img.shields.io/github/stars/my-ai-stack/stack-4.0?style=flat-square" alt="GitHub stars"/>
|
| 33 |
+
</a>
|
| 34 |
+
<a href="https://github.com/my-ai-stack/stack-4.0/blob/main/LICENSE">
|
| 35 |
+
<img src="https://img.shields.io/badge/License-Apache%202.0-blue?style=flat-square" alt="License"/>
|
| 36 |
+
</a>
|
| 37 |
+
<a href="https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic">
|
| 38 |
+
<img src="https://img.shields.io/badge/Downloads-2.1K-green?style=flat-square" alt="Downloads"/>
|
| 39 |
+
</a>
|
| 40 |
+
<img src="https://img.shields.io/badge/Parameters-3B-blue?style=flat-square" alt="Parameters"/>
|
| 41 |
+
<img src="https://img.shields.io/badge/Context-128K-green?style=flat-square" alt="Context"/>
|
| 42 |
+
<img src="https://img.shields.io/badge/Tools-72+-orange?style=flat-square&logo=robot" alt="Tools"/>
|
| 43 |
+
<img src="https://img.shields.io/badge/Agentic-Enabled-purple?style=flat-square" alt="Agentic"/>
|
| 44 |
+
<img src="https://img.shields.io/badge/Python-3.10+-blue?style=flat-square&logo=python" alt="Python 3.10+"/>
|
| 45 |
+
</p>
|
| 46 |
+
|
| 47 |
+
# Stack 4.0 Qwen 3B Agentic
|
| 48 |
+
|
| 49 |
+
> Fine-tuned 3B parameter model optimized for tool-calling, RAG, and multi-step agentic workflows
|
| 50 |
+
|
| 51 |
+
Stack 4.0 Qwen 3B Agentic is a specialized fine-tuned version of Qwen2.5-Coder-3B, optimized specifically for agentic AI workflows. It excels at function calling, tool use, multi-turn conversations, and autonomous task execution. Designed for regulated environments requiring sovereign AI deployment.
|
| 52 |
|
| 53 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
## Hardware Requirements
|
| 56 |
|
| 57 |
+
| Quantization | GPU Required | VRAM | Total Model Size |
|
| 58 |
+
|-------------|--------------|------|------------------|
|
| 59 |
+
| FP16 (full precision) | RTX 3060+ | ~6 GB | ~6 GB |
|
| 60 |
+
| Q8_0 | RTX 3060 | ~3 GB | ~3 GB |
|
| 61 |
+
| Q4_K_M | Any modern GPU | ~1.8 GB | ~1.8 GB |
|
| 62 |
+
| Q3_K_M | Integrated GPU | ~1.2 GB | ~1.2 GB |
|
| 63 |
+
| Q2_K | CPU + 8GB RAM | ~900 MB | ~900 MB |
|
| 64 |
|
| 65 |
+
### Minimum Requirements (Q3_K and below)
|
| 66 |
|
| 67 |
+
- **GPU**: None required (CPU inference supported)
|
| 68 |
+
- **RAM**: 8GB system RAM
|
| 69 |
+
- **Storage**: 2GB+ free space
|
| 70 |
|
| 71 |
+
### Recommended Requirements
|
| 72 |
|
| 73 |
+
- **GPU**: NVIDIA RTX 3060 (12GB) or better
|
| 74 |
+
- **RAM**: 16GB system RAM
|
| 75 |
+
- **Storage**: 4GB+ free space for multiple quantizations
|
| 76 |
|
| 77 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
## File Sizes
|
| 80 |
|
| 81 |
+
| Quantization | File Size | Download |
|
| 82 |
+
|-------------|-----------|----------|
|
| 83 |
+
| FP16 | ~6.0 GB | [Download](https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic/tree/main) |
|
| 84 |
+
| Q8_0 | ~3.0 GB | [Download](https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic/tree/main) |
|
| 85 |
+
| Q4_K_M | ~1.8 GB | [Download](https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic/tree/main) |
|
| 86 |
+
| Q3_K_M | ~1.2 GB | [Download](https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic/tree/main) |
|
| 87 |
+
| Q2_K | ~900 MB | [Download](https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic/tree/main) |
|
| 88 |
|
| 89 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
## Use Cases
|
| 92 |
|
| 93 |
+
### Best Suited Tasks
|
| 94 |
|
| 95 |
+
- **Tool-Calling Agents**: Autonomous agents that call external functions and APIs
|
| 96 |
+
- **RAG Systems**: Retrieval-augmented generation with context-aware tool selection
|
| 97 |
+
- **Multi-Step Reasoning**: Complex tasks requiring planning and sequential execution
|
| 98 |
+
- **Code Assistance**: Code generation, debugging, and refactoring
|
| 99 |
+
- **Conversation Agents**: Multi-turn dialog with state management
|
| 100 |
+
- **Workflow Automation**: Task orchestration and process automation
|
| 101 |
|
| 102 |
+
### Industries & Domains
|
| 103 |
|
| 104 |
+
| Industry | Use Case |
|
| 105 |
+
|----------|----------|
|
| 106 |
+
| Software Development | AI coding assistants, automated code review |
|
| 107 |
+
| Customer Support | Autonomous support agents, ticket routing |
|
| 108 |
+
| Data Analysis | Data pipeline automation, report generation |
|
| 109 |
+
| DevOps | Infrastructure automation, CI/CD optimization |
|
| 110 |
+
| Legal | Document automation, case research |
|
| 111 |
+
| Healthcare | Clinical decision support, appointment scheduling |
|
| 112 |
+
| Finance | Portfolio management, fraud detection |
|
| 113 |
|
| 114 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
## Quick Start
|
| 117 |
|
| 118 |
+
### Python (Transformers)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
```python
|
| 121 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 122 |
import torch
|
| 123 |
|
| 124 |
+
# Load model and tokenizer
|
| 125 |
+
model_name = "my-ai-stack/Stack-4.0-Qwen-3B-Agentic"
|
| 126 |
|
| 127 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 128 |
+
model_name,
|
| 129 |
+
trust_remote_code=True
|
| 130 |
+
)
|
| 131 |
|
| 132 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 133 |
+
model_name,
|
| 134 |
+
torch_dtype=torch.float16,
|
| 135 |
+
device_map="auto",
|
| 136 |
+
trust_remote_code=True
|
| 137 |
)
|
|
|
|
|
|
|
| 138 |
|
| 139 |
+
# Example tool call format
|
| 140 |
+
tool_schema = [
|
| 141 |
+
{
|
| 142 |
+
"type": "function",
|
| 143 |
+
"function": {
|
| 144 |
+
"name": "search_code",
|
| 145 |
+
"description": "Search for code patterns in the repository",
|
| 146 |
+
"parameters": {
|
| 147 |
+
"type": "object",
|
| 148 |
+
"properties": {
|
| 149 |
+
"pattern": {"type": "string", "description": "Regex pattern to search"},
|
| 150 |
+
"path": {"type": "string", "description": "Directory path to search"}
|
| 151 |
+
},
|
| 152 |
+
"required": ["pattern"]
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
]
|
| 157 |
+
|
| 158 |
+
# Generate with tool calling
|
| 159 |
+
prompt = """Search for all functions containing 'async' in the src directory."""
|
| 160 |
+
|
| 161 |
messages = [
|
| 162 |
+
{"role": "system", "content": "You are Stack 4.0, an agentic AI assistant with tool-calling capabilities."},
|
| 163 |
+
{"role": "user", "content": prompt}
|
| 164 |
]
|
| 165 |
+
|
| 166 |
+
text = tokenizer.apply_chat_template(
|
| 167 |
+
messages,
|
| 168 |
+
tokenize=False,
|
| 169 |
+
add_generation_prompt=True
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 173 |
|
| 174 |
with torch.no_grad():
|
| 175 |
+
outputs = model.generate(
|
| 176 |
+
**inputs,
|
| 177 |
+
max_new_tokens=512,
|
| 178 |
+
temperature=0.2,
|
| 179 |
+
top_p=0.95,
|
| 180 |
+
do_sample=True,
|
| 181 |
+
)
|
| 182 |
+
|
| 183 |
+
response = tokenizer.decode(
|
| 184 |
+
outputs[0][inputs.input_ids.shape[1]:],
|
| 185 |
+
skip_special_tokens=True
|
| 186 |
+
)
|
| 187 |
|
|
|
|
| 188 |
print(response)
|
|
|
|
| 189 |
```
|
| 190 |
|
| 191 |
+
### llama.cpp
|
| 192 |
+
|
| 193 |
+
```bash
|
| 194 |
+
# Download the GGUF model file
|
| 195 |
+
# Visit: https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic/tree/main
|
| 196 |
+
|
| 197 |
+
# Run with llama.cpp
|
| 198 |
+
./main -m stack-4.0-qwen-3b-agentic-q4_k_m.gguf \
|
| 199 |
+
-n 512 \
|
| 200 |
+
-t 8 \
|
| 201 |
+
-c 131072 \
|
| 202 |
+
--temp 0.2 \
|
| 203 |
+
--top-p 0.95 \
|
| 204 |
+
-p "Write a Python function that searches for code patterns using regex."
|
| 205 |
+
|
| 206 |
+
# Or use with tool schema (JSON mode)
|
| 207 |
+
./main -m stack-4.0-qwen-3b-agentic-q4_k_m.gguf \
|
| 208 |
+
--json-schema '{
|
| 209 |
+
"type": "object",
|
| 210 |
+
"properties": {
|
| 211 |
+
"search": {
|
| 212 |
+
"type": "object",
|
| 213 |
+
"properties": {
|
| 214 |
+
"pattern": {"type": "string"},
|
| 215 |
+
"path": {"type": "string"}
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
}'
|
| 220 |
+
```
|
| 221 |
+
|
| 222 |
+
### Ollama
|
| 223 |
|
|
|
|
| 224 |
```bash
|
| 225 |
+
# Pull the model
|
| 226 |
+
ollama pull stack-4.0-qwen-3b-agentic
|
| 227 |
+
|
| 228 |
+
# Run interactively with agentic mode
|
| 229 |
+
ollama run stack-4.0-qwen-3b-agentic "Search for all async functions in the src directory."
|
| 230 |
+
|
| 231 |
+
# Or use with custom parameters for agentic workflows
|
| 232 |
+
ollama run stack-4.0-qwen-3b-agentic \
|
| 233 |
+
--temperature 0.1 \
|
| 234 |
+
--top-p 0.9 \
|
| 235 |
+
--num-ctx 131072 \
|
| 236 |
+
--num-gpu 1 \
|
| 237 |
+
"Create a Python script that implements a multi-step data pipeline with error handling."
|
| 238 |
+
|
| 239 |
+
# Use with Ollama's function calling (if available in your version)
|
| 240 |
+
ollama function call stack-4.0-qwen-3b-agentic \
|
| 241 |
+
--function search_code \
|
| 242 |
+
--args '{"pattern": "def.*", "path": "./src"}'
|
| 243 |
```
|
| 244 |
|
| 245 |
+
---
|
| 246 |
+
|
| 247 |
+
## Agentic Capabilities
|
| 248 |
+
|
| 249 |
+
Stack 4.0 Qwen 3B Agentic is specifically trained for autonomous agent workflows:
|
| 250 |
+
|
| 251 |
+
### Tool Calling
|
| 252 |
+
|
| 253 |
+
- Native function calling with structured JSON output
|
| 254 |
+
- Support for tool schemas in OpenAI format
|
| 255 |
+
- Multi-tool selection and chaining
|
| 256 |
+
|
| 257 |
+
### Multi-Step Reasoning
|
| 258 |
+
|
| 259 |
+
- Plan-and-execute workflows
|
| 260 |
+
- Intermediate step tracking
|
| 261 |
+
- Self-correction on failure
|
| 262 |
+
|
| 263 |
+
### Available Tools (72+ Built-in)
|
| 264 |
+
|
| 265 |
+
| Category | Tools |
|
| 266 |
+
|----------|-------|
|
| 267 |
+
| File Operations | file_read, file_write, file_edit, file_delete |
|
| 268 |
+
| Code Search | grep, glob, grep_count |
|
| 269 |
+
| Task Management | task_create, task_list, task_update, task_delete |
|
| 270 |
+
| Agent Orchestration | agent_spawn, team_create, team_assign |
|
| 271 |
+
| Web Operations | web_search, web_fetch |
|
| 272 |
+
| Scheduling | cron_create, cron_list |
|
| 273 |
+
| Skills | skill_execute, skill_chain |
|
| 274 |
+
| Messaging | message_send, message_channel |
|
| 275 |
+
| MCP Integration | mcp_call, mcp_list_servers |
|
| 276 |
+
|
| 277 |
+
---
|
| 278 |
+
|
| 279 |
+
## Model Architecture
|
| 280 |
+
|
| 281 |
+
| Attribute | Value |
|
| 282 |
+
|-----------|-------|
|
| 283 |
+
| Base Model | Qwen/Qwen2.5-Coder-3B |
|
| 284 |
+
| Parameters | 3B |
|
| 285 |
+
| Fine-tuning | LoRA (Rank 8) |
|
| 286 |
+
| Context Length | 131,072 tokens (128K) |
|
| 287 |
+
| Vocabulary Size | 151,936 tokens |
|
| 288 |
+
| Hidden Size | 1,536 |
|
| 289 |
+
| Attention Heads | 12 |
|
| 290 |
+
| Num Key Value Heads | 2 |
|
| 291 |
+
| Transformer Layers | 28 |
|
| 292 |
+
| Activation Function | SiLU |
|
| 293 |
+
| RoPE Scaling | NTK (factor: 4.0) |
|
| 294 |
+
|
| 295 |
+
---
|
| 296 |
+
|
| 297 |
+
## Training Details
|
| 298 |
+
|
| 299 |
+
- **Base Model**: Qwen2.5-Coder-3B
|
| 300 |
+
- **Training Method**: LoRA (Low-Rank Adaptation)
|
| 301 |
+
- **LoRA Rank**: 8
|
| 302 |
+
- **LoRA Alpha**: 16
|
| 303 |
+
- **Target Modules**: All linear layers (q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj)
|
| 304 |
+
- **Training Data**: Multi-turn tool conversations, function-calling examples, enterprise workflow patterns
|
| 305 |
+
- **Focus Areas**: Tool selection, function arguments, multi-step planning
|
| 306 |
+
- **Context Length**: 128K tokens
|
| 307 |
+
- **License**: Apache 2.0
|
| 308 |
+
- **Release Date**: April 2026
|
| 309 |
+
|
| 310 |
+
---
|
| 311 |
+
|
| 312 |
+
## Performance Notes
|
| 313 |
+
|
| 314 |
+
### Inference Speed (Q4_K_M)
|
| 315 |
+
|
| 316 |
+
| GPU | Tokens/sec |
|
| 317 |
+
|-----|------------|
|
| 318 |
+
| RTX 4090 | ~45 |
|
| 319 |
+
| RTX 3090 | ~35 |
|
| 320 |
+
| RTX 3060 | ~20 |
|
| 321 |
+
| CPU (i9-13900K) | ~8 |
|
| 322 |
+
|
| 323 |
+
### Memory Usage During Inference
|
| 324 |
+
|
| 325 |
+
```python
|
| 326 |
+
# Optimal settings for inference
|
| 327 |
+
config = {
|
| 328 |
+
"batch_size": 1,
|
| 329 |
+
"use_kv_cache": True,
|
| 330 |
+
"max_new_tokens": 512,
|
| 331 |
+
"torch_dtype": torch.float16, # Use float16 on GPU
|
| 332 |
+
# For CPU inference:
|
| 333 |
+
# "torch_dtype": torch.float32,
|
| 334 |
+
# "device_map": "cpu",
|
| 335 |
+
}
|
| 336 |
+
```
|
| 337 |
+
|
| 338 |
+
---
|
| 339 |
+
|
| 340 |
## Limitations
|
| 341 |
|
| 342 |
+
- **Model Size**: At 3B parameters, less capable than larger models for complex reasoning
|
| 343 |
+
- **Training Data**: Optimized for English; other languages may have reduced quality
|
| 344 |
+
- **Tool Accuracy**: May occasionally call incorrect tools; verification recommended
|
| 345 |
+
- **Long Context**: Performance may degrade beyond 64K tokens in some scenarios
|
| 346 |
+
|
| 347 |
+
---
|
| 348 |
+
|
| 349 |
+
## Quick Links
|
| 350 |
+
|
| 351 |
+
- [GitHub Repository](https://github.com/my-ai-stack/stack-4.0)
|
| 352 |
+
- [HuggingFace Organization](https://huggingface.co/my-ai-stack)
|
| 353 |
+
- [Model Hub](https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic)
|
| 354 |
+
- [Training Dataset](https://huggingface.co/my-ai-stack/Stack-4.0-Dataset)
|
| 355 |
+
- [Documentation](https://docs.stackai.dev)
|
| 356 |
+
- [Discord Community](https://discord.gg/clawd)
|
| 357 |
+
|
| 358 |
+
---
|
| 359 |
|
| 360 |
## Citation
|
| 361 |
|
| 362 |
```bibtex
|
| 363 |
+
@misc{my-ai-stack/stack-4-0-qwen-3b-agentic,
|
| 364 |
+
author = {Walid Sobhi},
|
| 365 |
+
title = {Stack 4.0 Qwen 3B Agentic: Fine-tuned for Tool-Calling and Agentic Workflows},
|
| 366 |
+
year = {2026},
|
| 367 |
+
publisher = {HuggingFace},
|
| 368 |
+
url = {https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic}
|
| 369 |
}
|
| 370 |
```
|
| 371 |
|
| 372 |
+
---
|
| 373 |
|
| 374 |
+
<p align="center">
|
| 375 |
+
Built with love for developers<br/>
|
| 376 |
+
<a href="https://discord.gg/clawd">Discord</a> · <a href="https://github.com/my-ai-stack/stack-4.0">GitHub</a> · <a href="https://huggingface.co/my-ai-stack">HuggingFace</a>
|
| 377 |
+
</p>
|