eugenehp commited on
Commit
dbcd650
Β·
verified Β·
1 Parent(s): da15109

Upload folder using huggingface_hub

Browse files
Files changed (34) hide show
  1. .DS_Store +0 -0
  2. .gitattributes +24 -0
  3. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-BF16.gguf +3 -0
  4. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F16.gguf +3 -0
  5. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F32.gguf +3 -0
  6. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ3_M.gguf +3 -0
  7. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ3_S.gguf +3 -0
  8. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ4_NL.gguf +3 -0
  9. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ4_XS.gguf +3 -0
  10. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q2_K.gguf +3 -0
  11. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_L.gguf +3 -0
  12. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_M.gguf +3 -0
  13. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_S.gguf +3 -0
  14. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_0.gguf +3 -0
  15. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_1.gguf +3 -0
  16. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_K_M.gguf +3 -0
  17. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_K_S.gguf +3 -0
  18. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_0.gguf +3 -0
  19. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_1.gguf +3 -0
  20. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_K_M.gguf +3 -0
  21. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_K_S.gguf +3 -0
  22. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q6_K.gguf +3 -0
  23. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q8_0.gguf +3 -0
  24. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-TQ1_0.gguf +3 -0
  25. Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-TQ2_0.gguf +3 -0
  26. README.md +139 -3
  27. SHA256SUMS +13 -0
  28. chat_template.jinja +88 -0
  29. config.json +146 -0
  30. processor_config.json +63 -0
  31. scripts/convert_to_gguf.sh +269 -0
  32. scripts/verify_gguf.sh +221 -0
  33. tokenizer.json +3 -0
  34. tokenizer_config.json +34 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
.gitattributes CHANGED
@@ -33,3 +33,27 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-BF16.gguf filter=lfs diff=lfs merge=lfs -text
37
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F16.gguf filter=lfs diff=lfs merge=lfs -text
38
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F32.gguf filter=lfs diff=lfs merge=lfs -text
39
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ3_M.gguf filter=lfs diff=lfs merge=lfs -text
40
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ3_S.gguf filter=lfs diff=lfs merge=lfs -text
41
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ4_NL.gguf filter=lfs diff=lfs merge=lfs -text
42
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ4_XS.gguf filter=lfs diff=lfs merge=lfs -text
43
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
44
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text
45
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
46
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_S.gguf filter=lfs diff=lfs merge=lfs -text
47
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
48
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_1.gguf filter=lfs diff=lfs merge=lfs -text
49
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
50
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text
51
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_0.gguf filter=lfs diff=lfs merge=lfs -text
52
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_1.gguf filter=lfs diff=lfs merge=lfs -text
53
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
54
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text
55
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
56
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
57
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-TQ1_0.gguf filter=lfs diff=lfs merge=lfs -text
58
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-TQ2_0.gguf filter=lfs diff=lfs merge=lfs -text
59
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-BF16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75d11ed29b7b8a7976d21c3cd6891791c4fd3b80194b50ef799ee82082550ad8
3
+ size 53808277728
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1bc9edc8d6520dd3be0f7630cd97599d1dfd1fb7048b087d0c10b1ae2643427f
3
+ size 53808277728
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F32.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fadcacce33789c7537e275e9f4aa8e4e9effff5444b50f2ed28c6d31f7b1e30
3
+ size 107594983648
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ3_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7c8ca7a96a936fa2bce7c653ac7b7c75af036b0a24adebb0d814578246f4525
3
+ size 12580870368
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ3_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:926c3a7a3a600910732f35131bf36a61bf51998b924e6ca6b6aaa5acfb69aa2e
3
+ size 12419324128
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ4_NL.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:976cf75e4de43702cd50ec8a2b4be398ee8b0d782c947d84549933c10cf8e5f1
3
+ size 15891052768
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ4_XS.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d90520006ac14e968ee2bdcc67073d642a50a26d8852cd1fc81376d835c7b86f
3
+ size 15193913568
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:315187ba637f08c81b16794a32133ca7ef6c54f45e13e917aff016017358ee61
3
+ size 10711660768
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_L.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:179e62572403b040e63e8e125888ddd485d1cbfbacaee6d1ef9039714b2f9255
3
+ size 14344771808
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c0c2e2fbf559d62fc870ba4af1a0eb33bde592b9dfecf720b2d55f325d72a2a
3
+ size 13301438688
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q3_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5ea1d643f27b19cd8b476f4c65eda279415f5822f16b9af0f0275896bee63c2
3
+ size 12073949408
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a4b5b98b638ab76bc5a79bd8d453bc4f1f71d21bebcfb80a7619d776dea35c9
3
+ size 15476865248
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37705abf793b140a8c141b88114497e4b887cb23a8def835b7909ec46dc32764
3
+ size 17078237408
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4787c3f7241c1cbb38ca5d69104b51acdf42bf2357892f476a2d4022b7f9c004
3
+ size 16547395808
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q4_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca6e16c8db6c8e5d6016f8c0e888dbc8d2efdc0911e47fd15ab1c8b5c6c94ec5
3
+ size 15586310368
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5221d3ea5879717782024d29734972e0c7dec820c2c7a21d42f3f9487818a625
3
+ size 18679609568
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78f4196934add1bf85f3c2be5139378b2384dc5adc83d33fe8c88d6bbf53c613
3
+ size 20280981728
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34bb9278a13f92e68f7ec6c0470637e9e84a49c6aba33167e9ff5a27edcb5a01
3
+ size 19231095008
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q5_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c013aa2c1223c76e49c4202c665a3f3432d79b8f7d9c17f7f7434e20bfb2f8d
3
+ size 18679609568
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e95c10adf07a26f122f36d3e89d38ec74b465cd4ccf6a70d6dde43575da6e7ff
3
+ size 22082525408
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6a383ae8ea725cd39568da0b6d58f3c6c521c55ecde0ae3eeb02ee0ac0e8e0a
3
+ size 28595759328
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-TQ1_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da8ef7d5a3018e4db10e4406cebb1918b5a64a62ea0b168aa249fb6c1ba7977e
3
+ size 6916122848
Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-TQ2_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:766bbf1215bded9624a1aec5c2f5adeeee391cf431e24ff696ce81398fe53cac
3
+ size 8057555168
README.md CHANGED
@@ -1,3 +1,139 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - zh
5
+ license: apache-2.0
6
+ base_model: Qwen/Qwen3.5-27B
7
+ tags:
8
+ - unsloth
9
+ - qwen
10
+ - qwen3.5
11
+ - reasoning
12
+ - chain-of-thought
13
+ - Dense
14
+ pipeline_tag: text-generation
15
+ datasets:
16
+ - nohurry/Opus-4.6-Reasoning-3000x-filtered
17
+ - Jackrong/Qwen3.5-reasoning-700x
18
+ ---
19
+
20
+ # 🌟 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-GGUF
21
+
22
+ > πŸ“’ **Release Note**
23
+ > **Build Environment Upgrades:**
24
+ > - **Distilled and quantized on 2026.3.12**
25
+ > - **Fine-tuning Framework**: **Unsloth 2026.3.3**
26
+ > - **Core Dependencies**: **Transformers 5.2.0**
27
+ > - This model fixes the crash in the official model caused by the Jinja template not supporting the **"developer"** role. (commonly sent by modern coding agents like Claude Code and OpenCode)
28
+ > - It does **not disable thinking mode by default**, and allowing the agent to run continuously for **over 9 minutes without interruption**.
29
+ > - Compared to the original model, **autonomy and stability are significantly improved**.
30
+
31
+ ![HB8AleUaMAArNyM](https://cdn-uploads.huggingface.co/production/uploads/66309bd090589b7c65950665/GHkMJL6I383eIwK1qj80K.jpeg)
32
+
33
+
34
+ ## πŸ’‘ Model Introduction
35
+ **Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled** is a highly capable reasoning model fine-tuned on top of the powerful Qwen3.5 architecture. The model's core directive is to leverage state-of-the-art Chain-of-Thought (CoT) distillation primarily sourced from Claude-4.6 Opus interactions.
36
+
37
+ Through Supervised Fine-Tuning (SFT) focusing specifically on structured reasoning logic, this model excels in breaking down complex user problems, planning step-by-step methodologies within strictly formatted `<think>` tags, and ultimately delivering precise, nuanced solutions.
38
+
39
+ ### 🧠 Example of Learned Reasoning Scaffold(ExampleοΌ‰
40
+
41
+ The model includes targeted optimizations addressing Qwen3.5’s tendency toward excessive transitional or repetitive reasoning on simple queries. Through deep distillation and structural imitation of Claude-4.6-Opus reasoning chains, the model adopts a more efficient structured thinking pattern:
42
+ **β€œLet me analyze this request carefully: 1..2..3...”.**
43
+ This streamlined reasoning paradigm significantly reduces redundant cognitive loops while preserving deep analytical capacity, resulting in substantially improved inference efficiency.
44
+
45
+ ```text
46
+ Let me analyze this request carefully:
47
+
48
+ 1. Identify the core objective of the problem.
49
+ 2. Break the task into clearly defined subcomponents.
50
+ 3. Evaluate constraints and edge cases.
51
+ 4. Formulate a step-by-step solution plan.
52
+ 5. Execute the reasoning sequentially and verify consistency.
53
+ .
54
+ .
55
+ .
56
+ ```
57
+
58
+ ## πŸ—ΊοΈ Training Pipeline Overview
59
+
60
+ ```text
61
+ Base Model (Qwen3.5-27B)
62
+ β”‚
63
+ β–Ό
64
+ Supervised Fine-Tuning (SFT) + LoRA
65
+ β”‚
66
+ β–Ό
67
+ Final Model (Claude-4.6-Opus-Reasoning-Distilled,text-only)
68
+ ```
69
+
70
+ ## πŸ“‹ Stage Details
71
+
72
+ πŸ”₯**Community-tested advantages** (benchmark tests by user @sudoingX on a single RTX 3090):
73
+
74
+ Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled shows significant advantages in coding-agent environments such as Claude Code and OpenCode:
75
+
76
+ >- **Native support for the β€œdeveloper” role**, requiring no Jinja template patches or ChatML workarounds.
77
+ >- **Thinking mode fully preserved** (logs confirm `thinking=1`), not silently disabled, maintaining the complete chain-of-thought reasoning process.
78
+ >- **Greatly improved autonomy and stability** β€” capable of running continuously for **over 9 minutes autonomously** (with zero human intervention). It actively waits for tool responses, reads outputs, self-corrects errors, and can even automatically generate a README, whereas the base model often stalls or freezes mid-execution.
79
+
80
+ >**Hardware usage remains unchanged:**
81
+ >- About **16.5 GB VRAM** with **Q4_K_M** quantization
82
+ >- **29–35 tok/s** generation speed
83
+ >- **Full 262K context** with no compromises
84
+
85
+ - These improvements come from successfully distilling the **structured reasoning style of Claude 4.6 Opus**, allowing Qwopus to be truly **plug-and-play in modern local coding agents** and deliver an experience close to Opus in smoothness and usability.
86
+
87
+ **Thanks to the community for the in-depth testing and feedback!**
88
+
89
+
90
+ ### πŸ”Ή Supervised Fine-Tuning (SFT)
91
+ - **Objective:** To inject high-density reasoning logic and establish a strict format for problem-solving involving an internal thinking state prior to outputting the final response.
92
+ - **Methodology:** We utilized **Unsloth** for highly efficient memory and compute optimization. A critical component of this stage is the `train_on_responses_only` strategy, masking instructions so the loss is purely calculated over the generation of the `<think>` sequences and the subsequent solutions.
93
+ - **Format Enforcement:** All training samples were systematically normalized so the model strictly abides by the structure `<think> {internal reasoning} </think>\n {final answer}`.
94
+
95
+ ### πŸ“š All Datasets Used
96
+ The dataset consists of high-quality, filtered reasoning distillation data:
97
+
98
+ | Dataset Name | Description / Purpose |
99
+ |--------------|-----------------------|
100
+ | [nohurry/Opus-4.6-Reasoning-3000x-filtered](https://huggingface.co/datasets/nohurry/Opus-4.6-Reasoning-3000x-filtered) | Provides comprehensive Claude 4.6 Opus reasoning trajectories. |
101
+ | [TeichAI/claude-4.5-opus-high-reasoning-250x](https://huggingface.co/datasets/TeichAI/claude-4.5-opus-high-reasoning-250x) | Injecting high-intensity, structured reasoning instances. |
102
+ | [Jackrong/Qwen3.5-reasoning-700x](https://huggingface.co/datasets/Jackrong/Qwen3.5-reasoning-700x) | Additional curated reasoning samples designed to strengthen structured step-by-step problem solving and improve reasoning diversity. |
103
+
104
+ ## 🌟 Core Skills & Capabilities
105
+ 1. **Modular & Structured Thinking:** Inheriting traits from Opus-level reasoning, the model demonstrates confident parsing of the prompt, establishing an outlined plan in its `<think>` block sequentially rather than exploratory "trial-and-error" self-doubt.
106
+
107
+ ## ⚠️ Limitations & Intended Use
108
+ - **Hallucination Risk:** While reasoning is strong, the model remains an autoregressive LLM; external facts provided during the thinking sequence may occasionally contain hallucinations if verifying real-world events.
109
+ - **Intended Scenario:** Best suited for offline analytical tasks, coding, math, and heavy logic-dependent prompting where the user needs to transparently follow the AI's internal logic.
110
+ - **Preview Version Notice:** Because this model is relatively new and intentionally lightweight, the surrounding ecosystem β€” including inference templates, fine-tuning pipelines, routing configurations, and tooling integrations β€” may not yet be fully mature or standardized. As a result, users may encounter occasional bugs, compatibility inconsistencies, or integration edge cases. The current release should be considered a preview build while the broader architectural stack and supporting utilities continue to stabilize and improve.
111
+
112
+ ## πŸ™ Acknowledgements
113
+ Significant thanks to the [Unsloth AI](https://unsloth.ai/) team for making rapid fine-tuning of MoE and large LLM models accessible. Additionally, we acknowledge Qwen internally, and the open-source community developers producing exceptional distilled datasets (`nohurry` and `TeichAI`).
114
+
115
+ ## πŸ“– Citation
116
+
117
+ If you use this model in your research or projects, please cite:
118
+
119
+ ```bibtex
120
+ @misc{jackrong_qwen35_opus_distilled,
121
+ title = {Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-GGUF},
122
+ author = {Eugene Hauptmann},
123
+ year = {2026},
124
+ publisher = {Hugging Face},
125
+ howpublished = {\url{https://huggingface.co/eugenehp/Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-GGUF}}
126
+ }
127
+ ```
128
+
129
+ Original weights:
130
+
131
+ ```bibtex
132
+ @misc{jackrong_qwen35_opus_distilled,
133
+ title = {Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled},
134
+ author = {Jackrong},
135
+ year = {2026},
136
+ publisher = {Hugging Face},
137
+ howpublished = {\url{https://huggingface.co/Jackrong/Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled}}
138
+ }
139
+ ```
SHA256SUMS ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 75d11ed29b7b8a7976d21c3cd6891791c4fd3b80194b50ef799ee82082550ad8 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-BF16.gguf
2
+ 75d11ed29b7b8a7976d21c3cd6891791c4fd3b80194b50ef799ee82082550ad8 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-BF16.gguf
3
+ 75d11ed29b7b8a7976d21c3cd6891791c4fd3b80194b50ef799ee82082550ad8 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-BF16.gguf
4
+ 75d11ed29b7b8a7976d21c3cd6891791c4fd3b80194b50ef799ee82082550ad8 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-BF16.gguf
5
+ 1bc9edc8d6520dd3be0f7630cd97599d1dfd1fb7048b087d0c10b1ae2643427f Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F16.gguf
6
+ 8fadcacce33789c7537e275e9f4aa8e4e9effff5444b50f2ed28c6d31f7b1e30 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F32.gguf
7
+ f7c8ca7a96a936fa2bce7c653ac7b7c75af036b0a24adebb0d814578246f4525 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ3_M.gguf
8
+ 926c3a7a3a600910732f35131bf36a61bf51998b924e6ca6b6aaa5acfb69aa2e Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ3_S.gguf
9
+ 976cf75e4de43702cd50ec8a2b4be398ee8b0d782c947d84549933c10cf8e5f1 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ4_NL.gguf
10
+ d90520006ac14e968ee2bdcc67073d642a50a26d8852cd1fc81376d835c7b86f Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-IQ4_XS.gguf
11
+ 75d11ed29b7b8a7976d21c3cd6891791c4fd3b80194b50ef799ee82082550ad8 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-BF16.gguf
12
+ 1bc9edc8d6520dd3be0f7630cd97599d1dfd1fb7048b087d0c10b1ae2643427f Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F16.gguf
13
+ 8fadcacce33789c7537e275e9f4aa8e4e9effff5444b50f2ed28c6d31f7b1e30 Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled-F32.gguf
chat_template.jinja ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant
86
+ <think>
87
+ ' }}
88
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "bos_token_id": null,
6
+ "torch_dtype": "bfloat16",
7
+ "eos_token_id": 248046,
8
+ "image_token_id": 248056,
9
+ "model_name": "qwen/Qwen3.5-27B",
10
+ "model_type": "qwen3_5",
11
+ "pad_token_id": 248044,
12
+ "text_config": {
13
+ "attention_bias": false,
14
+ "attention_dropout": 0.0,
15
+ "attn_output_gate": true,
16
+ "bos_token_id": null,
17
+ "torch_dtype": "bfloat16",
18
+ "eos_token_id": 248044,
19
+ "full_attention_interval": 4,
20
+ "head_dim": 256,
21
+ "hidden_act": "silu",
22
+ "hidden_size": 5120,
23
+ "initializer_range": 0.02,
24
+ "intermediate_size": 17408,
25
+ "layer_types": [
26
+ "linear_attention",
27
+ "linear_attention",
28
+ "linear_attention",
29
+ "full_attention",
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "full_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "full_attention",
38
+ "linear_attention",
39
+ "linear_attention",
40
+ "linear_attention",
41
+ "full_attention",
42
+ "linear_attention",
43
+ "linear_attention",
44
+ "linear_attention",
45
+ "full_attention",
46
+ "linear_attention",
47
+ "linear_attention",
48
+ "linear_attention",
49
+ "full_attention",
50
+ "linear_attention",
51
+ "linear_attention",
52
+ "linear_attention",
53
+ "full_attention",
54
+ "linear_attention",
55
+ "linear_attention",
56
+ "linear_attention",
57
+ "full_attention",
58
+ "linear_attention",
59
+ "linear_attention",
60
+ "linear_attention",
61
+ "full_attention",
62
+ "linear_attention",
63
+ "linear_attention",
64
+ "linear_attention",
65
+ "full_attention",
66
+ "linear_attention",
67
+ "linear_attention",
68
+ "linear_attention",
69
+ "full_attention",
70
+ "linear_attention",
71
+ "linear_attention",
72
+ "linear_attention",
73
+ "full_attention",
74
+ "linear_attention",
75
+ "linear_attention",
76
+ "linear_attention",
77
+ "full_attention",
78
+ "linear_attention",
79
+ "linear_attention",
80
+ "linear_attention",
81
+ "full_attention",
82
+ "linear_attention",
83
+ "linear_attention",
84
+ "linear_attention",
85
+ "full_attention",
86
+ "linear_attention",
87
+ "linear_attention",
88
+ "linear_attention",
89
+ "full_attention"
90
+ ],
91
+ "linear_conv_kernel_dim": 4,
92
+ "linear_key_head_dim": 128,
93
+ "linear_num_key_heads": 16,
94
+ "linear_num_value_heads": 48,
95
+ "linear_value_head_dim": 128,
96
+ "mamba_ssm_dtype": "float32",
97
+ "max_position_embeddings": 262144,
98
+ "mlp_only_layers": [],
99
+ "model_type": "qwen3_5_text",
100
+ "mtp_num_hidden_layers": 1,
101
+ "mtp_use_dedicated_embeddings": false,
102
+ "num_attention_heads": 24,
103
+ "num_hidden_layers": 64,
104
+ "num_key_value_heads": 4,
105
+ "pad_token_id": null,
106
+ "partial_rotary_factor": 0.25,
107
+ "rms_norm_eps": 1e-06,
108
+ "rope_parameters": {
109
+ "mrope_interleaved": true,
110
+ "mrope_section": [
111
+ 11,
112
+ 11,
113
+ 10
114
+ ],
115
+ "partial_rotary_factor": 0.25,
116
+ "rope_theta": 10000000,
117
+ "rope_type": "default"
118
+ },
119
+ "tie_word_embeddings": false,
120
+ "use_cache": true,
121
+ "vocab_size": 248320
122
+ },
123
+ "tie_word_embeddings": false,
124
+ "unsloth_version": "2026.3.3",
125
+ "use_cache": false,
126
+ "video_token_id": 248057,
127
+ "vision_config": {
128
+ "deepstack_visual_indexes": [],
129
+ "depth": 27,
130
+ "torch_dtype": "bfloat16",
131
+ "hidden_act": "gelu_pytorch_tanh",
132
+ "hidden_size": 1152,
133
+ "in_channels": 3,
134
+ "initializer_range": 0.02,
135
+ "intermediate_size": 4304,
136
+ "model_type": "qwen3_5",
137
+ "num_heads": 16,
138
+ "num_position_embeddings": 2304,
139
+ "out_hidden_size": 5120,
140
+ "patch_size": 16,
141
+ "spatial_merge_size": 2,
142
+ "temporal_patch_size": 2
143
+ },
144
+ "vision_end_token_id": 248054,
145
+ "vision_start_token_id": 248053
146
+ }
processor_config.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "data_format": "channels_first",
4
+ "do_convert_rgb": true,
5
+ "do_normalize": true,
6
+ "do_rescale": true,
7
+ "do_resize": true,
8
+ "image_mean": [
9
+ 0.5,
10
+ 0.5,
11
+ 0.5
12
+ ],
13
+ "image_processor_type": "Qwen2VLImageProcessorFast",
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "merge_size": 2,
20
+ "patch_size": 16,
21
+ "resample": 3,
22
+ "rescale_factor": 0.00392156862745098,
23
+ "size": {
24
+ "longest_edge": 16777216,
25
+ "shortest_edge": 65536
26
+ },
27
+ "temporal_patch_size": 2
28
+ },
29
+ "processor_class": "Qwen3VLProcessor",
30
+ "video_processor": {
31
+ "data_format": "channels_first",
32
+ "default_to_square": true,
33
+ "do_convert_rgb": true,
34
+ "do_normalize": true,
35
+ "do_rescale": true,
36
+ "do_resize": true,
37
+ "do_sample_frames": true,
38
+ "fps": 2,
39
+ "image_mean": [
40
+ 0.5,
41
+ 0.5,
42
+ 0.5
43
+ ],
44
+ "image_std": [
45
+ 0.5,
46
+ 0.5,
47
+ 0.5
48
+ ],
49
+ "max_frames": 768,
50
+ "merge_size": 2,
51
+ "min_frames": 4,
52
+ "patch_size": 16,
53
+ "resample": 3,
54
+ "rescale_factor": 0.00392156862745098,
55
+ "return_metadata": false,
56
+ "size": {
57
+ "longest_edge": 25165824,
58
+ "shortest_edge": 4096
59
+ },
60
+ "temporal_patch_size": 2,
61
+ "video_processor_type": "Qwen3VLVideoProcessor"
62
+ }
63
+ }
scripts/convert_to_gguf.sh ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ #=============================================================================
5
+ # Convert Jackrong/Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled to GGUF
6
+ #
7
+ # Produces ALL quantization variants from a single F16 GGUF base.
8
+ #
9
+ # Prerequisites:
10
+ # - Python 3.10+
11
+ # - pip packages: numpy torch transformers sentencepiece safetensors gguf protobuf
12
+ # - llama.cpp repo cloned (for convert_hf_to_gguf.py and llama-quantize)
13
+ #
14
+ # Usage:
15
+ # ./convert_to_gguf.sh # all quants, default llama.cpp path
16
+ # ./convert_to_gguf.sh /path/to/llama.cpp # all quants, custom llama.cpp path
17
+ #=============================================================================
18
+
19
+ MODEL_REPO="Jackrong/Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled"
20
+ MODEL_NAME="Qwen3.5-27B-Claude-4.6-Opus-Reasoning-Distilled"
21
+ LLAMA_CPP_DIR="${1:-$HOME/Desktop/llama.cpp}"
22
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
23
+ OUTPUT_DIR="${SCRIPT_DIR}/gguf_output"
24
+
25
+ # ─── Every quantization type supported by llama-quantize ─────────────────────
26
+ # Sorted roughly by bits-per-weight (smallest β†’ largest)
27
+ QUANT_TYPES=(
28
+ # ~1-2 bpw β€” extreme compression
29
+ IQ1_S # 1.56 bpw
30
+ IQ1_M # 1.75 bpw
31
+ TQ1_0 # 1.69 bpw ternary
32
+ TQ2_0 # 2.06 bpw ternary
33
+ IQ2_XXS # 2.06 bpw
34
+ IQ2_XS # 2.31 bpw
35
+ IQ2_S # 2.5 bpw
36
+ IQ2_M # 2.7 bpw
37
+
38
+ # ~3 bpw
39
+ Q2_K # 2.96G @ 8B, +3.52 ppl
40
+ Q2_K_S # 2.96G @ 8B, +3.18 ppl
41
+ IQ3_XXS # 3.06 bpw
42
+ IQ3_XS # 3.3 bpw
43
+ IQ3_S # 3.44 bpw
44
+ IQ3_M # 3.66 bpw
45
+ Q3_K_S # 3.41G @ 8B, +1.63 ppl
46
+ Q3_K_M # 3.74G @ 8B, +0.66 ppl
47
+ Q3_K_L # 4.03G @ 8B, +0.56 ppl
48
+
49
+ # ~4 bpw β€” sweet spot
50
+ IQ4_XS # 4.25 bpw
51
+ IQ4_NL # 4.50 bpw
52
+ Q4_0 # 4.34G @ 8B, +0.47 ppl
53
+ Q4_1 # 4.78G @ 8B, +0.45 ppl
54
+ Q4_K_S # 4.37G @ 8B, +0.27 ppl
55
+ Q4_K_M # 4.58G @ 8B, +0.18 ppl ← popular default
56
+
57
+ # ~5 bpw
58
+ Q5_0 # 5.21G @ 8B, +0.13 ppl
59
+ Q5_1 # 5.65G @ 8B, +0.11 ppl
60
+ Q5_K_S # 5.21G @ 8B, +0.10 ppl
61
+ Q5_K_M # 5.33G @ 8B, +0.06 ppl
62
+
63
+ # ~6-8 bpw β€” high fidelity
64
+ Q6_K # 6.14G @ 8B, +0.02 ppl
65
+ Q8_0 # 7.96G @ 8B, +0.003 ppl
66
+
67
+ # Full precision (format conversion only)
68
+ BF16 # 14G @ 7B
69
+ F16 # 14G @ 7B
70
+ F32 # 26G @ 7B
71
+ )
72
+
73
+ echo "============================================="
74
+ echo " HuggingFace β†’ GGUF Conversion Script"
75
+ echo "============================================="
76
+ echo " Model: $MODEL_REPO"
77
+ echo " llama.cpp: $LLAMA_CPP_DIR"
78
+ echo " Output dir: $OUTPUT_DIR"
79
+ echo " Quant types: ${#QUANT_TYPES[@]} variants"
80
+ echo "============================================="
81
+
82
+ #-----------------------------------------------------------------------------
83
+ # Step 0: Validate llama.cpp directory
84
+ #-----------------------------------------------------------------------------
85
+ if [ ! -f "$LLAMA_CPP_DIR/convert_hf_to_gguf.py" ]; then
86
+ echo "❌ convert_hf_to_gguf.py not found in $LLAMA_CPP_DIR"
87
+ echo " Clone llama.cpp first: git clone https://github.com/ggml-org/llama.cpp.git"
88
+ exit 1
89
+ fi
90
+
91
+ #-----------------------------------------------------------------------------
92
+ # Step 1: Resolve model from HF cache, local dir, or download
93
+ #-----------------------------------------------------------------------------
94
+ echo ""
95
+ echo "β–Ά Step 1: Resolving model files..."
96
+
97
+ HF_CACHE_DIR="$HOME/.cache/huggingface/hub"
98
+ MODEL_CACHE="$HF_CACHE_DIR/models--$(echo "$MODEL_REPO" | tr '/' '--')"
99
+ MODEL_DIR=""
100
+
101
+ # Helper: check if a directory has config.json + at least one .safetensors
102
+ has_model_files() {
103
+ local dir="$1"
104
+ [ -f "$dir/config.json" ] && \
105
+ [ "$(find "$dir" -maxdepth 1 -name '*.safetensors' 2>/dev/null | head -1)" != "" ]
106
+ }
107
+
108
+ # 1) Check HF cache snapshots
109
+ if [ -d "$MODEL_CACHE/snapshots" ]; then
110
+ SNAPSHOT=$(ls -t "$MODEL_CACHE/snapshots" 2>/dev/null | head -1)
111
+ if [ -n "$SNAPSHOT" ]; then
112
+ CANDIDATE="$MODEL_CACHE/snapshots/$SNAPSHOT"
113
+ if has_model_files "$CANDIDATE"; then
114
+ MODEL_DIR="$CANDIDATE"
115
+ echo " Found complete model in HF cache: $MODEL_DIR"
116
+ else
117
+ echo " HF cache exists but is incomplete (missing safetensors or config.json)"
118
+ fi
119
+ fi
120
+ fi
121
+
122
+ # 2) Check local model_hf directory (from a previous download)
123
+ if [ -z "$MODEL_DIR" ] && has_model_files "${SCRIPT_DIR}/model_hf"; then
124
+ MODEL_DIR="${SCRIPT_DIR}/model_hf"
125
+ echo " Found complete model in local dir: $MODEL_DIR"
126
+ fi
127
+
128
+ # 3) Nothing found β€” download everything
129
+ if [ -z "$MODEL_DIR" ]; then
130
+ MODEL_DIR="${SCRIPT_DIR}/model_hf"
131
+ echo " ⬇ No complete model found locally. Downloading from HuggingFace..."
132
+ echo " Repo: $MODEL_REPO"
133
+ echo " Dest: $MODEL_DIR"
134
+ echo ""
135
+ python3 -c "
136
+ from huggingface_hub import snapshot_download
137
+ path = snapshot_download(
138
+ '$MODEL_REPO',
139
+ local_dir='$MODEL_DIR',
140
+ resume_download=True,
141
+ )
142
+ print(f' βœ… Downloaded to: {path}')
143
+ "
144
+ echo ""
145
+
146
+ # Verify the download actually worked
147
+ if ! has_model_files "$MODEL_DIR"; then
148
+ echo "❌ Download finished but model files are still missing."
149
+ echo " Expected config.json and *.safetensors in: $MODEL_DIR"
150
+ echo ""
151
+ echo " Contents:"
152
+ ls -la "$MODEL_DIR" 2>/dev/null || echo " (directory does not exist)"
153
+ exit 1
154
+ fi
155
+ fi
156
+
157
+ SAFETENSOR_COUNT=$(find "$MODEL_DIR" -maxdepth 1 -name "*.safetensors" 2>/dev/null | wc -l)
158
+ TOTAL_SIZE=$(du -sh "$MODEL_DIR"/*.safetensors 2>/dev/null | tail -1 | cut -f1)
159
+ echo " Found config.json and $SAFETENSOR_COUNT safetensor shard(s) (~${TOTAL_SIZE:-?} total)"
160
+
161
+ #-----------------------------------------------------------------------------
162
+ # Step 2: Convert to F16 GGUF (base for all quantizations)
163
+ #-----------------------------------------------------------------------------
164
+ echo ""
165
+ echo "β–Ά Step 2: Converting safetensors β†’ GGUF (F16 base)..."
166
+
167
+ mkdir -p "$OUTPUT_DIR"
168
+ F16_GGUF="$OUTPUT_DIR/${MODEL_NAME}-F16.gguf"
169
+
170
+ if [ -f "$F16_GGUF" ]; then
171
+ echo " F16 GGUF already exists, skipping conversion."
172
+ else
173
+ python3 "$LLAMA_CPP_DIR/convert_hf_to_gguf.py" \
174
+ "$MODEL_DIR" \
175
+ --outfile "$F16_GGUF" \
176
+ --outtype f16
177
+
178
+ echo " βœ… Created: $F16_GGUF"
179
+ fi
180
+
181
+ F16_SIZE=$(du -h "$F16_GGUF" | cut -f1)
182
+ echo " F16 size: $F16_SIZE"
183
+
184
+ #-----------------------------------------------------------------------------
185
+ # Step 3: Build llama-quantize if needed
186
+ #-----------------------------------------------------------------------------
187
+ echo ""
188
+ echo "β–Ά Step 3: Ensuring llama-quantize is built..."
189
+
190
+ QUANTIZE_BIN="$LLAMA_CPP_DIR/build/bin/llama-quantize"
191
+ if [ ! -f "$QUANTIZE_BIN" ]; then
192
+ echo " Building llama-quantize..."
193
+ pushd "$LLAMA_CPP_DIR" > /dev/null
194
+ cmake -B build -DCMAKE_BUILD_TYPE=Release 2>&1 | tail -3
195
+ cmake --build build --target llama-quantize -j"$(nproc)" 2>&1 | tail -5
196
+ popd > /dev/null
197
+
198
+ if [ ! -f "$QUANTIZE_BIN" ]; then
199
+ echo "❌ Failed to build llama-quantize"
200
+ exit 1
201
+ fi
202
+ fi
203
+ echo " βœ… llama-quantize ready: $QUANTIZE_BIN"
204
+
205
+ #-----------------------------------------------------------------------------
206
+ # Step 4: Quantize ALL variants
207
+ #-----------------------------------------------------------------------------
208
+ echo ""
209
+ echo "β–Ά Step 4: Quantizing ${#QUANT_TYPES[@]} variants..."
210
+ echo ""
211
+
212
+ SUCCEEDED=0
213
+ FAILED=0
214
+ SKIPPED=0
215
+ FAILED_LIST=()
216
+
217
+ for QTYPE in "${QUANT_TYPES[@]}"; do
218
+ QUANT_GGUF="$OUTPUT_DIR/${MODEL_NAME}-${QTYPE}.gguf"
219
+
220
+ # Skip F16 since that's our base file
221
+ if [ "$QTYPE" = "F16" ]; then
222
+ echo " [SKIP] $QTYPE β€” already created as base"
223
+ SKIPPED=$((SKIPPED + 1))
224
+ continue
225
+ fi
226
+
227
+ # Skip if already exists
228
+ if [ -f "$QUANT_GGUF" ]; then
229
+ SIZE=$(du -h "$QUANT_GGUF" | cut -f1)
230
+ echo " [SKIP] $QTYPE β€” already exists ($SIZE)"
231
+ SKIPPED=$((SKIPPED + 1))
232
+ continue
233
+ fi
234
+
235
+ echo -n " [QUANT] $QTYPE ... "
236
+ if "$QUANTIZE_BIN" "$F16_GGUF" "$QUANT_GGUF" "$QTYPE" > "$OUTPUT_DIR/.quantize_${QTYPE}.log" 2>&1; then
237
+ SIZE=$(du -h "$QUANT_GGUF" | cut -f1)
238
+ echo "βœ… ($SIZE)"
239
+ SUCCEEDED=$((SUCCEEDED + 1))
240
+ else
241
+ echo "❌ FAILED (see $OUTPUT_DIR/.quantize_${QTYPE}.log)"
242
+ FAILED=$((FAILED + 1))
243
+ FAILED_LIST+=("$QTYPE")
244
+ fi
245
+ done
246
+
247
+ #-----------------------------------------------------------------------------
248
+ # Summary
249
+ #-----------------------------------------------------------------------------
250
+ echo ""
251
+ echo "============================================="
252
+ echo " βœ… Conversion complete!"
253
+ echo "============================================="
254
+ echo ""
255
+ echo " Results: $SUCCEEDED succeeded, $SKIPPED skipped, $FAILED failed"
256
+ if [ ${#FAILED_LIST[@]} -gt 0 ]; then
257
+ echo " Failed: ${FAILED_LIST[*]}"
258
+ fi
259
+ echo ""
260
+ echo " Output directory: $OUTPUT_DIR"
261
+ echo ""
262
+ echo " Files:"
263
+ echo " ─────"
264
+ ls -lhS "$OUTPUT_DIR"/*.gguf 2>/dev/null | awk '{printf " %-12s %s\n", $5, $NF}'
265
+ echo ""
266
+ echo " Test with llama.cpp:"
267
+ echo " $LLAMA_CPP_DIR/build/bin/llama-cli -m $OUTPUT_DIR/${MODEL_NAME}-Q4_K_M.gguf -p 'Hello!' -n 128"
268
+ echo "============================================="
269
+
scripts/verify_gguf.sh ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ export PYTHONPATH=$HOME/Desktop/llama.cpp/gguf-py
5
+
6
+ # ──────────────────────────────────────────────────────────────
7
+ # Verify GGUF files
8
+ # - Metadata
9
+ # - Tensor inventory (optional, skips if missing)
10
+ # - SHA256 hash
11
+ # - Smoke-test inference
12
+ # - Perplexity (optional)
13
+ # Usage:
14
+ # ./verify_gguf.sh [--perplexity] [file1.gguf file2.gguf ...]
15
+ # ──────────────────────────────────────────────────────────────
16
+
17
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
18
+ LLAMA_CPP_DIR="${LLAMA_CPP_DIR:-$HOME/Desktop/llama.cpp}"
19
+ OUTPUT_DIR="${SCRIPT_DIR}/gguf_output"
20
+ GGUF_PY_DIR="$LLAMA_CPP_DIR/gguf-py"
21
+ RUN_PERPLEXITY=false
22
+ TARGETS=()
23
+
24
+ # Add gguf-py to PYTHONPATH
25
+ export PYTHONPATH="$GGUF_PY_DIR:$PYTHONPATH"
26
+
27
+ # Detect number of CPU cores
28
+ if command -v nproc >/dev/null 2>&1; then
29
+ NPROC=$(nproc)
30
+ else
31
+ NPROC=$(sysctl -n hw.ncpu)
32
+ fi
33
+
34
+ # ─── Parse arguments ─────────────────────────────────────────────
35
+ while [[ $# -gt 0 ]]; do
36
+ case "$1" in
37
+ --perplexity|--ppl|--all)
38
+ RUN_PERPLEXITY=true
39
+ shift
40
+ ;;
41
+ --llama-cpp)
42
+ LLAMA_CPP_DIR="$2"
43
+ GGUF_PY_DIR="$LLAMA_CPP_DIR/gguf-py"
44
+ shift 2
45
+ ;;
46
+ *)
47
+ TARGETS+=("$1")
48
+ shift
49
+ ;;
50
+ esac
51
+ done
52
+
53
+ # ─── If no targets, find all GGUFs in output dir ───────────────
54
+ if [ ${#TARGETS[@]} -eq 0 ]; then
55
+ while IFS= read -r f; do
56
+ TARGETS+=("$f")
57
+ done < <(find "$OUTPUT_DIR" -name "*.gguf" -type f | sort)
58
+ fi
59
+
60
+ if [ ${#TARGETS[@]} -eq 0 ]; then
61
+ echo "❌ No GGUF files found in $OUTPUT_DIR"
62
+ exit 1
63
+ fi
64
+
65
+ # ─── Build llama-cli / llama-perplexity if missing ─────────────
66
+ CLI_BIN="$LLAMA_CPP_DIR/build/bin/llama-cli"
67
+ PPL_BIN="$LLAMA_CPP_DIR/build/bin/llama-perplexity"
68
+
69
+ build_target() {
70
+ local target="$1"
71
+ local bin="$LLAMA_CPP_DIR/build/bin/$target"
72
+ if [ ! -f "$bin" ]; then
73
+ echo " Building $target..."
74
+ pushd "$LLAMA_CPP_DIR" > /dev/null
75
+ cmake -B build -DCMAKE_BUILD_TYPE=Release 2>&1 | tail -1
76
+ cmake --build build --target "$target" -j"$NPROC" 2>&1 | tail -3
77
+ popd > /dev/null
78
+ fi
79
+ }
80
+
81
+ build_target "llama-cli"
82
+ if $RUN_PERPLEXITY; then
83
+ build_target "llama-perplexity"
84
+ fi
85
+
86
+ # ─── Begin verification ────────────────────────────────────────
87
+ PASS=0
88
+ FAIL=0
89
+
90
+ echo "============================================="
91
+ echo " GGUF Verification"
92
+ echo "============================================="
93
+ echo " Files to check: ${#TARGETS[@]}"
94
+ echo " Perplexity: $RUN_PERPLEXITY"
95
+ echo "============================================="
96
+ echo ""
97
+
98
+ for GGUF_FILE in "${TARGETS[@]}"; do
99
+ BASENAME=$(basename "$GGUF_FILE")
100
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
101
+ echo " $BASENAME"
102
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
103
+
104
+ # Skip empty or missing files
105
+ if [ ! -s "$GGUF_FILE" ]; then
106
+ echo " ⚠️ Skipping empty or missing file"
107
+ FAIL=$((FAIL+1))
108
+ continue
109
+ fi
110
+
111
+ FILE_SIZE=$(du -h "$GGUF_FILE" | cut -f1)
112
+ echo " Size: $FILE_SIZE"
113
+ echo ""
114
+
115
+ FILE_OK=true
116
+
117
+ # ── Check 1: Metadata ─────────────────────────────
118
+ echo " β”Œβ”€ [1/4] Metadata"
119
+ if METADATA=$(python3 "$GGUF_PY_DIR/gguf/scripts/gguf_dump.py" "$GGUF_FILE" --no-tensors 2>&1); then
120
+ ARCH=$(echo "$METADATA" | sed -n 's/.*general\.architecture *= *\([^ ]*\).*/\1/p' | head -1)
121
+ QTYPE=$(echo "$METADATA" | sed -n 's/.*general\.file_type *= *\(.*\)/\1/p' | head -1)
122
+ CTX=$(echo "$METADATA" | sed -n 's/.*context_length *= *\([^ ]*\).*/\1/p' | head -1)
123
+ NLAYER=$(echo "$METADATA" | sed -n 's/.*block_count *= *\([^ ]*\).*/\1/p' | head -1)
124
+ VOCAB=$(echo "$METADATA" | sed -n 's/.*tokens.*length *= *\([^ ]*\).*/\1/p' | head -1)
125
+ echo " β”‚ Architecture: ${ARCH:-?}"
126
+ echo " β”‚ File type: ${QTYPE:-?}"
127
+ echo " β”‚ Context length: ${CTX:-?}"
128
+ echo " β”‚ Layers: ${NLAYER:-?}"
129
+ echo " β”‚ Vocab size: ${VOCAB:-?}"
130
+ echo " β”‚ βœ… Metadata OK"
131
+ else
132
+ echo " β”‚ ❌ Failed to read metadata"
133
+ echo " β”‚ $METADATA" | head -5
134
+ FILE_OK=false
135
+ # Skip tensor check if metadata fails
136
+ SKIP_TENSORS=true
137
+ fi
138
+ echo " β”‚"
139
+
140
+ # ── Check 2: Tensor inventory ─────────────────────
141
+ echo " β”œβ”€ [2/4] Tensor inventory"
142
+ if [ "${SKIP_TENSORS:-false}" = true ]; then
143
+ echo " β”‚ ⚠️ Skipping tensors due to missing metadata"
144
+ else
145
+ if TENSOR_INFO=$(python3 "$GGUF_PY_DIR/gguf/scripts/gguf_dump.py" "$GGUF_FILE" --json 2>/dev/null); then
146
+ if [ -z "$TENSOR_INFO" ]; then
147
+ echo " β”‚ ⚠️ Tensor info empty, skipping"
148
+ else
149
+ TENSOR_COUNT=$(echo "$TENSOR_INFO" | python3 -c "
150
+ import sys, json
151
+ data = json.load(sys.stdin)
152
+ tensors = data.get('tensors', [])
153
+ print(len(tensors))
154
+ " 2>/dev/null || echo "?")
155
+
156
+ echo " β”‚ Total tensors: ${TENSOR_COUNT:-?}"
157
+ echo " β”‚ βœ… Tensors OK"
158
+ fi
159
+ else
160
+ echo " β”‚ ⚠️ Failed to parse tensor JSON, skipping"
161
+ fi
162
+ fi
163
+ echo " β”‚"
164
+
165
+ # ── Check 3: SHA256 hash ──────────────────────────
166
+ echo " β”œβ”€ [3/4] SHA256 hash"
167
+ if command -v shasum >/dev/null 2>&1; then
168
+ HASH=$(shasum -a 256 "$GGUF_FILE" | cut -d' ' -f1)
169
+ else
170
+ HASH=$(sha256sum "$GGUF_FILE" | cut -d' ' -f1)
171
+ fi
172
+ echo " β”‚ $HASH"
173
+ echo " β”‚ βœ… Hash computed"
174
+ echo "$HASH $BASENAME" >> "$OUTPUT_DIR/SHA256SUMS"
175
+ echo " β”‚"
176
+
177
+ # ── Check 4: Smoke-test inference ───────────────
178
+ echo " └─ [4/4] Smoke-test inference"
179
+ if [ ! -s "$GGUF_FILE" ]; then
180
+ echo " ⚠️ File empty or missing weights, skipping inference"
181
+ FILE_OK=false
182
+ else
183
+ SMOKE_OUTPUT=$("$CLI_BIN" -m "$GGUF_FILE" -p "The capital of France is" -n 20 -r "" --no-display-prompt --seed 42 --temp 0.0 --threads 4 --log-disable 2>&1) || FILE_OK=false
184
+ TOKEN_COUNT=$(echo "$SMOKE_OUTPUT" | wc -w)
185
+ PREVIEW=$(echo "$SMOKE_OUTPUT" | head -3 | sed 's/^/ β”‚ > /')
186
+ echo "$PREVIEW"
187
+ if [ "$TOKEN_COUNT" -gt 0 ]; then
188
+ echo " β”‚ βœ… Generated $TOKEN_COUNT words"
189
+ else
190
+ echo " β”‚ ⚠️ Empty output"
191
+ fi
192
+ fi
193
+ echo ""
194
+
195
+ # ── Summary per file ─────────────────────────────
196
+ if $FILE_OK; then
197
+ echo " βœ… $BASENAME β€” ALL CHECKS PASSED"
198
+ PASS=$((PASS + 1))
199
+ else
200
+ echo " ❌ $BASENAME β€” SOME CHECKS FAILED"
201
+ FAIL=$((FAIL + 1))
202
+ fi
203
+ echo ""
204
+ done
205
+
206
+ # ─── Final summary ─────────────────────────────────────────────
207
+ echo "============================================="
208
+ echo " Verification Summary"
209
+ echo "============================================="
210
+ echo " Passed: $PASS"
211
+ echo " Failed: $FAIL"
212
+ echo " Total: ${#TARGETS[@]}"
213
+ if [ -f "$OUTPUT_DIR/SHA256SUMS" ]; then
214
+ sort -u -o "$OUTPUT_DIR/SHA256SUMS" "$OUTPUT_DIR/SHA256SUMS"
215
+ echo ""
216
+ echo " SHA256 checksums saved to:"
217
+ echo " $OUTPUT_DIR/SHA256SUMS"
218
+ fi
219
+ echo "============================================="
220
+
221
+ exit $FAIL
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87a7830d63fcf43bf241c3c5242e96e62dd3fdc29224ca26fed8ea333db72de4
3
+ size 19989343
tokenizer_config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": false,
13
+ "model_max_length": 262144,
14
+ "model_specific_special_tokens": {
15
+ "audio_bos_token": "<|audio_start|>",
16
+ "audio_eos_token": "<|audio_end|>",
17
+ "audio_token": "<|audio_pad|>",
18
+ "image_token": "<|image_pad|>",
19
+ "video_token": "<|video_pad|>",
20
+ "vision_bos_token": "<|vision_start|>",
21
+ "vision_eos_token": "<|vision_end|>"
22
+ },
23
+ "pad_token": "<|endoftext|>",
24
+ "padding_side": "right",
25
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
26
+ "processor_class": "Qwen3VLProcessor",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "TokenizersBackend",
29
+ "unk_token": null,
30
+ "video_token": "<|video_pad|>",
31
+ "vision_bos_token": "<|vision_start|>",
32
+ "vision_eos_token": "<|vision_end|>",
33
+ "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n {%- if message.content is string %}\n {%- set content = message.content %}\n {%- else %}\n {%- set content = '' %}\n {%- endif %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- if loop.index0 > ns.last_query_index %}\n {%- if loop.last or (not loop.last and reasoning_content) %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content.strip('\\n') + '\\n</think>\\n\\n' + content.lstrip('\\n') }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\n<think>\n' }}\n{%- endif %}"
34
+ }