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.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model and tokenizer
5model_name = "my-ai-stack/Stack-4.0-Qwen-3B-Agentic"
6
7tokenizer = AutoTokenizer.from_pretrained(
8 model_name,
9 trust_remote_code=True
10)
11
12model = AutoModelForCausalLM.from_pretrained(
13 model_name,
14 torch_dtype=torch.float16,
15 device_map="auto",
16 trust_remote_code=True
17)
18
19# Example tool call format
20tool_schema = [
21 {
22 "type": "function",
23 "function": {
24 "name": "search_code",
25 "description": "Search for code patterns in the repository",
26 "parameters": {
27 "type": "object",
28 "properties": {
29 "pattern": {"type": "string", "description": "Regex pattern to search"},
30 "path": {"type": "string", "description": "Directory path to search"}
31 },
32 "required": ["pattern"]
33 }
34 }
35 }
36]
37
38# Generate with tool calling
39prompt = """Search for all functions containing 'async' in the src directory."""
40
41messages = [
42 {"role": "system", "content": "You are Stack 4.0, an agentic AI assistant with tool-calling capabilities."},
43 {"role": "user", "content": prompt}
44]
45
46text = tokenizer.apply_chat_template(
47 messages,
48 tokenize=False,
49 add_generation_prompt=True
50)
51
52inputs = tokenizer([text], return_tensors="pt").to(model.device)
53
54with torch.no_grad():
55 outputs = model.generate(
56 **inputs,
57 max_new_tokens=512,
58 temperature=0.2,
59 top_p=0.95,
60 do_sample=True,
61 )
62
63response = tokenizer.decode(
64 outputs[0][inputs.input_ids.shape[1]:],
65 skip_special_tokens=True
66)
67
68print(response)
1# Download the GGUF model file
2# Visit: https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic/tree/main
3
4# Run with llama.cpp
5./main -m stack-4.0-qwen-3b-agentic-q4_k_m.gguf \
6 -n 512 \
7 -t 8 \
8 -c 131072 \
9 --temp 0.2 \
10 --top-p 0.95 \
11 -p "Write a Python function that searches for code patterns using regex."
12
13# Or use with tool schema (JSON mode)
14./main -m stack-4.0-qwen-3b-agentic-q4_k_m.gguf \
15 --json-schema '{
16 "type": "object",
17 "properties": {
18 "search": {
19 "type": "object",
20 "properties": {
21 "pattern": {"type": "string"},
22 "path": {"type": "string"}
23 }
24 }
25 }
26 }'
1# Pull the model
2ollama pull stack-4.0-qwen-3b-agentic
3
4# Run interactively with agentic mode
5ollama run stack-4.0-qwen-3b-agentic "Search for all async functions in the src directory."
6
7# Or use with custom parameters for agentic workflows
8ollama run stack-4.0-qwen-3b-agentic \
9 --temperature 0.1 \
10 --top-p 0.9 \
11 --num-ctx 131072 \
12 --num-gpu 1 \
13 "Create a Python script that implements a multi-step data pipeline with error handling."
14
15# Use with Ollama's function calling (if available in your version)
16ollama function call stack-4.0-qwen-3b-agentic \
17 --function search_code \
18 --args '{"pattern": "def.*", "path": "./src"}'
Stack 4.0 Qwen 3B Agentic is specifically trained for autonomous agent workflows:
1# Optimal settings for inference
2config = {
3 "batch_size": 1,
4 "use_kv_cache": True,
5 "max_new_tokens": 512,
6 "torch_dtype": torch.float16, # Use float16 on GPU
7 # For CPU inference:
8 # "torch_dtype": torch.float32,
9 # "device_map": "cpu",
10}
1@misc{my-ai-stack/stack-4-0-qwen-3b-agentic,
2 author = {Walid Sobhi},
3 title = {Stack 4.0 Qwen 3B Agentic: Fine-tuned for Tool-Calling and Agentic Workflows},
4 year = {2026},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/my-ai-stack/Stack-4.0-Qwen-3B-Agentic}
7}
Built with love for developers
Discord ·
GitHub ·
HuggingFace