Text Generation
NInfer
qwen.83
qwen3_8
blackwell
sm120a
mtp
speculative-decoding
indexed88
vocabulary-prune
coding
agentic
nvfp4
conversational
Instructions to use Schestex/ThinkingCap-Qwen3.8-27B-NInfer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- NInfer
How to use Schestex/ThinkingCap-Qwen3.8-27B-NInfer with NInfer:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Publish Indexed88 v6.4 135K R2
Browse files- .gitattributes +1 -0
- README.md +104 -244
- indexed88-v6.4-135k-r2/RELEASE.json +26 -0
- indexed88-v6.4-135k-r2/SHA256SUMS +3 -0
- indexed88-v6.4-135k-r2/qwen3_8_sharp.jinja +488 -0
- indexed88-v6.4-135k-r2/selected_88064_135k_v64_40_R2.i32le +3 -0
- indexed88-v6.4-135k-r2/thinkingcap-135000-q8-repack.ninfer +3 -0
.gitattributes
CHANGED
|
@@ -2,3 +2,4 @@
|
|
| 2 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.gguf filter=lfs diff=lfs merge=lfs -text
|
| 4 |
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 2 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.gguf filter=lfs diff=lfs merge=lfs -text
|
| 4 |
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
indexed88-v6.4-135k-r2/selected_88064_135k_v64_40_R2.i32le filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,290 +1,150 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
base_model: bottlecapai/ThinkingCap-Qwen3.8-27B
|
| 3 |
base_model_relation: quantized
|
| 4 |
library_name: ninfer
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
-
license: other
|
| 7 |
-
license_name: polyform-small-business-1.0.0
|
| 8 |
-
license_link: LICENSE
|
| 9 |
tags:
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
- blackwell
|
| 14 |
-
-
|
| 15 |
-
-
|
| 16 |
-
-
|
| 17 |
-
-
|
|
|
|
|
|
|
| 18 |
---
|
| 19 |
|
| 20 |
-
# ThinkingCap
|
| 21 |
-
|
| 22 |
-
Production-oriented NInfer export of
|
| 23 |
-
`bottlecapai/ThinkingCap-Qwen3.8-27B`, tuned and validated for NVIDIA Blackwell.
|
| 24 |
-
|
| 25 |
-
**V1 status:** frozen and production validated.
|
| 26 |
-
|
| 27 |
-
The final artifact combines:
|
| 28 |
-
|
| 29 |
-
- compact **147,590-token public vocabulary**
|
| 30 |
-
- **147,712 physical vocabulary rows**
|
| 31 |
-
- 131,072-row indexed proposal head
|
| 32 |
-
- native one-layer ThinkingCap MTP
|
| 33 |
-
- NVFP4 target quantization
|
| 34 |
-
- baked activation-divisor tuning
|
| 35 |
-
- NVFP4 KV cache validation in the production benchmark path
|
| 36 |
-
- NInfer upstream GDN/runtime changes
|
| 37 |
-
- production prefill chunk **2048**
|
| 38 |
-
|
| 39 |
-
No runtime DX override environment variables are required for this artifact.
|
| 40 |
-
|
| 41 |
-
[☕ Support My Work](https://buymeacoffee.com/Schestex)
|
| 42 |
-
|
| 43 |
-
I'm an independent AI developer working on model optimization, quantization, fine-tuning, and high-performance inference.
|
| 44 |
-
|
| 45 |
-
If you find my models or research useful, consider supporting my work. Every contribution helps fund GPU experiments, new model releases, and further open-source AI development.
|
| 46 |
-
|
| 47 |
-
All support is voluntary and greatly appreciated!
|
| 48 |
|
| 49 |
-
|
| 50 |
|
| 51 |
-
`
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|---|---|
|
| 55 |
-
| File size | `16308912900 bytes` / `15.19 GiB` |
|
| 56 |
-
| SHA256 | `d030303f73b658399810a1be097c3b682610c47df8ea1cd24eb0c1eb53255b27` |
|
| 57 |
-
| Conversion sidecar | `combined-147590/thinkingcap-v1-upstream-d48dx3p5-oattndx6-ogdndx1-igdndx1-iattndx1-g64dx1-mtpgateupdx15p40-combined-147590.ninfer.conversion.json` |
|
| 58 |
-
| Public vocabulary | `147,590` |
|
| 59 |
-
| Physical vocabulary | `147,712` |
|
| 60 |
-
| Proposal rows | `131,072` |
|
| 61 |
-
| Components | `text, mtp` |
|
| 62 |
-
| Conversion device | CPU |
|
| 63 |
-
| Converter rows/chunk | `512` |
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|---|---:|
|
| 72 |
-
| D48 — MLP down | **3.5** |
|
| 73 |
-
| O_GDN — GDN output | **1.0** |
|
| 74 |
-
| O_ATTN — attention output | **6.0** |
|
| 75 |
-
| I_GDN — GDN input parent | **1.0** |
|
| 76 |
-
| I_ATTN — attention input parent | **1.0** |
|
| 77 |
-
| G64 — MLP gate/up | **1.0** |
|
| 78 |
-
| MTP GateUp | **15.40** |
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
-
- **O44**
|
| 84 |
-
- **I53**
|
| 85 |
-
- **G64**
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
| 91 |
|
| 92 |
-
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
``
|
|
|
|
|
|
|
| 101 |
|
| 102 |
-
The
|
| 103 |
-
Release mode, using CUDA 13.1.2.
|
| 104 |
|
| 105 |
-
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
``
|
|
|
|
| 110 |
|
| 111 |
-
|
| 112 |
|
| 113 |
-
|
| 114 |
-
https://github.com/Xtravaganz/ninfer
|
| 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 |
-
environment variables**.
|
| 149 |
|
| 150 |
-
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|---|---:|---:|---:|
|
| 154 |
-
| Mixed 8k | 0.7509293680 | **0.7509293680** | 0 |
|
| 155 |
-
| Mixed 32k | 0.6134185304 | **0.6134185304** | 0 |
|
| 156 |
-
| Mixed 48k | 0.5483870968 | **0.5483870968** | 0 |
|
| 157 |
-
| Mixed 110k | 0.5864197531 | **0.5864197531** | 0 |
|
| 158 |
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
-
|
| 162 |
|
| 163 |
-
|
| 164 |
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
| 170 |
-
| Mixed 8k | 54.02% | **75.09%** | **+21.07 pp** | 82.15 t/s | **116.99 t/s** | **+42.41%** | 3390.4 t/s | **3664.2 t/s** | **+8.07%** |
|
| 171 |
-
| Mixed 32k | 40.91% | **61.34%** | **+20.43 pp** | 64.00 t/s | **93.16 t/s** | **+45.56%** | 2866.7 t/s | **3027.2 t/s** | **+5.60%** |
|
| 172 |
-
| Mixed 48k | **55.33%** | 54.84% | -0.49 pp | 75.78 t/s | **83.33 t/s** | **+9.96%** | 2551.6 t/s | **2707.2 t/s** | **+6.10%** |
|
| 173 |
-
| Mixed 110k | 54.52% | **58.64%** | **+4.12 pp** | 67.55 t/s | **76.57 t/s** | **+13.35%** | 1798.4 t/s | **1919.2 t/s** | **+6.72%** |
|
| 174 |
|
| 175 |
-
|
| 176 |
-
|
|
|
|
| 177 |
|
| 178 |
-
|
| 179 |
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
| Context | Acc. 1024 | Acc. 2048 | Delta | Decode gain | Prefill gain |
|
| 183 |
-
|---|---:|---:|---:|---:|---:|
|
| 184 |
-
| Mixed 32k | 55.29% | **61.34%** | **+6.05 pp** | **+6.28%** | **+4.89%** |
|
| 185 |
-
| Mixed 110k | 43.53% | **58.64%** | **+15.11 pp** | **+22.45%** | **+4.79%** |
|
| 186 |
-
|
| 187 |
-
For this V1, `prefill-chunk=2048` is therefore part of the validated
|
| 188 |
-
production configuration.
|
| 189 |
-
|
| 190 |
-
## Compact vocabulary
|
| 191 |
-
|
| 192 |
-
The source tokenizer exposes 248,077 public tokens with a 248,320-row aligned
|
| 193 |
-
NInfer embedding/output head.
|
| 194 |
-
|
| 195 |
-
V1 uses the validated combined Script + CJK cut:
|
| 196 |
-
|
| 197 |
-
```text
|
| 198 |
-
Original public vocabulary 248,077
|
| 199 |
-
V1 public vocabulary 147,590
|
| 200 |
-
V1 physical vocabulary 147,712
|
| 201 |
-
Removed 100,487
|
| 202 |
-
Reduction 40.51%
|
| 203 |
-
Padding rows 122
|
| 204 |
-
```
|
| 205 |
-
|
| 206 |
-
The compact vocabulary was produced conservatively using:
|
| 207 |
-
|
| 208 |
-
- Unicode/script classification
|
| 209 |
-
- workload protection
|
| 210 |
-
- BPE dependency closure
|
| 211 |
-
- special/added-token protection
|
| 212 |
-
- tokenizer parity checks
|
| 213 |
-
- teacher-output audits
|
| 214 |
-
- runtime A/B validation
|
| 215 |
-
|
| 216 |
-
The MTP proposal vocabulary remains **131,072 rows** and is independent from
|
| 217 |
-
the full target vocabulary cut.
|
| 218 |
-
|
| 219 |
-
## Benchmark corpus
|
| 220 |
-
|
| 221 |
-
The V1 runtime tuning used mixed-context benchmark corpora intended to better
|
| 222 |
-
match real coding/agent workloads than pure text-only or code-only streams.
|
| 223 |
-
|
| 224 |
-
Primary validation points:
|
| 225 |
-
|
| 226 |
-
- 8,192-token mixed context
|
| 227 |
-
- 32,768-token mixed context
|
| 228 |
-
- 49,152-token mixed context
|
| 229 |
-
- 112,640-token mixed context
|
| 230 |
-
|
| 231 |
-
The 112,640-token test is intended to approximate the long-context
|
| 232 |
-
summary/compaction regime.
|
| 233 |
-
|
| 234 |
-
These benchmark-corpus acceptance values should not be interpreted as universal
|
| 235 |
-
chat or coding acceptance rates.
|
| 236 |
-
|
| 237 |
-
## Reproducibility
|
| 238 |
-
|
| 239 |
-
Final model:
|
| 240 |
-
|
| 241 |
-
```text
|
| 242 |
-
thinkingcap-v1-upstream-d48dx3p5-oattndx6-ogdndx1-igdndx1-iattndx1-g64dx1-mtpgateupdx15p40-combined-147590.ninfer
|
| 243 |
-
SHA256: d030303f73b658399810a1be097c3b682610c47df8ea1cd24eb0c1eb53255b27
|
| 244 |
-
```
|
| 245 |
-
|
| 246 |
-
Conversion sidecar SHA256:
|
| 247 |
-
|
| 248 |
-
```text
|
| 249 |
-
62eff698b11f1d393b518cf62937f918dc131e6893f65ec9cb57d5c5d8a9843b
|
| 250 |
-
```
|
| 251 |
-
|
| 252 |
-
Exact V1 source:
|
| 253 |
-
|
| 254 |
-
```text
|
| 255 |
-
git clone https://github.com/Xtravaganz/ninfer.git
|
| 256 |
-
cd ninfer
|
| 257 |
-
git checkout thinkingcap-upstream-v1-2026-10-05
|
| 258 |
-
```
|
| 259 |
-
|
| 260 |
-
The V1 tag is intentionally kept on the exact tested source commit, while
|
| 261 |
-
`master` also contains the repository's previous origin history.
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
## Repository layout
|
| 265 |
-
|
| 266 |
-
```text
|
| 267 |
-
combined-147590/
|
| 268 |
-
thinkingcap-v1-upstream-d48dx3p5-oattndx6-ogdndx1-igdndx1-iattndx1-g64dx1-mtpgateupdx15p40-combined-147590.ninfer
|
| 269 |
-
thinkingcap-v1-upstream-d48dx3p5-oattndx6-ogdndx1-igdndx1-iattndx1-g64dx1-mtpgateupdx15p40-combined-147590.ninfer.conversion.json
|
| 270 |
-
thinkingcap-v1-upstream-d48dx3p5-oattndx6-ogdndx1-igdndx1-iattndx1-g64dx1-mtpgateupdx15p40-combined-147590.ninfer.sha256
|
| 271 |
-
|
| 272 |
-
provenance/
|
| 273 |
-
V1-PRODUCTION.md
|
| 274 |
|
| 275 |
-
|
| 276 |
-
V1-RESULTS.md
|
| 277 |
|
| 278 |
-
|
| 279 |
-
FACTS.json
|
| 280 |
-
PROVENANCE.md
|
| 281 |
-
SHA256SUMS
|
| 282 |
-
README.md
|
| 283 |
-
```
|
| 284 |
|
| 285 |
-
|
| 286 |
-
The artifact listed in `MODEL_FILE.txt` is the current V1 production model.
|
| 287 |
-
|
| 288 |
-
## License
|
| 289 |
|
| 290 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: polyform-small-business-1.0.0
|
| 4 |
+
license_link: LICENSE
|
| 5 |
base_model: bottlecapai/ThinkingCap-Qwen3.8-27B
|
| 6 |
base_model_relation: quantized
|
| 7 |
library_name: ninfer
|
| 8 |
pipeline_tag: text-generation
|
|
|
|
|
|
|
|
|
|
| 9 |
tags:
|
| 10 |
+
- ninfer
|
| 11 |
+
- thinkingcap
|
| 12 |
+
- qwen3_8
|
| 13 |
+
- blackwell
|
| 14 |
+
- sm120a
|
| 15 |
+
- quantized
|
| 16 |
+
- speculative-decoding
|
| 17 |
+
- mtp
|
| 18 |
+
- indexed88
|
| 19 |
+
- text-generation
|
| 20 |
---
|
| 21 |
|
| 22 |
+
# ThinkingCap Qwen3.8-27B — NInfer releases
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
NInfer-format conversions of [bottlecapai/ThinkingCap-Qwen3.8-27B](https://huggingface.co/bottlecapai/ThinkingCap-Qwen3.8-27B), based on [Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B), for NVIDIA Blackwell inference.
|
| 25 |
|
| 26 |
+
**These artifacts are native `.ninfer` files, not Safetensors, GGUF, or Transformers checkpoints.** They require a compatible [NInfer](https://github.com/Xtravaganz/ninfer) runtime and are not intended for direct loading with `transformers.AutoModel` or vLLM.
|
| 27 |
|
| 28 |
+
## Releases
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
| Release | Public vocabulary | Physical rows | MTP proposal rows | Status |
|
| 31 |
+
| --- | ---: | ---: | ---: | --- |
|
| 32 |
+
| **Indexed88 v6.4 / 135K / R2** | **135,000** | **135,168** | **88,064** | Locally deployed; tagged container reports `canary` |
|
| 33 |
+
| **Original V1 / 147K** | 147,590 | 147,712 | 131,072 | Previously published, separately versioned |
|
| 34 |
|
| 35 |
+
**The 135K and 147K releases are different artifacts. Do not mix their tokenizers, proposal rankings, runtime settings, or conversion sidecars.** The original V1 remains in [`combined-147590/`](./combined-147590/).
|
| 36 |
|
| 37 |
+
## Indexed88 v6.4 — 135K / R2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
This release uses one physical Q8-backed MTP output head and evaluates only 88,064 selected vocabulary rows for speculative proposals. It is **not** a second output head or a second complete head projection.
|
| 40 |
|
| 41 |
+
### Release components
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
| Component | Description |
|
| 44 |
+
| --- | --- |
|
| 45 |
+
| Model artifact | `indexed88-v6.4-135k-r2/thinkingcap-135000-q8-repack.ninfer` |
|
| 46 |
+
| Selected-row IDs | `indexed88-v6.4-135k-r2/selected_88064_135k_v64_40_R2.i32le` |
|
| 47 |
+
| Chat template | `indexed88-v6.4-135k-r2/qwen3_8_sharp.jinja` |
|
| 48 |
+
| Checksums | `indexed88-v6.4-135k-r2/SHA256SUMS` |
|
| 49 |
+
| Release metadata | `indexed88-v6.4-135k-r2/RELEASE.json` |
|
| 50 |
|
| 51 |
+
The public model filename above is a **distribution name** for the local artifact `thinkingcap-135000-q8-repack-EXPERIMENTAL.ninfer`. Renaming/copying it does not change the model bytes. Verify its SHA-256 before publication and record the checksum in `SHA256SUMS`; a public model SHA-256 has not been asserted here.
|
| 52 |
|
| 53 |
+
Known source facts:
|
| 54 |
|
| 55 |
+
| Item | Value |
|
| 56 |
+
| --- | --- |
|
| 57 |
+
| Local model artifact size | **15,820,439,556 bytes** (approximately 14.73 GiB) |
|
| 58 |
+
| Model vocabulary | 135,000 public / 135,168 physical rows |
|
| 59 |
+
| Indexed proposal selection | 88,064 original token IDs |
|
| 60 |
+
| Selection file SHA-256 | `b578828c0b517ba47abe90a130fda7cde5a56d94add1afeac7623e7c8f6234b4` |
|
| 61 |
+
| Sharp chat-template SHA-256 | `cdff39fb26b60dc90faa292e726655c6b21f62db497846e02e4c4bbab942a84a` |
|
| 62 |
+
| Local deployment image tag | `thinkingcap-v1:indexed88-v6.4-135k-r2` |
|
| 63 |
+
| Local deployment image label | `org.thinkingcap.release.status=canary` |
|
| 64 |
|
| 65 |
+
**Important:** The Docker tag is a local runtime/deployment identifier, not a Hugging Face model filename and not evidence of a published OCI image. This repository distributes model assets; a container image must be distributed separately through an OCI registry if desired.
|
|
|
|
| 66 |
|
| 67 |
+
### Requirements
|
| 68 |
|
| 69 |
+
- A NInfer build that includes **135K Indexed88 v6.4 direct Q8 MTP support**. A generic upstream NInfer binary is not guaranteed to load or run this release correctly.
|
| 70 |
+
- Linux with an NVIDIA Blackwell GPU supported by that build (tested on an RTX PRO 4000 Blackwell with 24 GB VRAM, CUDA architecture `sm_120a`).
|
| 71 |
+
- Compatible CUDA runtime/driver and sufficient device memory. The referenced local builds used CUDA 13.3, `sm_120a`, Release mode.
|
| 72 |
+
- The exact 135K ranking and chat template supplied with this release.
|
| 73 |
|
| 74 |
+
### Download
|
| 75 |
|
| 76 |
+
After the release directory has been uploaded:
|
|
|
|
|
|
|
| 77 |
|
| 78 |
+
```bash
|
| 79 |
+
hf download Schestex/ThinkingCap-Qwen3.8-27B-NInfer \
|
| 80 |
+
--include 'indexed88-v6.4-135k-r2/*' \
|
| 81 |
+
--local-dir ./thinkingcap-ninfer
|
| 82 |
|
| 83 |
+
cd thinkingcap-ninfer
|
| 84 |
+
(cd indexed88-v6.4-135k-r2 && sha256sum --check SHA256SUMS)
|
| 85 |
```
|
| 86 |
|
| 87 |
+
### Example: native NInfer server
|
| 88 |
+
|
| 89 |
+
This command assumes you have **built a compatible 135K Indexed88 v6.4 NInfer server**. On a host with multiple GPUs, `--device 0` refers to the first GPU visible to the process.
|
| 90 |
+
|
| 91 |
+
```bash
|
| 92 |
+
export CUDA_VISIBLE_DEVICES=0 # change to the intended physical GPU index if needed
|
| 93 |
+
export NINFER_MTP_INDEXED_SHADOW=1
|
| 94 |
+
export NINFER_MTP_INDEXED_MODE=indexed96
|
| 95 |
+
export NINFER_MTP_INDEXED_RANKING="$PWD/indexed88-v6.4-135k-r2/selected_88064_135k_v64_40_R2.i32le"
|
| 96 |
+
|
| 97 |
+
./ninfer-serve \
|
| 98 |
+
"$PWD/indexed88-v6.4-135k-r2/thinkingcap-135000-q8-repack.ninfer" \
|
| 99 |
+
--host 127.0.0.1 --port 8080 \
|
| 100 |
+
--model-id thinkingcap-135k-indexed88 \
|
| 101 |
+
--device 0 \
|
| 102 |
+
--spec mtp --draft-tokens 5 \
|
| 103 |
+
--kv-dtype nvfp4 \
|
| 104 |
+
--max-context 8192 --kv-capacity 8192 \
|
| 105 |
+
--max-concurrency 1 --prefill-chunk 512 \
|
| 106 |
+
--preserve-thinking \
|
| 107 |
+
--chat-template "$PWD/indexed88-v6.4-135k-r2/qwen3_8_sharp.jinja"
|
| 108 |
```
|
| 109 |
|
| 110 |
+
The historical environment variable `NINFER_MTP_INDEXED_SHADOW=1` enables the Indexed-MTP configuration. **`NINFER_MTP_INDEXED_MODE=indexed96` selects the direct path** in the tested runtime, notwithstanding the older internal name. The runtime's `indexed96` enum uses 88,064 selected rows for this release. In direct mode the selected Q8 proposal is authoritative and the full MTP proposal projection is skipped. No external Q5/Q6 head is required.
|
| 111 |
|
| 112 |
+
Do not set `NINFER_MTP_INDEXED_MODE=shadow` if you want the one-projection Indexed88 direct configuration.
|
|
|
|
| 113 |
|
| 114 |
+
### Validation and performance scope
|
| 115 |
|
| 116 |
+
The 135K Indexed88 configuration was evaluated on **one RTX PRO 4000 Blackwell GPU (24 GB)** using native NInfer builds, `--spec mtp --draft-tokens 5`, NVFP4 KV cache, `temperature=0`, and three consecutive requests capped at 3,500 output tokens each. Each kernel variant used the same model, ranking, and template.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
+
| Indexed88 Q8 kernel tested | Turn 1 | Turn 2 | Turn 3 | Acceptance across the test |
|
| 119 |
+
| --- | ---: | ---: | ---: | ---: |
|
| 120 |
+
| R0 reference | 95.34 tok/s | 94.75 tok/s | 90.44 tok/s | 55.33% |
|
| 121 |
+
| Experimental R2 (row-ID hoisting) | 95.19 tok/s | 94.66 tok/s | 90.42 tok/s | 55.33% |
|
| 122 |
+
| Experimental R3 (hoisting + occupancy) | 95.30 tok/s | 94.80 tok/s | 90.43 tok/s | 55.33% |
|
| 123 |
|
| 124 |
+
All three experimental builds produced **identical complete response hashes for each corresponding turn**, and matched draft/acceptance counts. The R2/R3 optimizations were **experimental isolated builds, not changes to the local production image**. These results are not a standardized model-quality benchmark or a guarantee of performance on other hardware, prompts, contexts, or decoding settings. The model and the actual published image/build should be matched using separately recorded hashes before making reproducibility claims.
|
| 125 |
|
| 126 |
+
### Limitations
|
| 127 |
|
| 128 |
+
- The selected 88,064-row proposal vocabulary is a performance/coverage trade-off; it is **not** a reduction of the public tokenizer to 88,064 IDs. The model's public vocabulary is 135,000.
|
| 129 |
+
- Generated content can be inaccurate, unsafe, or unsuitable for unsupervised code/agent execution. Validate outputs before use.
|
| 130 |
+
- This release is NInfer-runtime-specific, not a drop-in HF Transformers distribution.
|
| 131 |
+
- CUDA Graph and runtime behavior depend on the exact NInfer build. The tested direct `indexed96` path supports CUDA Graph integration; other versions may differ.
|
| 132 |
+
- Release status is still marked `canary` in the known local image metadata; do not interpret this page as a universal production-readiness or support guarantee.
|
| 133 |
|
| 134 |
+
## Provenance and attribution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
+
- **Base model:** [Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B).
|
| 137 |
+
- **ThinkingCap fine-tune:** [bottlecapai/ThinkingCap-Qwen3.8-27B](https://huggingface.co/bottlecapai/ThinkingCap-Qwen3.8-27B).
|
| 138 |
+
- **NInfer:** [Xtravaganz/ninfer](https://github.com/Xtravaganz/ninfer) (the repository linked by the previous release; a matching 135K Indexed88 runtime commit/tag has not yet been publicly verified here).
|
| 139 |
|
| 140 |
+
This is an independently packaged NInfer conversion and runtime configuration of the upstream ThinkingCap model; it should not be presented as a new pretraining or fine-tuning run.
|
| 141 |
|
| 142 |
+
## License
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
+
ThinkingCap is licensed under **PolyForm Small Business License 1.0.0**, with an additional personal, noncommercial use permission from BottleCap AI. The underlying Qwen materials carry **Apache-2.0** requirements. See the original [ThinkingCap LICENSE](https://huggingface.co/bottlecapai/ThinkingCap-Qwen3.8-27B/blob/main/LICENSE) and [NOTICE](https://huggingface.co/bottlecapai/ThinkingCap-Qwen3.8-27B/blob/main/NOTICE).
|
|
|
|
| 145 |
|
| 146 |
+
Keep the upstream license texts, copyright notices, and attribution files when redistributing these derived weights. This release does not grant broader commercial rights than the upstream license.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
+
---
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
+
For historical 147K V1 artifacts and results, retain the existing [`combined-147590/`](./combined-147590/), `provenance/`, and `benchmarks/` directories until older references have been verified and archived cleanly.
|
indexed88-v6.4-135k-r2/RELEASE.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"release": "indexed88-v6.4-135k-r2",
|
| 3 |
+
"model_repo": "Schestex/ThinkingCap-Qwen3.8-27B-NInfer",
|
| 4 |
+
"created_at_utc": "2026-11-01T12:43:22.651143+00:00",
|
| 5 |
+
"model_file": "thinkingcap-135000-q8-repack.ninfer",
|
| 6 |
+
"source_model_filename": "thinkingcap-135000-q8-repack-EXPERIMENTAL.ninfer",
|
| 7 |
+
"model_size_bytes": 15820439556,
|
| 8 |
+
"selected_rows": 88064,
|
| 9 |
+
"public_vocab": 135000,
|
| 10 |
+
"physical_vocab_rows": 135168,
|
| 11 |
+
"checksums_sha256": {
|
| 12 |
+
"thinkingcap-135000-q8-repack.ninfer": "df1ab1bfc8dc4ac119b3c064993423f3e4f351796db43468f4180b2e20ab7ad6",
|
| 13 |
+
"selected_88064_135k_v64_40_R2.i32le": "b578828c0b517ba47abe90a130fda7cde5a56d94add1afeac7623e7c8f6234b4",
|
| 14 |
+
"qwen3_8_sharp.jinja": "cdff39fb26b60dc90faa292e726655c6b21f62db497846e02e4c4bbab942a84a"
|
| 15 |
+
},
|
| 16 |
+
"mtpspec_draft_window": 5,
|
| 17 |
+
"selected_row_mode": "indexed96",
|
| 18 |
+
"proposal_head": "one direct Q8 projection",
|
| 19 |
+
"local_docker_image_tag": "thinkingcap-v1:indexed88-v6.4-135k-r2",
|
| 20 |
+
"local_docker_image_status_label": "canary",
|
| 21 |
+
"local_docker_image_id": "sha256:32a4388fa74a174d42de9a39ea6e93d3e830f95c271efb4931408945abea8021",
|
| 22 |
+
"runtime_source_commit": null,
|
| 23 |
+
"artifact_conversion_provenance": null,
|
| 24 |
+
"oci_image_registry_url": null,
|
| 25 |
+
"note": "null fields must be resolved or clearly documented before claiming full reproducibility"
|
| 26 |
+
}
|
indexed88-v6.4-135k-r2/SHA256SUMS
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
df1ab1bfc8dc4ac119b3c064993423f3e4f351796db43468f4180b2e20ab7ad6 thinkingcap-135000-q8-repack.ninfer
|
| 2 |
+
b578828c0b517ba47abe90a130fda7cde5a56d94add1afeac7623e7c8f6234b4 selected_88064_135k_v64_40_R2.i32le
|
| 3 |
+
cdff39fb26b60dc90faa292e726655c6b21f62db497846e02e4c4bbab942a84a qwen3_8_sharp.jinja
|
indexed88-v6.4-135k-r2/qwen3_8_sharp.jinja
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set template_version = "qwen3.8-froggeric-v22.5.0" %}
|
| 2 |
+
{%- set _tool_format = tool_call_format if tool_call_format is defined else 'xml' %}
|
| 3 |
+
{%- set image_count = namespace(value=0) %}
|
| 4 |
+
{%- set video_count = namespace(value=0) %}
|
| 5 |
+
{%- set add_vision_id = add_vision_id if add_vision_id is defined else false %}
|
| 6 |
+
{%- set enable_thinking = enable_thinking if enable_thinking is defined else true %}
|
| 7 |
+
{%- set auto_disable_thinking_with_tools = auto_disable_thinking_with_tools if auto_disable_thinking_with_tools is defined else false %}
|
| 8 |
+
{%- if preserve_reasoning is defined and preserve_reasoning is not none %}
|
| 9 |
+
{%- set _preserve_thinking = preserve_reasoning %}
|
| 10 |
+
{%- elif preserve_thinking is defined and preserve_thinking is not none %}
|
| 11 |
+
{%- set _preserve_thinking = preserve_thinking %}
|
| 12 |
+
{%- else %}
|
| 13 |
+
{%- set _preserve_thinking = true %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- set max_tool_arg_chars = max_tool_arg_chars if max_tool_arg_chars is defined else 0 %}
|
| 16 |
+
{%- set max_tool_response_chars = max_tool_response_chars if max_tool_response_chars is defined else 0 %}
|
| 17 |
+
{%- set _default_reasoning_effort = 'medium' %}
|
| 18 |
+
{%- set _has_tools = (tools is defined and tools and tools is iterable and tools is not mapping) %}
|
| 19 |
+
{%- set _effort_raw = (reasoning_effort | string | lower) if reasoning_effort is defined and reasoning_effort is not none else _default_reasoning_effort %}
|
| 20 |
+
{%- set _initial_thinking = enable_thinking %}
|
| 21 |
+
{%- if _effort_raw in ('none', 'off') %}
|
| 22 |
+
{%- set _initial_thinking = false %}
|
| 23 |
+
{%- set _initial_effort = 'medium' %}
|
| 24 |
+
{%- elif _effort_raw in ('minimal', 'low') %}
|
| 25 |
+
{%- set _initial_effort = 'low' %}
|
| 26 |
+
{%- elif _effort_raw in ('high', 'xhigh', 'max', 'ultracode', 'extreme') %}
|
| 27 |
+
{%- set _initial_effort = 'xhigh' %}
|
| 28 |
+
{%- else %}
|
| 29 |
+
{%- set _initial_effort = 'medium' %}
|
| 30 |
+
{%- endif %}
|
| 31 |
+
{%- set ns_state = namespace(thinking=_initial_thinking, effort=_initial_effort) %}
|
| 32 |
+
{%- if auto_disable_thinking_with_tools and _has_tools %}
|
| 33 |
+
{%- set ns_state.thinking = false %}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- for msg in messages %}
|
| 36 |
+
{%- if msg.role == 'system' or msg.role == 'developer' or msg.role == 'user' %}
|
| 37 |
+
{%- if msg.content is string %}
|
| 38 |
+
{%- if '<|think_off|>' in msg.content %}
|
| 39 |
+
{%- set ns_state.thinking = false %}
|
| 40 |
+
{%- elif '<|think_on|>' in msg.content %}
|
| 41 |
+
{%- set ns_state.thinking = true %}
|
| 42 |
+
{%- elif '<|think_xhigh|>' in msg.content or '<|think_high|>' in msg.content or '<|think_ultracode|>' in msg.content or '<|think_extreme|>' in msg.content or '<|think_max|>' in msg.content %}
|
| 43 |
+
{%- set ns_state.thinking = true %}
|
| 44 |
+
{%- set ns_state.effort = 'xhigh' %}
|
| 45 |
+
{%- elif '<|think_low|>' in msg.content or '<|think_minimal|>' in msg.content %}
|
| 46 |
+
{%- set ns_state.thinking = true %}
|
| 47 |
+
{%- set ns_state.effort = 'low' %}
|
| 48 |
+
{%- elif '<|think_medium|>' in msg.content %}
|
| 49 |
+
{%- set ns_state.thinking = true %}
|
| 50 |
+
{%- set ns_state.effort = 'medium' %}
|
| 51 |
+
{%- endif %}
|
| 52 |
+
{%- elif msg.content is iterable and msg.content is not mapping %}
|
| 53 |
+
{%- for item in msg.content %}
|
| 54 |
+
{%- if item is string %}
|
| 55 |
+
{%- set _item_text = item %}
|
| 56 |
+
{%- elif item is mapping and 'text' in item and item.text is string %}
|
| 57 |
+
{%- set _item_text = item.text %}
|
| 58 |
+
{%- else %}
|
| 59 |
+
{%- set _item_text = '' %}
|
| 60 |
+
{%- endif %}
|
| 61 |
+
{%- if _item_text %}
|
| 62 |
+
{%- if '<|think_off|>' in _item_text %}
|
| 63 |
+
{%- set ns_state.thinking = false %}
|
| 64 |
+
{%- elif '<|think_on|>' in _item_text %}
|
| 65 |
+
{%- set ns_state.thinking = true %}
|
| 66 |
+
{%- elif '<|think_xhigh|>' in _item_text or '<|think_high|>' in _item_text or '<|think_ultracode|>' in _item_text or '<|think_extreme|>' in _item_text or '<|think_max|>' in _item_text %}
|
| 67 |
+
{%- set ns_state.thinking = true %}
|
| 68 |
+
{%- set ns_state.effort = 'xhigh' %}
|
| 69 |
+
{%- elif '<|think_low|>' in _item_text or '<|think_minimal|>' in _item_text %}
|
| 70 |
+
{%- set ns_state.thinking = true %}
|
| 71 |
+
{%- set ns_state.effort = 'low' %}
|
| 72 |
+
{%- elif '<|think_medium|>' in _item_text %}
|
| 73 |
+
{%- set ns_state.thinking = true %}
|
| 74 |
+
{%- set ns_state.effort = 'medium' %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- endif %}
|
| 79 |
+
{%- endif %}
|
| 80 |
+
{%- endfor %}
|
| 81 |
+
{%- set reasoning_instructions = '' %}
|
| 82 |
+
{%- if ns_state.thinking %}
|
| 83 |
+
{%- if ns_state.effort == 'xhigh' %}
|
| 84 |
+
{%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}
|
| 85 |
+
{%- elif ns_state.effort == 'low' %}
|
| 86 |
+
{%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}
|
| 87 |
+
{%- endif %}
|
| 88 |
+
{%- endif %}
|
| 89 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 90 |
+
{%- if content is string %}
|
| 91 |
+
{{- content }}
|
| 92 |
+
{%- elif content is iterable and content is not mapping %}
|
| 93 |
+
{%- for item in content %}
|
| 94 |
+
{%- if item is mapping %}
|
| 95 |
+
{%- if item.type == 'image' or 'image' in item or 'image_url' in item %}
|
| 96 |
+
{%- if is_system_content %}
|
| 97 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- if do_vision_count %}
|
| 100 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 101 |
+
{%- endif %}
|
| 102 |
+
{%- if add_vision_id %}
|
| 103 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 106 |
+
{%- elif item.type == 'video' or 'video' in item or 'video_url' in item %}
|
| 107 |
+
{%- if is_system_content %}
|
| 108 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{%- if do_vision_count %}
|
| 111 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 112 |
+
{%- endif %}
|
| 113 |
+
{%- if add_vision_id %}
|
| 114 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 117 |
+
{%- elif 'text' in item %}
|
| 118 |
+
{{- item.text }}
|
| 119 |
+
{%- else %}
|
| 120 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 121 |
+
{%- endif %}
|
| 122 |
+
{%- else %}
|
| 123 |
+
{{- item | string }}
|
| 124 |
+
{%- endif %}
|
| 125 |
+
{%- endfor %}
|
| 126 |
+
{%- elif content is none or content is undefined %}
|
| 127 |
+
{{- '' }}
|
| 128 |
+
{%- else %}
|
| 129 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 130 |
+
{%- endif %}
|
| 131 |
+
{%- endmacro %}
|
| 132 |
+
{%- if not messages %}
|
| 133 |
+
{{- raise_exception('No messages provided.') }}
|
| 134 |
+
{%- endif %}
|
| 135 |
+
{%- set head = namespace(count=0, seen_non_system=false) %}
|
| 136 |
+
{%- for message in messages %}
|
| 137 |
+
{%- set _is_sys = (message.role == 'system' or message.role == 'developer') %}
|
| 138 |
+
{%- if _is_sys and not head.seen_non_system %}
|
| 139 |
+
{%- set head.count = head.count + 1 %}
|
| 140 |
+
{%- else %}
|
| 141 |
+
{%- set head.seen_non_system = true %}
|
| 142 |
+
{%- endif %}
|
| 143 |
+
{%- endfor %}
|
| 144 |
+
{%- set sys_state = namespace(content='') %}
|
| 145 |
+
{%- for message in messages[:head.count] %}
|
| 146 |
+
{%- set _part = render_content(message.content, false, true) | trim %}
|
| 147 |
+
{%- if '<|think_off|>' in _part %}{%- set _part = _part.split('<|think_off|>') | join('') | trim %}{%- endif %}
|
| 148 |
+
{%- if '<|think_on|>' in _part %}{%- set _part = _part.split('<|think_on|>') | join('') | trim %}{%- endif %}
|
| 149 |
+
{%- if '<|think_xhigh|>' in _part %}{%- set _part = _part.split('<|think_xhigh|>') | join('') | trim %}{%- endif %}
|
| 150 |
+
{%- if '<|think_high|>' in _part %}{%- set _part = _part.split('<|think_high|>') | join('') | trim %}{%- endif %}
|
| 151 |
+
{%- if '<|think_ultracode|>' in _part %}{%- set _part = _part.split('<|think_ultracode|>') | join('') | trim %}{%- endif %}
|
| 152 |
+
{%- if '<|think_extreme|>' in _part %}{%- set _part = _part.split('<|think_extreme|>') | join('') | trim %}{%- endif %}
|
| 153 |
+
{%- if '<|think_max|>' in _part %}{%- set _part = _part.split('<|think_max|>') | join('') | trim %}{%- endif %}
|
| 154 |
+
{%- if '<|think_medium|>' in _part %}{%- set _part = _part.split('<|think_medium|>') | join('') | trim %}{%- endif %}
|
| 155 |
+
{%- if '<|think_low|>' in _part %}{%- set _part = _part.split('<|think_low|>') | join('') | trim %}{%- endif %}
|
| 156 |
+
{%- if '<|think_minimal|>' in _part %}{%- set _part = _part.split('<|think_minimal|>') | join('') | trim %}{%- endif %}
|
| 157 |
+
{%- if _part %}
|
| 158 |
+
{%- if sys_state.content %}
|
| 159 |
+
{%- set sys_state.content = sys_state.content ~ '\n\n' ~ _part %}
|
| 160 |
+
{%- else %}
|
| 161 |
+
{%- set sys_state.content = _part %}
|
| 162 |
+
{%- endif %}
|
| 163 |
+
{%- endif %}
|
| 164 |
+
{%- endfor %}
|
| 165 |
+
{%- set _sc = sys_state.content %}
|
| 166 |
+
{%- set _msgs = messages[head.count:] %}
|
| 167 |
+
{%- if ns_state.thinking %}
|
| 168 |
+
{%- set _terse_lead = 'Answer directly, after thinking. Lead with the answer, then only what it needs to be correct and usable.' %}
|
| 169 |
+
{%- else %}
|
| 170 |
+
{%- set _terse_lead = 'Answer directly and concisely. Give the answer with only what it needs to be correct and usable.' %}
|
| 171 |
+
{%- endif %}
|
| 172 |
+
{%- set _terse_core %}
|
| 173 |
+
Never: open with preamble or pleasantries; restate the question; add filler transitions; hedge with niceties; or repeat a point you've already made.
|
| 174 |
+
Always: keep essential steps, caveats, uncertainties, and specifics — never drop correctness or a needed warning for brevity. Keep the final answer lean. Use the least structure that conveys it (plain prose when short; lists or code only when they earn their place). If genuinely uncertain, say so and explain why — never omit uncertainty for the sake of brevity.
|
| 175 |
+
If a user request is genuinely ambiguous, ask a sharp question, don't guess.
|
| 176 |
+
{%- endset %}
|
| 177 |
+
{%- set _terse = _terse_lead ~ '\n' ~ (_terse_core | trim) %}
|
| 178 |
+
{#- `terse` chat-template kwarg: default true, so behaviour is unchanged unless a caller opts out.
|
| 179 |
+
Pass {"terse": false} via chat_template_kwargs to serve the model with only its own system
|
| 180 |
+
prompt -- useful for A/B-ing the terseness effect, or when a downstream prompt conflicts. #}
|
| 181 |
+
{%- set _terse_on = terse if terse is defined else true %}
|
| 182 |
+
{%- if _terse_on %}
|
| 183 |
+
{%- if not _sc %}
|
| 184 |
+
{%- set _sc = _terse | trim %}
|
| 185 |
+
{%- else %}
|
| 186 |
+
{%- set _sc = (_sc | trim) ~ '\n\n' ~ (_terse | trim) %}
|
| 187 |
+
{%- endif %}
|
| 188 |
+
{%- endif %}
|
| 189 |
+
{#- Some runtimes (LM Studio's MLX backend) have no native tool-call parser and prepend their own
|
| 190 |
+
protocol into the system content. Emitting ours as well gives the model two contradictory tool
|
| 191 |
+
protocols and it follows one at random. Detect that marker and stand down; the
|
| 192 |
+
`suppress_tool_instructions` kwarg overrides either way where a runtime can pass template kwargs. #}
|
| 193 |
+
{%- set _runtime_tool_protocol = (_sc is defined and _sc and '[TOOL_REQUEST]' in _sc) %}
|
| 194 |
+
{%- set _suppress_tools = suppress_tool_instructions if suppress_tool_instructions is defined else _runtime_tool_protocol %}
|
| 195 |
+
{%- if _has_tools and not _suppress_tools %}
|
| 196 |
+
{{- '<|im_start|>system\n' }}
|
| 197 |
+
{%- if reasoning_instructions %}
|
| 198 |
+
{{- reasoning_instructions + '\n\n' }}
|
| 199 |
+
{%- endif %}
|
| 200 |
+
{{- '# Tools\n\nYou have access to the following functions:\n\n<tools>' }}
|
| 201 |
+
{%- for tool in tools %}
|
| 202 |
+
{{- '\n' }}
|
| 203 |
+
{{- tool | tojson }}
|
| 204 |
+
{%- endfor %}
|
| 205 |
+
{{- '\n</tools>' }}
|
| 206 |
+
{%- if _tool_format == 'json' %}
|
| 207 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n' }}
|
| 208 |
+
{%- if ns_state.thinking %}
|
| 209 |
+
{{- '<think>\nBrief explanation of tool call\n</think>\n' }}
|
| 210 |
+
{%- endif %}
|
| 211 |
+
{{- '<tool_call>\n{"name": "example_function_name", "arguments": {"example_parameter_1": "value_1", "example_parameter_2": "This is the value for the second parameter"}}\n</tool_call>\n\n<IMPORTANT>\nReminder:\n' }}
|
| 212 |
+
{%- if ns_state.thinking %}
|
| 213 |
+
{{- '- You can use the <think></think> block to plan your next tool call OR to synthesize data and formulate your final response to the user.\n- ALL explanation and reasoning MUST be placed strictly inside the <think></think> block.\n' }}
|
| 214 |
+
{%- endif %}
|
| 215 |
+
{{- '- Function calls MUST follow the specified format: a single JSON object with "name" and "arguments" keys inside <tool_call></tool_call> XML tags.\n' }}
|
| 216 |
+
{%- if ns_state.thinking %}
|
| 217 |
+
{{- '- If you choose to call a tool, you MUST output the <tool_call> block IMMEDIATELY after thinking, with NO conversational text before it.\n' }}
|
| 218 |
+
{%- else %}
|
| 219 |
+
{{- '- If you choose to call a tool, you MUST output the <tool_call> block IMMEDIATELY, with NO conversational text before it.\n' }}
|
| 220 |
+
{%- endif %}
|
| 221 |
+
{{- '- The <tool_call> tag MUST be at the very beginning of a new line, with NO spaces or indentation before it.\n- To call multiple functions, output a separate, completely closed <tool_call></tool_call> block for EACH function. Do NOT nest <tool_call> blocks.\n- If you have all necessary data, provide your final answer directly to the user without any tool call.\n</IMPORTANT>' }}
|
| 222 |
+
{%- else %}
|
| 223 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n' }}
|
| 224 |
+
{%- if ns_state.thinking %}
|
| 225 |
+
{{- '<think>\nBrief explanation of tool call\n</think>\n' }}
|
| 226 |
+
{%- endif %}
|
| 227 |
+
{{- '<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n' }}
|
| 228 |
+
{%- if ns_state.thinking %}
|
| 229 |
+
{{- '- You can use the <think></think> block to plan your next tool call OR to synthesize data and formulate your final response to the user.\n- ALL explanation and reasoning MUST be placed strictly inside the <think></think> block.\n' }}
|
| 230 |
+
{%- endif %}
|
| 231 |
+
{{- '- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags.\n' }}
|
| 232 |
+
{%- if ns_state.thinking %}
|
| 233 |
+
{{- '- If you choose to call a tool, you MUST output the <tool_call> block IMMEDIATELY after thinking, with NO conversational text before it.\n' }}
|
| 234 |
+
{%- else %}
|
| 235 |
+
{{- '- If you choose to call a tool, you MUST output the <tool_call> block IMMEDIATELY, with NO conversational text before it.\n' }}
|
| 236 |
+
{%- endif %}
|
| 237 |
+
{{- '- The <tool_call> and <function> tags MUST be at the very beginning of a new line, with NO spaces or indentation before them.\n- To call multiple functions, output a separate, completely closed <tool_call></tool_call> block for EACH function. Do NOT nest <tool_call> blocks.\n- If you have all necessary data, provide your final answer directly to the user without any tool call.\n</IMPORTANT>' }}
|
| 238 |
+
{%- endif %}
|
| 239 |
+
{%- if _sc %}
|
| 240 |
+
{{- '\n\n' + _sc }}
|
| 241 |
+
{%- endif %}
|
| 242 |
+
{{- '<|im_end|>\n' }}
|
| 243 |
+
{%- else %}
|
| 244 |
+
{%- if _sc %}
|
| 245 |
+
{{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + _sc + '<|im_end|>\n' }}
|
| 246 |
+
{%- elif reasoning_instructions %}
|
| 247 |
+
{{- '<|im_start|>system\n' + reasoning_instructions + '<|im_end|>\n' }}
|
| 248 |
+
{%- endif %}
|
| 249 |
+
{%- endif %}
|
| 250 |
+
{%- set _last_idx = _msgs | length - 1 %}
|
| 251 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=_last_idx) %}
|
| 252 |
+
{%- for message in _msgs[::-1] %}
|
| 253 |
+
{%- set index = (_msgs | length - 1) - loop.index0 %}
|
| 254 |
+
{%- if ns.multi_step_tool and message.role == 'user' %}
|
| 255 |
+
{%- set _rc = render_content(message.content, false) | trim %}
|
| 256 |
+
{%- if not (_rc.startswith('<tool_response>') and _rc.endswith('</tool_response>')) %}
|
| 257 |
+
{%- set ns.multi_step_tool = false %}
|
| 258 |
+
{%- set ns.last_query_index = index %}
|
| 259 |
+
{%- endif %}
|
| 260 |
+
{%- endif %}
|
| 261 |
+
{%- endfor %}
|
| 262 |
+
{%- if ns.multi_step_tool %}
|
| 263 |
+
{%- if _last_idx > 50 %}
|
| 264 |
+
{%- set ns.last_query_index = _last_idx %}
|
| 265 |
+
{%- else %}
|
| 266 |
+
{%- set ns.last_query_index = 0 %}
|
| 267 |
+
{%- endif %}
|
| 268 |
+
{%- endif %}
|
| 269 |
+
{%- set ns2 = namespace(prev_role='', consecutive_failures=0) %}
|
| 270 |
+
{%- for message in _msgs %}
|
| 271 |
+
{%- set is_system = (message.role == "system" or message.role == "developer") %}
|
| 272 |
+
{%- set content = render_content(message.content, true, is_system) | trim %}
|
| 273 |
+
{%- if is_system or message.role == 'user' %}
|
| 274 |
+
{%- if '<|think_off|>' in content %}{%- set content = content.split('<|think_off|>') | join('') | trim %}{%- endif %}
|
| 275 |
+
{%- if '<|think_on|>' in content %}{%- set content = content.split('<|think_on|>') | join('') | trim %}{%- endif %}
|
| 276 |
+
{%- if '<|think_xhigh|>' in content %}{%- set content = content.split('<|think_xhigh|>') | join('') | trim %}{%- endif %}
|
| 277 |
+
{%- if '<|think_high|>' in content %}{%- set content = content.split('<|think_high|>') | join('') | trim %}{%- endif %}
|
| 278 |
+
{%- if '<|think_ultracode|>' in content %}{%- set content = content.split('<|think_ultracode|>') | join('') | trim %}{%- endif %}
|
| 279 |
+
{%- if '<|think_extreme|>' in content %}{%- set content = content.split('<|think_extreme|>') | join('') | trim %}{%- endif %}
|
| 280 |
+
{%- if '<|think_max|>' in content %}{%- set content = content.split('<|think_max|>') | join('') | trim %}{%- endif %}
|
| 281 |
+
{%- if '<|think_medium|>' in content %}{%- set content = content.split('<|think_medium|>') | join('') | trim %}{%- endif %}
|
| 282 |
+
{%- if '<|think_low|>' in content %}{%- set content = content.split('<|think_low|>') | join('') | trim %}{%- endif %}
|
| 283 |
+
{%- if '<|think_minimal|>' in content %}{%- set content = content.split('<|think_minimal|>') | join('') | trim %}{%- endif %}
|
| 284 |
+
{%- endif %}
|
| 285 |
+
{%- if is_system %}
|
| 286 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 287 |
+
{%- elif message.role == 'user' %}
|
| 288 |
+
{%- set ns2.consecutive_failures = 0 %}
|
| 289 |
+
{{- '<|im_start|>user\n' + content + '<|im_end|>\n' }}
|
| 290 |
+
{%- elif message.role == 'assistant' %}
|
| 291 |
+
{%- set reasoning_content = '' %}
|
| 292 |
+
{%- set _explicit_reasoning = '' %}
|
| 293 |
+
{%- if message.reasoning_content is defined and message.reasoning_content is not none %}
|
| 294 |
+
{%- if message.reasoning_content is string %}
|
| 295 |
+
{%- set _explicit_reasoning = message.reasoning_content %}
|
| 296 |
+
{%- else %}
|
| 297 |
+
{%- set _explicit_reasoning = message.reasoning_content | string %}
|
| 298 |
+
{%- endif %}
|
| 299 |
+
{%- elif message.thinking is defined and message.thinking is not none %}
|
| 300 |
+
{%- if message.thinking is string %}
|
| 301 |
+
{%- set _explicit_reasoning = message.thinking %}
|
| 302 |
+
{%- else %}
|
| 303 |
+
{%- set _explicit_reasoning = message.thinking | string %}
|
| 304 |
+
{%- endif %}
|
| 305 |
+
{%- elif message.reasoning is defined and message.reasoning is not none %}
|
| 306 |
+
{%- if message.reasoning is string %}
|
| 307 |
+
{%- set _explicit_reasoning = message.reasoning %}
|
| 308 |
+
{%- else %}
|
| 309 |
+
{%- set _explicit_reasoning = message.reasoning | string %}
|
| 310 |
+
{%- endif %}
|
| 311 |
+
{%- endif %}
|
| 312 |
+
{%- if _explicit_reasoning %}
|
| 313 |
+
{%- set _lead_end = '' %}
|
| 314 |
+
{%- if content.startswith('<think>') and '</think>' in content %}
|
| 315 |
+
{%- set _lead_end = '</think>' %}
|
| 316 |
+
{%- elif content.startswith('<thinking>') and '</thinking>' in content %}
|
| 317 |
+
{%- set _lead_end = '</thinking>' %}
|
| 318 |
+
{%- elif content.startswith('</think>') %}
|
| 319 |
+
{%- set _lead_end = '</think>' %}
|
| 320 |
+
{%- elif content.startswith('</thinking>') %}
|
| 321 |
+
{%- set _lead_end = '</thinking>' %}
|
| 322 |
+
{%- endif %}
|
| 323 |
+
{%- if _lead_end %}
|
| 324 |
+
{%- set content = content.split(_lead_end)[-1].lstrip('\n') %}
|
| 325 |
+
{%- endif %}
|
| 326 |
+
{%- set reasoning_content = _explicit_reasoning %}
|
| 327 |
+
{%- else %}
|
| 328 |
+
{%- set _think_end = '' %}
|
| 329 |
+
{%- if content.startswith('</think>') %}
|
| 330 |
+
{%- set _think_end = '</think>' %}
|
| 331 |
+
{%- elif content.startswith('</thinking>') %}
|
| 332 |
+
{%- set _think_end = '</thinking>' %}
|
| 333 |
+
{%- elif '\n</think>' in content %}
|
| 334 |
+
{%- set _think_end = '\n</think>' %}
|
| 335 |
+
{%- elif '\n</thinking>' in content %}
|
| 336 |
+
{%- set _think_end = '\n</thinking>' %}
|
| 337 |
+
{%- elif '\n</ think>' in content %}
|
| 338 |
+
{%- set _think_end = '\n</ think>' %}
|
| 339 |
+
{%- elif '\n</think >' in content %}
|
| 340 |
+
{%- set _think_end = '\n</think >' %}
|
| 341 |
+
{%- elif content.startswith('<think>') and '</think>' in content %}
|
| 342 |
+
{%- set _think_end = '</think>' %}
|
| 343 |
+
{%- elif content.startswith('<thinking>') and '</thinking>' in content %}
|
| 344 |
+
{%- set _think_end = '</thinking>' %}
|
| 345 |
+
{%- endif %}
|
| 346 |
+
{%- if _think_end %}
|
| 347 |
+
{%- if 'thinking' in _think_end %}
|
| 348 |
+
{%- set _think_start = '<thinking>' %}
|
| 349 |
+
{%- else %}
|
| 350 |
+
{%- set _think_start = '<think>' %}
|
| 351 |
+
{%- endif %}
|
| 352 |
+
{%- set reasoning_content = content.split(_think_end)[0].rstrip('\n') %}
|
| 353 |
+
{%- if _think_start in reasoning_content %}
|
| 354 |
+
{%- set reasoning_content = reasoning_content.split(_think_start)[-1].lstrip('\n') %}
|
| 355 |
+
{%- endif %}
|
| 356 |
+
{%- set content = content.split(_think_end)[-1].lstrip('\n') %}
|
| 357 |
+
{%- endif %}
|
| 358 |
+
{%- endif %}
|
| 359 |
+
{%- set reasoning_content = reasoning_content | trim %}
|
| 360 |
+
{%- if (_preserve_thinking or loop.index0 > ns.last_query_index) %}
|
| 361 |
+
{{- '<|im_start|>assistant\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 362 |
+
{%- else %}
|
| 363 |
+
{{- '<|im_start|>assistant\n' + content }}
|
| 364 |
+
{%- endif %}
|
| 365 |
+
{%- if message.tool_calls is defined and message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 366 |
+
{%- for tool_call in message.tool_calls %}
|
| 367 |
+
{%- if tool_call.function is defined and tool_call.function is not none %}
|
| 368 |
+
{%- set tc = tool_call.function %}
|
| 369 |
+
{%- else %}
|
| 370 |
+
{%- set tc = tool_call %}
|
| 371 |
+
{%- endif %}
|
| 372 |
+
{%- set tc_name = tc.name if (tc.name is defined and tc.name is not none) else '' %}
|
| 373 |
+
{%- if _tool_format == 'json' %}
|
| 374 |
+
{%- if loop.first %}
|
| 375 |
+
{%- if content | trim %}
|
| 376 |
+
{{- '\n\n' }}
|
| 377 |
+
{%- endif %}
|
| 378 |
+
{%- else %}
|
| 379 |
+
{{- '\n' }}
|
| 380 |
+
{%- endif %}
|
| 381 |
+
{%- set _args = '{}' %}
|
| 382 |
+
{%- if tc.arguments is defined and tc.arguments is not none %}
|
| 383 |
+
{%- if tc.arguments is mapping %}
|
| 384 |
+
{%- set _args = tc.arguments | tojson %}
|
| 385 |
+
{%- elif tc.arguments is string %}
|
| 386 |
+
{%- if tc.arguments %}
|
| 387 |
+
{%- set _args = tc.arguments %}
|
| 388 |
+
{%- endif %}
|
| 389 |
+
{%- else %}
|
| 390 |
+
{%- set _args = tc.arguments | tojson %}
|
| 391 |
+
{%- endif %}
|
| 392 |
+
{%- endif %}
|
| 393 |
+
{{- '<tool_call>\n{"name": ' }}{{- tc_name | tojson }}{{- ', "arguments": ' }}{{- _args }}{{- '}\n</tool_call>' }}
|
| 394 |
+
{%- else %}
|
| 395 |
+
{%- if loop.first %}
|
| 396 |
+
{%- if content | trim %}
|
| 397 |
+
{{- '\n\n<tool_call>\n<function=' + tc_name + '>\n' }}
|
| 398 |
+
{%- else %}
|
| 399 |
+
{{- '<tool_call>\n<function=' + tc_name + '>\n' }}
|
| 400 |
+
{%- endif %}
|
| 401 |
+
{%- else %}
|
| 402 |
+
{{- '\n<tool_call>\n<function=' + tc_name + '>\n' }}
|
| 403 |
+
{%- endif %}
|
| 404 |
+
{%- if tc.arguments is defined and tc.arguments is not none %}
|
| 405 |
+
{%- if tc.arguments is mapping %}
|
| 406 |
+
{%- for args_name, args_value in tc.arguments.items() %}
|
| 407 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 408 |
+
{%- if args_value is string %}
|
| 409 |
+
{%- set _av = args_value %}
|
| 410 |
+
{%- else %}
|
| 411 |
+
{%- set _av = args_value | tojson %}
|
| 412 |
+
{%- endif %}
|
| 413 |
+
{%- if max_tool_arg_chars > 0 and _av | length > max_tool_arg_chars %}
|
| 414 |
+
{{- _av[:max_tool_arg_chars] + '\n[TRUNCATED - original length ' ~ (_av | length | string) ~ ' chars]' }}
|
| 415 |
+
{%- else %}
|
| 416 |
+
{{- _av }}
|
| 417 |
+
{%- endif %}
|
| 418 |
+
{{- '\n</parameter>\n' }}
|
| 419 |
+
{%- endfor %}
|
| 420 |
+
{%- else %}
|
| 421 |
+
{%- if tc.arguments is string %}
|
| 422 |
+
{%- set _raw_args = tc.arguments %}
|
| 423 |
+
{%- else %}
|
| 424 |
+
{%- set _raw_args = tc.arguments | tojson %}
|
| 425 |
+
{%- endif %}
|
| 426 |
+
{%- if _raw_args %}
|
| 427 |
+
{%- if max_tool_arg_chars > 0 and _raw_args | length > max_tool_arg_chars %}
|
| 428 |
+
{{- _raw_args[:max_tool_arg_chars] + '\n[TRUNCATED - original length ' ~ (_raw_args | length | string) ~ ' chars]' }}
|
| 429 |
+
{%- else %}
|
| 430 |
+
{{- _raw_args }}
|
| 431 |
+
{%- endif %}
|
| 432 |
+
{%- endif %}
|
| 433 |
+
{%- endif %}
|
| 434 |
+
{%- endif %}
|
| 435 |
+
{{- '</function>\n</tool_call>' }}
|
| 436 |
+
{%- endif %}
|
| 437 |
+
{%- endfor %}
|
| 438 |
+
{%- endif %}
|
| 439 |
+
{{- '<|im_end|>\n' }}
|
| 440 |
+
{%- elif message.role == 'tool' %}
|
| 441 |
+
{%- set _content_lower = content | lower %}
|
| 442 |
+
{%- set _content_head = _content_lower[:120] %}
|
| 443 |
+
{%- set _is_code_or_grep = ('throw new ' in _content_lower or 'throw error' in _content_lower or 'console.error' in _content_lower or 'logger.error' in _content_lower or 'logging.error' in _content_lower or 'import ' in _content_head or 'def ' in _content_head or 'function ' in _content_head) %}
|
| 444 |
+
{%- set _exit_code_zero = ('exit code: 0' in _content_head or 'process exited with code 0' in _content_head) %}
|
| 445 |
+
{%- set _error_field_ok = ('"error": null' in _content_head or '"error":null' in _content_head or '"error": false' in _content_head or '"error":false' in _content_head or '"error": ""' in _content_head or '"error":""' in _content_head) %}
|
| 446 |
+
{%- set _strong_error = (('"error":' in _content_head and not _error_field_ok) or '"status": "error"' in _content_head or '"status":"error"' in _content_head or 'traceback (most recent call last):' in _content_head or 'command not found' in _content_head or 'invalid syntax' in _content_head or 'fatal:' in _content_head or (('exit code: ' in _content_head or 'process exited with code' in _content_head) and not _exit_code_zero) or _content_head.startswith('exception:') or _content_head.startswith('failed to ')) %}
|
| 447 |
+
{%- set _weak_error = ('error:' in _content_head or 'err!' in _content_head) %}
|
| 448 |
+
{%- set _weak_suppressed = ('$ ' in _content_head or 'took ' in _content_head or content | length >= 600) %}
|
| 449 |
+
{%- if not _is_code_or_grep and (_strong_error or (_weak_error and not _weak_suppressed)) %}
|
| 450 |
+
{%- set ns2.consecutive_failures = ns2.consecutive_failures + 1 %}
|
| 451 |
+
{%- else %}
|
| 452 |
+
{%- set ns2.consecutive_failures = 0 %}
|
| 453 |
+
{%- endif %}
|
| 454 |
+
{%- if ns2.prev_role != 'tool' %}
|
| 455 |
+
{{- '<|im_start|>user' }}
|
| 456 |
+
{%- endif %}
|
| 457 |
+
{%- set _is_json_payload = (_tool_format == 'json' and content | trim | length > 0 and (content | trim)[:1] in ('{', '[')) %}
|
| 458 |
+
{%- if not _is_json_payload and max_tool_response_chars > 0 and content | length > max_tool_response_chars %}
|
| 459 |
+
{%- set content = content[:max_tool_response_chars] + '\n[TRUNCATED - original length ' ~ (content | length | string) ~ ' chars]' %}
|
| 460 |
+
{%- endif %}
|
| 461 |
+
{{- '\n<tool_response>\n' + content }}
|
| 462 |
+
{%- if ns2.consecutive_failures >= 2 %}
|
| 463 |
+
{{- '\n\n⚠️ SYSTEM WARNING: ' ~ ns2.consecutive_failures ~ ' consecutive tool errors detected. Your previous approach is incorrect. You MUST use a fundamentally different approach or corrected arguments.' }}
|
| 464 |
+
{%- elif ns2.consecutive_failures == 1 %}
|
| 465 |
+
{{- '\n\n⚠️ SYSTEM WARNING: The previous tool call returned an error. Diagnose the failure and retry with completely corrected arguments.' }}
|
| 466 |
+
{%- endif %}
|
| 467 |
+
{{- '\n</tool_response>' }}
|
| 468 |
+
{%- if loop.last %}
|
| 469 |
+
{{- '<|im_end|>\n' }}
|
| 470 |
+
{%- else %}
|
| 471 |
+
{%- set _next_role = _msgs[loop.index0 + 1].role %}
|
| 472 |
+
{%- if _next_role != 'tool' %}
|
| 473 |
+
{{- '<|im_end|>\n' }}
|
| 474 |
+
{%- endif %}
|
| 475 |
+
{%- endif %}
|
| 476 |
+
{%- else %}
|
| 477 |
+
{{- '<|im_start|>user\n[' + message.role + ']: ' + content + '<|im_end|>\n' }}
|
| 478 |
+
{%- endif %}
|
| 479 |
+
{%- set ns2.prev_role = message.role %}
|
| 480 |
+
{%- endfor %}
|
| 481 |
+
{%- if add_generation_prompt %}
|
| 482 |
+
{{- '<|im_start|>assistant\n' }}
|
| 483 |
+
{%- if not ns_state.thinking %}
|
| 484 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 485 |
+
{%- else %}
|
| 486 |
+
{{- '<think>\n' }}
|
| 487 |
+
{%- endif %}
|
| 488 |
+
{%- endif %}
|
indexed88-v6.4-135k-r2/selected_88064_135k_v64_40_R2.i32le
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b578828c0b517ba47abe90a130fda7cde5a56d94add1afeac7623e7c8f6234b4
|
| 3 |
+
size 352256
|
indexed88-v6.4-135k-r2/thinkingcap-135000-q8-repack.ninfer
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df1ab1bfc8dc4ac119b3c064993423f3e4f351796db43468f4180b2e20ab7ad6
|
| 3 |
+
size 15820439556
|