File size: 9,768 Bytes
edc6db4
 
 
 
 
 
 
5f02adc
 
edc6db4
 
 
 
 
 
3eb99a8
edc6db4
5f02adc
edc6db4
 
 
 
5f02adc
 
 
edc6db4
 
 
3eb99a8
 
 
 
5f02adc
3eb99a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f02adc
 
 
 
 
 
 
 
 
 
 
 
 
edc6db4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f02adc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
edc6db4
 
 
1ce1569
3eb99a8
1ce1569
3eb99a8
edc6db4
 
 
 
 
 
 
3eb99a8
5f02adc
edc6db4
 
 
 
 
5f02adc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
edc6db4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f02adc
 
 
 
 
 
edc6db4
 
 
 
 
 
 
 
 
 
 
 
3eb99a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
edc6db4
 
5f02adc
 
 
 
 
edc6db4
5f02adc
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
---
base_model: Qwen/Qwen3-Coder-Next
library_name: mlx
pipeline_tag: text-generation
license: apache-2.0
tags:
  - mlx
  - gguf
  - quantized
  - lora
  - qwen3-next
  - orchestrator
  - agent
---

# bankai-v1

`bankai-v1` is a one-step agent orchestration model based on
[`Qwen/Qwen3-Coder-Next`](https://huggingface.co/Qwen/Qwen3-Coder-Next), trained
to perform one-step agent orchestration. Given a task, it selects one specialist
worker and emits a complete delegated instruction as strict JSON.

This repository includes the original MLX LoRA, a llama.cpp GGUF LoRA, a fully
fused 4-bit MLX model, and a fully fused Q4_K_M GGUF model. The adapter was
trained against
[`mlx-community/Qwen3-Coder-Next-4bit`](https://huggingface.co/mlx-community/Qwen3-Coder-Next-4bit).
The upstream model is an 80B MoE with approximately 3B active parameters.

## Model Details

| Property | Value |
|---|---|
| Model type | One-step agent orchestration model and adapters |
| Upstream architecture | Qwen3-Next hybrid Gated DeltaNet / attention MoE |
| Total base parameters | 79,674,391,296 (79.674B) |
| Active parameters per token | Approximately 3B |
| LoRA trainable parameters | 2,857,000 (2.857M) |
| Trainable share | Approximately 0.004% of base parameters |
| Base precision used for training | MLX 4-bit quantization |
| Adapter precision | Safetensors LoRA weights |
| Native base context | 262,144 tokens |
| Fine-tuning sequence length | 2,048 tokens |
| Languages | Primarily English; base model is multilingual |
| License | Apache-2.0 |
| Framework | MLX LM 0.31.3 |

Qwen3-Coder-Next has 48 layers, 512 routed experts, ten activated routed
experts per token, and one shared expert. `bankai-v1` adapts only attention and
gated-delta projections in the final 16 layers; it does not add LoRA matrices
to the routed experts.

## Repository Contents

| Path | Type | Size | Standalone |
|---|---|---:|---|
| `adapters.safetensors` | Original MLX LoRA | 11,439,496 bytes | No |
| `adapter_config.json` | MLX LoRA configuration | 1.3 KB | No |
| `gguf/bankai-v1-f16.gguf` | llama.cpp F16 LoRA | 6,116,192 bytes | No |
| `gguf/bankai-v1-Q4_K_M.gguf` | Fused Q4_K_M GGUF | 48,528,320,544 bytes | Yes |
| `mlx/` | Fused 4-bit MLX model, nine shards | Approximately 44.9 GB | Yes |
| `bankai-system.txt` | Exact training-time system prompt | 1 KB | N/A |
| `training_config.yaml` | Reproducible training configuration | 746 bytes | N/A |
| `evaluation.json` | Per-example behavioral evaluation | 30 KB | N/A |

## Output Contract

```json
{
  "action": "call_agent",
  "agent": "software_engineer",
  "model": "auto",
  "instruction": "A complete execution-ready instruction for the worker",
  "context_refs": ["user_request"],
  "expected_output": "completed_task_with_evidence",
  "budget": {"max_tokens": 4096}
}
```

Supported worker labels:

- `software_engineer`
- `technical_writer`
- `marketing_strategist`
- `marketing_copywriter`
- `sales_specialist`
- `customer_support_specialist`
- `data_analyst`
- `product_designer`
- `financial_analyst`
- `compliance_specialist`

## Usage

Download the exact system prompt:

```bash
hf download ApplauseLab/bankai-v1 bankai-system.txt --local-dir bankai-v1
```

### Fused MLX Model

The fused MLX model does not require an adapter:

```bash
hf download ApplauseLab/bankai-v1 \
  --include "mlx/*" \
  --local-dir bankai-v1

mlx_lm.generate \
  --model bankai-v1/mlx \
  --system-prompt "$(cat bankai-v1/bankai-system.txt)" \
  --prompt "Design a GDPR-compliant CRM integration for a real-estate business." \
  --max-tokens 1024 \
  --temp 0
```

### MLX Adapter

Install MLX LM on Apple Silicon:

```bash
pip install "mlx-lm>=0.31.3" "huggingface-hub>=1.17"
hf download ApplauseLab/bankai-v1 \
  --include "adapter*" \
  --local-dir bankai-v1-adapter
```

Generate with the adapter:

```bash
mlx_lm.generate \
  --model mlx-community/Qwen3-Coder-Next-4bit \
  --adapter-path bankai-v1-adapter \
  --system-prompt "$(cat bankai-system.txt)" \
  --prompt "Design and test a GDPR-compliant CRM integration for a real-estate business." \
  --max-tokens 1024 \
  --temp 0
```

For best consistency, use the included `bankai-system.txt`.

### Fused GGUF / llama.cpp

The fused GGUF is standalone and does not require `--lora`:

```bash
hf download ApplauseLab/bankai-v1 \
  gguf/bankai-v1-Q4_K_M.gguf \
  --local-dir bankai-v1

llama-cli \
  --model bankai-v1/gguf/bankai-v1-Q4_K_M.gguf \
  --system-prompt-file bankai-v1/bankai-system.txt \
  --prompt "Design a GDPR-compliant CRM integration for a real-estate business." \
  --temp 0 \
  --n-predict 1024 \
  --single-turn
```

### GGUF Adapter

`bankai-v1-f16.gguf` is the same LoRA adapter converted for llama.cpp. It is
not a standalone 80B model; load it alongside a compatible
Qwen3-Coder-Next GGUF base:

```bash
llama-cli \
  --model Qwen3-Coder-Next-Q4_K_M.gguf \
  --lora bankai-v1/gguf/bankai-v1-f16.gguf \
  --system-prompt-file bankai-v1/bankai-system.txt \
  --prompt "Design a GDPR-compliant CRM integration for a real-estate business." \
  --temp 0 \
  --n-predict 1024
```

The GGUF adapter was converted through PEFT tensor orientation with
`lora_alpha=128`, preserving the MLX effective scale of 16 at rank 8.

Use the included `bankai-system.txt` for the exact worker vocabulary and JSON
contract seen during fine-tuning. Shorter prompts may produce valid routing in
a different schema.

## Fusion Details

The fused MLX model was produced by merging the LoRA into
`mlx-community/Qwen3-Coder-Next-4bit` and saving the resulting quantized MLX
weights.

The standalone GGUF starts from the single-file Unsloth Q4_K_M conversion of
Qwen3-Coder-Next. Untouched tensors are copied bit-for-bit. The 64 targeted
attention and gated-delta matrices in layers 32-47 are dequantized to F32, the
LoRA delta is applied at effective scale 16, and each matrix is requantized to
its original Q4_K_M mixture type. The resulting GGUF contains 843 tensors.

## Training

- Training base: `mlx-community/Qwen3-Coder-Next-4bit`
- Upstream base: `Qwen/Qwen3-Coder-Next`
- Method: MLX QLoRA
- Trainable parameters: 2.857M, approximately 0.004%
- Adapted blocks: final 16 of 48
- Adapted modules: full-attention Q/K/V/O projections and gated-delta input/output projections
- LoRA rank: 8
- LoRA scale: 16
- Optimizer: AdamW
- Learning rate: `1e-5`
- Updates: 612
- Gradient accumulation: 2
- Maximum sequence length: 2048
- Training tokens: 355,178
- Peak training memory: 74.4 GB on an Apple M4 Max

The source consisted of 1,080 synthetic task-to-delegated-prompt examples
across ten task categories and twenty industries. Grouped splitting held out
complete industries and complete `(category, subtask)` groups:

- Train: 612
- Validation: 224
- Test: 244

Only assistant tokens contributed to the loss.

## Evaluation

- Final sampled validation loss: 1.606
- Held-out test loss over 32 batches: 1.795
- Held-out test perplexity: 6.018
- Behavioral evaluation: one held-out example from each of ten categories
- Strict JSON validity: 10/10
- Runtime schema validity: 10/10
- Worker-routing accuracy: 10/10
- Complete contract: 10/10

The behavioral sample is small and measures formatting and category routing,
not end-to-end quality of worker execution.

Both fused formats received inference smoke tests with the full system prompt.
The fused MLX output matched the JSON contract. The fused GGUF output also
matched the contract, selected `compliance_specialist` for a held-out
real-estate GDPR/CRM/accounting request, and generated at approximately 64
tokens/second on an Apple M4 Max using Metal offload.

## Limitations

This first version learns only single-step worker selection and prompt
delegation. It does not execute workers, consume observations, choose among
specific model providers, verify results, retry failures, call agents in
parallel, optimize cost, or perform reinforcement-learned multi-turn
orchestration.

Training examples are synthetic and stylistically concentrated. Outputs may be
overly verbose and domain-specific legal, financial, medical, or compliance
instructions require qualified human review.

## Intended Use

Use `bankai-v1` as a routing and prompt-delegation component in an agent runtime
that validates its JSON, resolves the selected worker, enforces budgets, and
records real worker observations. Suitable initial domains include software
delivery, documentation, marketing, customer support, analysis, product
design, finance, and compliance workflows.

Do not treat generated delegated instructions as professional legal,
regulatory, medical, accounting, or investment advice. The adapter should not
be given authority to execute high-impact actions without runtime controls and
human review.

## Training Data Notes

The source is a synthetic Cartesian task grid rather than organic production
traces. Inputs combine 54 task types with 20 industries. Responses are
execution-ready delegated prompts averaging roughly 345 words. A grouped split
was used instead of a random split to reduce leakage from repeated industry and
subtask templates. No private user conversations were used.

The source artifact has a documented lineage discrepancy: records
`task-0881` through `task-0900` differ from their current shard copies. Training
used the checksummed final `training_set.jsonl` artifact.

## Integrity

| File | SHA-256 |
|---|---|
| `adapters.safetensors` | `66df3ea1d9a9f0b1c3e07b1620a33dfb0b3bf36b6ea4b1e52fe2fc1bd8da67d9` |
| `gguf/bankai-v1-f16.gguf` | `184b7855166c6c97fe366b4412de51cf98474dfc5df7caa95bda09f83c80e84d` |
| `gguf/bankai-v1-Q4_K_M.gguf` | `75f8200b83756e6f32565b4579c9bb07aa6aa591fca380bc3f85af1138102296` |

The fused GGUF also passed llama.cpp per-tensor hashing with whole-file XXH64
`c64819733a364e4d`.