Downloads · 30 days
53
22% of all-time downloads
chendren/Qwen3-8B-LAM-v4
Qwen3-8B-LAM-v4 is a text generation model from chendren. Use it when you need the model to write or continue text. It is set up for mlx. The card lists the license as apache-2.0.
Eval size: every headline percentage on this card is 10 held-out prompts. Instruction repetition takes the fine-tune from 9/10 to 10/10. The base model stays 6/10 with or without repetition. benchmarkresults.json is i…
Downloads · 30 days
53
22% of all-time downloads
All-time downloads
242
Public
Parameters
8.2B
8.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors8.7 GB · 100%
How the weights are stored.
U328.2B · 100%
From the Hugging Face model README
Eval size: every headline percentage on this card is 10 held-out prompts. Instruction repetition takes the fine-tune from 9/10 to 10/10. The base model stays 6/10 with or without repetition.
benchmark_results.jsonis in the repo.
A fine-tuned Qwen3-8B model that creates, builds, and deploys AI agents from natural language requests. Unlike function-calling models that invoke existing tools, this LAM designs and constructs new agents — complete with tool definitions, multi-step skills, behavioral constraints, and installable agent files.
100% pass rate on agent generation benchmarks using the instruction repetition technique. Every generated agent is valid, installable, and immediately functional.
| Metric | LAM v4 (fine-tuned) | Qwen3-8B (base) | Improvement |
|---|---|---|---|
| Plan Mode Avg Score | 96.0/100 | 95.5/100 | +0.5% |
| Plan Mode Min Score | 95 | 85 | +11.8% |
| Valid JSON Rate | 100% | 100% | — |
| Agent Generation Pass Rate | 90% | 60% | +50% |
| With Instruction Repetition | 100% | 60% | +67% |
| Agent File Quality (passing) | 100/100 | 100/100 | — |
| Avg Inference Latency | 20.5s | 27.7s | -26% |
Critical finding: Instruction repetition only benefits the fine-tuned model (+10% pass rate). The base model remains at 60% with or without repetition — it fails on the same prompts because it never learned the agent output schema. The fine-tuning is what enables the technique to work.
All four conditions tested on the same 10 held-out prompts:
| Standard Prompt | + Instruction Repetition | |
|---|---|---|
| Qwen3-8B Base | 60% (6/10) | 60% (6/10) |
| Qwen3-8B-LAM-v4 (fine-tuned) | 90% (9/10) | 100% (10/10) |
Standard Repeated
Prompt Instruction
Base Qwen3-8B ██████░░░░ ██████░░░░ 60% → 60% (no improvement)
Fine-Tuned v4 █████████░ ██████████ 90% → 100% (+11% improvement)
▲
│
Fine-tuning + repetition = 100%
What this proves:
An LLM tells you how to do something. A LAM does it.
This model extends language generation to agent creation — it takes a natural language request like "Build an agent that reviews PRs for SQL injection" and outputs:
We achieve 100% pass rate (up from 90%) using instruction repetition — a technique where the user request is repeated in the prompt:
{{request}}
Let me repeat your instruction: {{request}}
This technique is based on research showing instruction repetition raises LLM accuracy from ~21% to ~97% by reinforcing task adherence. Our results confirm this finding in the agent generation domain.
Fine-tuned model:
| Metric | Standard Prompt | Repeated Instruction | Delta |
|---|---|---|---|
| Pass Rate | 90% | 100% | +11% |
| Avg Score | 85.0/100 | 100.0/100 | +17.6% |
| Min Score | 0 (failures) | 100 | Eliminated all failures |
| Avg Latency | 25.5s | 20.5s | -20% faster |
Every single prompt scored 100/100 — valid YAML frontmatter, correct tool names, meaningful system prompt body, process steps, and behavioral constraints. Zero degenerate outputs.
Base model (no fine-tuning) with same technique:
| Metric | Standard Prompt | Repeated Instruction | Delta |
|---|---|---|---|
| Pass Rate | 60% | 60% | No change |
| Avg Score | 60.0/100 | 60.0/100 | No change |
The base model fails on 4/10 prompts regardless of instruction repetition. The technique only amplifies capabilities the model already has — fine-tuning teaches the agent schema, repetition reinforces adherence to it.
| # | Prompt | Fine-Tuned | Base |
|---|---|---|---|
| 1 | TypeScript logging cleanup | 100 | 100 |
| 2 | Python security reviewer | 100 | 100 |
| 3 | Docker memory monitor | 100 | 100 |
| 4 | README sync agent | 100 | 0 |
| 5 | Markdown formatter | 100 | 0 |
| 6 | Package.json checker | 100 | 100 |
| 7 | CloudFormation validator | 100 | 0 |
| 8 | Git branch cleanup | 100 | 100 |
| 9 | Changelog generator | 100 | 100 |
| 10 | Log error monitor | 100 | 0 |
pip install mlx-lm
# Generate an agent definition
mlx_lm.generate \
--model chendren/Qwen3-8B-LAM-v4 \
--max-tokens 4096 \
--prompt "You are a Large Action Model that creates AI agents and skills from user requests.
When given a request, you:
1. Reason about what agent architecture best serves the need
2. Define the tools the agent requires
3. Define skills as composable, multi-step workflows
4. Set constraints to keep the agent safe and focused
Respond with a JSON object containing:
- reasoning: your thought process for the design
- agent: the complete agent definition with name, description, role, tools, skills, and constraints
User request: Build an agent that reviews PRs for SQL injection vulnerabilities
Let me repeat your instruction: Build an agent that reviews PRs for SQL injection vulnerabilities"
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("chendren/Qwen3-8B-LAM-v4")
tokenizer = AutoTokenizer.from_pretrained("chendren/Qwen3-8B-LAM-v4")
request = "Build an agent that monitors Docker containers for high memory usage"
prompt = f"""You are a Large Action Model that creates AI agents and skills from user requests.
When given a request, you:
1. Reason about what agent architecture best serves the need
2. Define the tools the agent requires
3. Define skills as composable, multi-step workflows
4. Set constraints to keep the agent safe and focused
Respond with a JSON object containing:
- reasoning: your thought process for the design
- agent: the complete agent definition with name, description, role, tools, skills, and constraints
User request: {request}
Let me repeat your instruction: {request}"""
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=4096)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
The model outputs structured JSON:
{
"reasoning": "The user needs a Docker monitoring agent with alerting. This requires Bash for running docker stats, Read for checking thresholds, and Write for logging alerts...",
"agent": {
"name": "docker-memory-monitor",
"description": "Monitors Docker container memory usage and alerts on threshold breaches",
"role": "infrastructure monitor",
"tools": [
{
"name": "check_container_stats",
"description": "Runs docker stats to collect memory usage metrics",
"parameters": [
{ "name": "container_id", "type": "string", "description": "Container to monitor", "required": true }
],
"returns": "Memory usage percentage and absolute values"
}
],
"skills": [
{
"name": "memory-check",
"description": "Checks all running containers against memory thresholds",
"trigger": "On schedule or manual invocation",
"inputs": [{ "name": "threshold_pct", "type": "number", "description": "Alert threshold", "required": true }],
"steps": [
{ "action": "List all running containers", "tool": "check_container_stats" },
{ "action": "Compare against threshold", "on_failure": "log and continue" },
{ "action": "Send alert for breaches", "tool": "send_alert" }
],
"output": "List of containers exceeding threshold with current usage"
}
],
"constraints": [
"Never kill or restart containers without explicit user approval",
"Alert thresholds must be configurable, default 80%",
"Log all alerts to persistent storage"
]
}
}
3,104 examples from three sources, all open-source (zero API cost):
| Source | Examples | Description |
|---|---|---|
| Synthetic agent definitions | 1,261 | Plan-mode examples generated via Anthropic Batch API (prior work) |
| Open-source agent/skill files | 800 | Harvested from GitHub: VoltAgent/awesome-claude-code-subagents, anthropics/skills, alirezarezvani/claude-skills, and jeremylongshore/claude-code-plugins-plus-skills |
| Tool-calling trajectories | 800 | Salesforce/APIGen-MT-5k and Team-ACE/ToolACE |
| Anti-forgetting mix | 250 | General conversation (Alpaca-Cleaned) to prevent catastrophic forgetting |
| Parameter | Value |
|---|---|
| Base model | Qwen/Qwen3-8B (8-bit quantized) |
| Method | QLoRA (rank 8, scale 20.0) |
| Framework | MLX 0.31.0 (Apple Metal) |
| Hardware | Apple M4 Max, 128GB unified memory |
| Trainable parameters | 9.7M / 8.2B (0.118%) |
| Iterations | 800 |
| Batch size | 1 |
| Learning rate | 1e-5 |
| Max sequence length | 8,192 |
| Best validation loss | 0.419 |
| Training time | ~90 minutes |
| Peak memory | 26.1 GB |
| Iteration | Validation Loss | Notes |
|---|---|---|
| 1 | 1.215 | Baseline |
| 150 | 0.545 | -55% |
| 300 | 0.508 | |
| 450 | 0.432 | |
| 700 | 0.419 | Best checkpoint |
| 800 | 0.426 | Final |
The harvested open-source data underwent quality filtering:
allowed-tools: → tools: (Claude Code standard format)|---|) that caused degenerate repetition loops during generationScores based on:
Agent file scored on:
All test prompts are held-out — none appear in the training data:
Plan Mode: S3 monitoring, Slack standup bot, PR SQL injection review, K8s pod health, API docs generation, Docker CVE scanning, AWS cost optimization, unit test generation, GDPR compliance, API latency monitoring
Execution Mode: TypeScript logging cleanup, Python security review, Docker memory monitoring, README sync, markdown formatting, dependency checking, CloudFormation validation, git branch cleanup, changelog generation, log error monitoring
| Version | Val Loss | Plan Avg | Exec Pass Rate | Dataset | Key Change |
|---|---|---|---|---|---|
| v1 | 0.559 | 92.5 | N/A | 992 | Initial plan-mode training |
| v2 | 0.500 | 98.5 | N/A | 1,580 | Added targeted weak-category examples |
| v3 | 0.443 | 96.0 | 80% | 3,085 | Added execution mode + open-source data |
| v4 | 0.419 | 96.0 | 90% (100% w/ repetition) | 3,104 | Cleaned data, eliminated degenerate patterns |
.md files.@misc{hendren2026lam,
title={Qwen3-8B-LAM: Fine-Tuning Large Action Models for AI Agent Creation on Apple Silicon},
author={Hendren, Chad},
year={2026},
url={https://huggingface.co/chendren/Qwen3-8B-LAM-v4}
}