TypeScript commited on
Commit
d8f70e4
Β·
verified Β·
1 Parent(s): 4beef25

Update Model Card with complete GGUF usage guide, 10-benchmark quantization evaluation, and YAML metadata

Browse files
Files changed (1) hide show
  1. README.md +141 -19
README.md CHANGED
@@ -1,15 +1,21 @@
1
  ---
2
- base_model: Cloudflare/clef-flash
3
- library_name: transformers
4
  license: apache-2.0
 
 
 
5
  pipeline_tag: text-generation
 
 
 
6
  tags:
7
  - fastbrain
8
  - clef
9
  - gguf
 
10
  - systemone
11
  - decision-index
12
  - tool-calling
 
13
  - intent-classification
14
  - structured-decision
15
  ---
@@ -124,42 +130,158 @@ response = clef.systemone(model, processor, {
124
  print(response)
125
  ```
126
 
127
- ### 2. `llama.cpp` GGUF (`Q4_K_M` / `Q8_0` / `BF16`) via `/v1/systemone`
 
 
 
 
 
 
 
 
128
 
129
- This repository includes official `llama.cpp` (`b11430`+ / `ClefModel`) GGUF quantizations that pack both the `Qwen3.5-9B` hybrid backbone and the `116M` `JointSchemaHead` (`dec.*` tensors preserved at `Q8_0` precision):
130
 
131
  ```bash
132
- # Start llama-server on the /v1/systemone decision endpoint (6.73 GB Q4_K_M quant)
133
- llama-server -hf TypeScript/FastBrain-9B:Q4_K_M --port 8080
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
- # Query the single-forward-pass /v1/systemone endpoint
136
  curl http://127.0.0.1:8080/v1/systemone \
137
  -H "Content-Type: application/json" \
138
  -d '{
139
  "model": "FastBrain-9B",
140
- "state": "Customer message: I was charged twice for my order last week and nobody has replied.",
 
 
 
141
  "questions": {
142
  "route": {
143
  "type": "choice",
144
  "instructions": "Which team should handle this?",
145
- "criteria": {"billing": "Payments or invoices", "technical": "Bugs or outages"}
 
 
 
 
146
  },
147
- "urgent": {"type": "noul", "instructions": "Is the customer requesting urgent resolution?"}
 
 
 
148
  }
149
  }'
150
  ```
151
 
152
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
- ## Hardware Footprint, Quantization Tiers & Inference Speed
 
 
 
 
155
 
156
- | Format / Precision Tier | Weight Footprint | Peak VRAM | Minimum Hardware | Typical Latency (`500–1k tok`) |
157
- | :--- | :---: | :---: | :--- | :---: |
158
- | **`FastBrain-9B-Q4_K_M.gguf`** *(4-bit + `Q8_0` Head)* | `6.73 GB` | `~7.6 GB` | **8GB GPU / Colab Free T4 (16GB) / Mac M1–M4** | `~90–220 ms` |
159
- | **PyTorch `load_in_4bit=True`** *(NF4 + `fp16` Head)* | `~5.5 GB` | `~6.2 GB` | **Colab Free T4 (16GB) / RTX 3060–4060 (8GB+)** | `~180–280 ms` |
160
- | **`FastBrain-9B-Q8_0.gguf`** *(Full 8-bit GGUF)* | `9.66 GB` | `~11.0 GB` | **12GB–16GB GPU / Colab T4 / Mac 16GB+** | `~80–180 ms` |
161
- | **PyTorch `load_in_8bit=True`** *(INT8 + `bf16` Head)* | `~9.6 GB` | `~11.2 GB` | **Colab T4 (16GB) / RTX 4070 Ti (12GB+)** | `~130–210 ms` |
162
- | **Native `bfloat16` (`safetensors` / `BF16.gguf`)** | `18.82 GB` (`18.16 GB`) | `20.3–24.7 GB` | **Colab L4 (24GB) / RTX 3090–4090 / PRO 6000 (96GB)** | **`38.8 ms` (`B=1`) Β· `61.7 ms` (`B=16` on G4 6000)** |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
164
  ---
165
 
 
1
  ---
 
 
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
  pipeline_tag: text-generation
7
+ base_model: Cloudflare/clef-flash
8
+ datasets:
9
+ - TypeScript/FastBrain-Instruct
10
  tags:
11
  - fastbrain
12
  - clef
13
  - gguf
14
+ - llama-cpp
15
  - systemone
16
  - decision-index
17
  - tool-calling
18
+ - function-calling
19
  - intent-classification
20
  - structured-decision
21
  ---
 
130
  print(response)
131
  ```
132
 
133
+ ### 2. `llama.cpp` GGUF (`Q8_0` / `Q4_K_M` / `BF16`) via `/v1/systemone`
134
+
135
+ This repository provides official `llama.cpp` (**`b11430`+**, `ClefModel` architecture) GGUF files that bundle both the `Qwen3.5-9B` hybrid backbone and the `116M` `JointSchemaHead` (`dec.*` decision-head tensors, `ssm_` linear-attention states, and `attn_` projections preserved at `Q8_0` precision even in the `Q4_K_M` build).
136
+
137
+ > [!IMPORTANT]
138
+ > **Required `llama.cpp` Version & `ClefModel` Batch Flags:**
139
+ > 1. **Minimum version**: Use **`llama.cpp` release `b11430` or newer** (which includes native `ClefModel` / `LLM_ARCH_CLEF` graph construction and the `/v1/systemone` HTTP endpoint). Standard Ollama or older `llama.cpp` builds without `ClefModel` support cannot execute `dec.*` decision-head tensors.
140
+ > 2. **Set `-b` and `-ub` to match your maximum prompt length (e.g., `-b 16384 -ub 16384 --no-cache-prompt` or `-b 4096 -ub 4096 --no-cache-prompt`)**:
141
+ > In `llama-server`, `ClefModel` computes cross-attention over `<|question_*|>` and `<|option_*|>` spans within a single physical micro-batch (`ubatch`, default `512`). Setting `-ub` equal to `-b` ensures long prompts (>512 tokens) are evaluated in a single physical `ubatch` without splitting option spans across micro-batches, and `--no-cache-prompt` prevents prefix-cache skipping over decision markers.
142
 
143
+ #### Step 1: Download Prebuilt `llama-server` (`b11430`+) and GGUF Weights
144
 
145
  ```bash
146
+ # 1. Download prebuilt llama.cpp (b11430+) with ClefModel & /v1/systemone support
147
+ # - Linux CUDA 13.x (Colab / Ubuntu): llama-b11430-bin-ubuntu-cuda-13.4-x64.tar.gz
148
+ # - Linux CUDA 12.x: llama-b11430-bin-ubuntu-cuda-12.8-x64.tar.gz
149
+ # - macOS Apple Silicon (M1/M2/M3/M4): llama-b11430-bin-macos-arm64.tar.gz
150
+ curl -sL https://github.com/ggml-org/llama.cpp/releases/download/b11430/llama-b11430-bin-ubuntu-cuda-13.4-x64.tar.gz | tar -xz
151
+
152
+ # 2. Download FastBrain-9B GGUF (choose Q8_0 [9.66 GB, lossless] or Q4_K_M [6.73 GB, 8GB–16GB GPUs])
153
+ pip install -U "huggingface_hub[hf_transfer]"
154
+ HF_HUB_ENABLE_HF_TRANSFER=1 hf download TypeScript/FastBrain-9B FastBrain-9B-Q8_0.gguf --local-dir .
155
+ ```
156
+
157
+ #### Step 2: Launch `llama-server` on the `/v1/systemone` Endpoint
158
+
159
+ ```bash
160
+ # On Linux / Google Colab, ensure CUDA driver libraries are in LD_LIBRARY_PATH:
161
+ export LD_LIBRARY_PATH="$(pwd)/llama-b11430:/usr/lib64-nvidia:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
162
+
163
+ # Launch llama-server (24GB+ GPU / 16K context):
164
+ ./llama-b11430/llama-server \
165
+ -m ./FastBrain-9B-Q8_0.gguf \
166
+ -ngl 99 -c 16384 -b 16384 -ub 16384 -np 1 -fa on --no-cache-prompt \
167
+ --port 8080
168
+
169
+ # Or on a 12GB–16GB GPU (e.g., Colab Free Tesla T4, 4K context):
170
+ # ./llama-b11430/llama-server \
171
+ # -m ./FastBrain-9B-Q4_K_M.gguf \
172
+ # -ngl 99 -c 4096 -b 4096 -ub 4096 -np 1 --no-cache-prompt \
173
+ # --port 8080
174
+
175
+ # Optional: For multimodal image/screenshot states, attach the vision projector:
176
+ # --mmproj ./mmproj-FastBrain-9B-Q8_0.gguf
177
+ ```
178
+
179
+ #### Step 3: Query `/v1/systemone` (`curl` or Python β€” Single Forward Pass, `0` Output Tokens)
180
 
181
+ ```bash
182
  curl http://127.0.0.1:8080/v1/systemone \
183
  -H "Content-Type: application/json" \
184
  -d '{
185
  "model": "FastBrain-9B",
186
+ "state": {
187
+ "ticket_id": "ORD-99281",
188
+ "customer_message": "I was charged twice for my subscription last week and nobody has replied to my ticket."
189
+ },
190
  "questions": {
191
  "route": {
192
  "type": "choice",
193
  "instructions": "Which team should handle this?",
194
+ "criteria": {
195
+ "billing": "Payments, refunds, duplicate charges, or invoices",
196
+ "technical": "Bugs, crashes, or service outages",
197
+ "account": "Password reset or login issues"
198
+ }
199
  },
200
+ "urgent": {
201
+ "type": "noul",
202
+ "instructions": "Is the customer reporting a financial or urgent issue?"
203
+ }
204
  }
205
  }'
206
  ```
207
 
208
+ **Python Client Example (`requests` / `urllib`)**:
209
+
210
+ ```python
211
+ import requests
212
+
213
+ resp = requests.post(
214
+ "http://127.0.0.1:8080/v1/systemone",
215
+ json={
216
+ "model": "FastBrain-9B",
217
+ "state": {
218
+ "query": "Can you check the live wire transfer status for my corporate checking account right now?",
219
+ "available_tools": ["get_account_balance", "list_recent_cards"],
220
+ },
221
+ "questions": {
222
+ "action": {
223
+ "type": "choice",
224
+ "instructions": "Select the best assistant response.",
225
+ "criteria": {
226
+ "direct_answer": "Your wire transfer has been completed.",
227
+ "tool_call": "<tool_call>{\"name\": \"get_account_balance\", \"arguments\": {}}</tool_call>",
228
+ "clarify": "Could you please provide your corporate account ID and wire reference number?",
229
+ "abstain": "I cannot check wire transfer status because no wire-transfer tool is available.",
230
+ },
231
+ }
232
+ },
233
+ },
234
+ timeout=30,
235
+ ).json()
236
 
237
+ print(resp["choices"]["action"]) # Calibrated probability distribution over all options
238
+ print(resp["usage"]) # {'input_tokens': ..., 'output_tokens': 0, 'total_tokens': ...}
239
+ ```
240
+
241
+ ---
242
 
243
+ ## GGUF Quantization Accuracy Retention & Speed Benchmarks
244
+
245
+ ### 1. Decision Index 10-Benchmark Test-Set Accuracy Retention (`BF16` vs. `Q8_0` vs. `Q4_K_M`)
246
+
247
+ Evaluated across a stratified 10-benchmark Decision Index test suite (**`203` multi-constraint requests / `1,473` scored schema questions** spanning `choice`, `noul`, and `score` heads), `FastBrain-9B-Q8_0.gguf` (`9.66 GB`) is **virtually lossless (`99.86%` Top-1 decision agreement with native `bfloat16`, `-0.03 pp` score delta)**, while `FastBrain-9B-Q4_K_M.gguf` (`6.73 GB`, with `dec.*` head preserved in `Q8_0`) retains **`98.78%` Top-1 agreement** and **`-0.20 pp`** calibrated 10-task mean:
248
+
249
+ | Benchmark / Metric | Native PyTorch `bfloat16` (`18.82 GB`) | `FastBrain-9B-Q8_0.gguf` (`9.66 GB`) | `FastBrain-9B-Q4_K_M.gguf` (`6.73 GB`, `Q8_0` Head) |
250
+ | :--- | :---: | :---: | :---: |
251
+ | **Top-1 Decision Agreement vs. `bfloat16`** (`1,473` questions) | `100.00%` *(Reference)* | **`99.86%` (`1,471 / 1,473` identical)** | **`98.78%` (`1,455 / 1,473` identical)** |
252
+ | **Probability Mean Absolute Error (`|p_quant - p_bf16|`)** | `0.00000` | **`0.00203` (`0.20%`)** | **`0.00387` (`0.39%`)** |
253
+ | **10-Benchmark Mean (Single-Checkpoint Raw)** | **`82.37%`** | **`82.34%` (`-0.03 pp`)** | **`82.56%` (`+0.19 pp`)** |
254
+ | **10-Benchmark Mean (With Margin Calibration)** | **`83.68%`** | **`83.65%` (`-0.03 pp`)** | **`83.48%` (`-0.20 pp`)** |
255
+ | β”œβ”€ **1. BFCL** *(AST Tool Selection)* | `100.00%` | **`100.00%`** (`0.00`) | **`100.00%`** (`0.00`) |
256
+ | β”œβ”€ **2. ToolRet** *(20-Candidate Tool Reranking, `score`)* | `73.15%` | **`73.70%`** (`+0.55`) | **`75.60%`** (`+2.45`) |
257
+ | β”œβ”€ **3. API-Bank** *(Multi-Step Stateful Tool Calling)* | `95.00%` | **`95.00%`** (`0.00`) | **`95.00%`** (`0.00`) |
258
+ | β”œβ”€ **4. BANKING77** *(77-Way Fine-Grained Intent)* | `100.00%` | **`100.00%`** (`0.00`) | **`100.00%`** (`0.00`) |
259
+ | β”œβ”€ **5. CLINC150+OOS** *(Intent + Open-Set `noul` Abstention)* | `93.94%` | **`93.94%`** (`0.00`) | **`93.94%`** (`0.00`) |
260
+ | β”œβ”€ **6. Home Appliances** *(Embedded Device Control)* | `90.00%` | **`90.00%`** (`0.00`) | **`90.00%`** (`0.00`) |
261
+ | β”œβ”€ **7. BRIGHT** *(Reasoning-Intensive Document Ranking)* | `41.93%` | **`41.00%`** (`-0.93`) | **`40.31%`** (`-1.62`) |
262
+ | β”œβ”€ **8. Amazon ESCI** *(Fine-Grained E-Commerce Relevance)* | `73.89%` | **`73.89%`** (`0.00`) | **`75.79%`** (`+1.90`) |
263
+ | β”œβ”€ **9. PhishNChips** *(9-Probe Joint Security Inspection)* | `85.00%` | **`85.00%`** (`0.00`) | **`85.00%`** (`0.00`) |
264
+ | └─ **10. When2Call** *(4-Way Tool Governance)* | `75.00%` *(Raw `70.83%`)* | **`75.00%`** *(Raw `70.83%`, `0.00`)* | **`72.92%`** *(Raw `70.83%`, `-2.08`)* |
265
+
266
+ ### 2. Measured Hardware Footprint & Inference Speed (`llama-server b11430` CUDA 13.4)
267
+
268
+ Because `FastBrain-9B` scores all schema questions and candidate options in a **single non-autoregressive prefill forward pass (`output_tokens = 0`)**, `llama-server` achieves **8,900–12,100+ input tokens/sec** (`31–109 ms` end-to-end HTTP latency) on server GPUs:
269
+
270
+ | Workload / Metric | `FastBrain-9B-Q8_0.gguf`<br>*(9.66 GB Β· RTX PRO 6000)* | `FastBrain-9B-Q4_K_M.gguf`<br>*(6.73 GB Β· RTX PRO 6000)* | Native PyTorch `bfloat16`<br>*(18.82 GB Β· RTX PRO 6000)* |
271
+ | :--- | :---: | :---: | :---: |
272
+ | **Model Load Time** | **`2.56 s`** | **`2.00 s`** | `~11.5 s` |
273
+ | **Peak GPU VRAM** *(incl. `16K` context & batch buffers)* | **`12.55 GiB` (`12,847 MiB`)** | **`10.30 GiB` (`10,545 MiB`)** | `20.3 – 24.7 GiB` |
274
+ | **Workload 1: Intent Routing + OOS** (`293 tok`, `K=2` questions) | **`32.82 ms`** (`8,928 tok/s` Β· `60.9 dec/s`) | **`31.69 ms`** (`9,245 tok/s` Β· `63.1 dec/s`) | `~35.0 ms` |
275
+ | **Workload 2: Tool Governance (`When2Call`)** (`1,068 tok`, `K=1`, `M=4`) | **`87.78 ms`** (`12,167 tok/s`) | **`89.34 ms`** (`11,955 tok/s`) | `~92.0 ms` |
276
+ | **Workload 3: Security Multi-Probe (`PhishNChips`)** (`1,303 tok`, `K=9` questions) | **`108.55 ms`** (`12,004 tok/s` Β· `82.9 dec/s`) | **`109.97 ms`** (`11,849 tok/s` Β· `81.8 dec/s`) | `~115.0 ms` |
277
+
278
+ | Format / Precision Tier | Weight Footprint | Peak VRAM (`4K`–`16K` ctx) | Minimum Recommended Hardware |
279
+ | :--- | :---: | :---: | :--- |
280
+ | **`FastBrain-9B-Q4_K_M.gguf`** *(4-bit + `Q8_0` Head)* | `6.73 GB` | `~7.8 – 10.3 GiB` | **8GB–12GB GPU / Colab Free T4 (16GB) / Mac M1–M4** |
281
+ | **PyTorch `load_in_4bit=True`** *(NF4 + `fp16` Head)* | `~5.5 GB` | `~6.2 – 6.8 GiB` | **Colab Free T4 (16GB) / RTX 3060–4060 (8GB+)** |
282
+ | **`FastBrain-9B-Q8_0.gguf`** *(Full 8-bit GGUF)* | `9.66 GB` | `~10.8 – 12.6 GiB` | **12GB–16GB GPU / Colab T4 / Mac 16GB+** |
283
+ | **PyTorch `load_in_8bit=True`** *(INT8 + `bf16` Head)* | `~9.6 GB` | `~11.2 GiB` | **Colab T4 (16GB) / RTX 4070 Ti (12GB+)** |
284
+ | **Native `bfloat16` (`safetensors` / `BF16.gguf`)** | `18.82 GB` (`18.16 GB`) | `20.3 – 24.7 GiB` | **Colab L4 (24GB) / RTX 3090–4090 / PRO 6000 (96GB)** |
285
 
286
  ---
287