ssaraf1/slm-workflow-planner-7b-v2
SLM Workflow Planner 7B v2 — Contrastive Alignment LoRA Adapter
Model Description
LoRA adapter for Qwen/Qwen2.5-7B-Instruct fine-tuned as a workflow execution planner. This is the v2 alignment model — trained in two stages:
- Stage A: Base policy training on 554K samples from 89 diverse workflow graphs (iter 800)
- Stage B: Contrastive alignment on 20K curated samples with clean decision boundaries (iter 100)
The model makes real-time decisions about workflow transitions by analyzing state signals, eligible nodes, and topology information.
Decision Types
Performance (76-scenario evaluation suite)
Key Results
- 🏆 Outperforms GPT-4.1 (55.3% vs 53.9%) on structured workflow planning
- 🏆 Only model that handles META — GPT-4.1 and GPT-4o-mini score 0% on anomaly detection
- 🔥 FORK: 93% — near-perfect parallel execution decisions
- 🔥 JOIN: 67% — first model to reliably synchronize parallel branches
- ⚡ 4x faster inference than base model, runs locally on Apple Silicon
Training Details
Two-Stage Training
Stage A: Base Policy (iter 800)
- Dataset: 554K instruction pairs from 89 workflow graphs
- 8 structural families (linear, retry, fork-join, escalation, etc.)
- Balanced decision distribution: NEXT 36%, JOIN 27%, META 13%, FORK 12%, RETRY 12%
Stage B: Contrastive Alignment (iter 100)
- Dataset: 20K curated samples with clean decision boundaries
- Contrastive pairs: FORK positives + hard FORK negatives (NEXT with forkable but blocked)
- JOIN positives + hard JOIN negatives (NEXT with join_ready but no parallel)
- Clean RETRY and META samples
- Proportional representation across all decision types
LoRA Configuration
Training Configuration
Training Curve (Alignment Stage)
Usage
With MLX (Apple Silicon)
from mlx_lm import load, generate
from mlx_lm.sample_utils import make_sampler
model, tokenizer = load(
"Qwen/Qwen2.5-7B-Instruct",
adapter_path="ssaraf1/slm-workflow-planner-7b-v2"
)
messages = [
{"role": "system", "content": "You are a workflow planner. Given the current workflow state, eligible nodes, and topology information, classify the decision type. Respond with exactly one of: NEXT, RETRY, FORK, JOIN, META"},
{"role": "user", "content": "Current node: TRIAGE_AND_ASSIGN (AGENT)\nOutcome: assigned\n\nState:\n goal_progress=0.15\n parallel_active=0\n resource_pressure=0.1\n\nEligible nodes:\n 1. VERIFY_POLICY (SYSTEM) → produces: policy_status\n 2. FRAUD_SCREENING (SYSTEM) → produces: fraud_score\n 3. DAMAGE_ASSESSMENT (AGENT) → produces: damage_report\n\nForkable sets: [{VERIFY_POLICY, FRAUD_SCREENING, DAMAGE_ASSESSMENT}]\nJoin-ready: []\n\nWhat decision type?"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
sampler = make_sampler(temp=0.0)
response = generate(model, tokenizer, prompt=prompt, max_tokens=10, sampler=sampler)
print(response) # Expected: FORKWhat Makes This Model Special
Contrastive Alignment
Unlike naive fine-tuning, this model was trained with contrastive pairs that teach policy boundaries, not just pattern matching:
Policy Learning, Not Path Memorization
The model learns decision = f(state signals, topology, actors), not domain-specific workflow paths. This enables generalization to unseen workflow structures.
Files
adapters.safetensors— LoRA adapter weights (base iter 800 + alignment iter 100)adapter_config.json— LoRA configuration for MLX
Citation
Part of the Agentic Factory project — building autonomous workflow orchestration with SLM-powered planning on Apple Silicon.
