Johnblick187 commited on
Commit
8a99bba
Β·
verified Β·
1 Parent(s): c521889

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +131 -0
README.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - merge
7
+ - custom-merge
8
+ - layer-wise-merge
9
+ - depth-aligned-merge
10
+ - coding
11
+ - code-generation
12
+ - abliterated
13
+ - reasoning
14
+ - qwen3
15
+ - qwen3-coder
16
+ - reap
17
+ - moe
18
+ base_model:
19
+ - huihui-ai/Huihui-Qwen3.5-27B-Claude-4.6-Opus-abliterated
20
+ - Youssofal/Qwen3.6-35B-A3B-Abliterated-Heretic-BF16
21
+ - lovedheart/Qwen3-Coder-Next-REAP-40B-A3B
22
+ language:
23
+ - en
24
+ ---
25
+
26
+ # Heretic-5Q3-Nexus-Coder
27
+
28
+ A 3-way layer-wise weighted merge of Qwopus (reasoning), Heretic (abliterated backbone), and REAP-pruned Qwen3-Coder-Next. Built around a single structural insight: **when merging across differently-sized architectures, aligning layers by index instead of by function wastes most of the contributing model's capability.**
29
+
30
+ This merge fixes that with a depth offset.
31
+
32
+ ## The core problem
33
+
34
+ Most naive 3-way merges do something like this:
35
+
36
+ merged_layer[N] = 0.5 * base[N] + 0.3 * reasoning[N] + 0.2 * coder[N]
37
+
38
+ That works when all three models have the same layer count. It falls apart the moment they don't.
39
+
40
+ In this merge, the base (Heretic, 35B-A3B) has fewer layers than the contributing coder (REAP-pruned Qwen3-Coder-Next, 40B). If you merge layer 10 of the coder into layer 10 of the base, you are combining two *functionally different* positions: layer 10 of the 40B is still in its mid-reasoning stretch, while layer 10 of the 35B is closer to its output generation. The coder's actual code-generation expertise lives in its later layers and never makes it into the output positions of the merged model.
41
+
42
+ The result of a naive merge is that the coder contribution structurally misfires β€” it shows up in the wrong positions and degrades performance rather than improving it.
43
+
44
+ ## The fix: CODER_OFFSET
45
+
46
+ When writing to output layer N, pull the coder contribution from layer N + 8:
47
+
48
+ CODER_OFFSET = 8
49
+ coder_layer_idx = output_layer_idx + CODER_OFFSET
50
+ coder_key = key.replace(f".{output_layer_idx}.", f".{coder_layer_idx}.")
51
+
52
+ This aligns the coder's actual output-stage behavior (its last third of layers) with where the merged model needs output-stage code generation. The coder no longer fights the base β€” it reinforces it at the right depth.
53
+
54
+ Aligning by function, not by index, is the thesis of this merge.
55
+
56
+ ## Weight schedule
57
+
58
+ Each of the three components contributes differently at different depths of the output model, matched to where that model's strength actually lives:
59
+
60
+ | Layer range | Qwopus | Heretic | REAP Coder | Rationale |
61
+ |-------------|--------|---------|------------|-----------|
62
+ | 0-13 (early) | 48% | 32% | 20% | Reasoning priors and attention patterns emerge early |
63
+ | 14-27 (mid) | 40% | 28% | 32% | Balanced semantic processing |
64
+ | 28-39 (late) | 30% | 22% | 48% | Code generation is an output-side skill |
65
+
66
+ Qwopus dominates early because reasoning structure is a precondition for everything downstream. REAP Coder dominates late because that's where generation actually happens. Heretic threads through the whole stack as the abliterated structural backbone that holds it all together.
67
+
68
+ ## Why it survives Q4
69
+
70
+ Process integrity under compression is not accidental. Most bad merges lose self-correction and spiral when they start going wrong. This one holds because the depth offset ensures reasoning-critical capability lands in layers where it can withstand aggressive quantization β€” rather than being distributed to positions where it would be lost first.
71
+
72
+ ## Components
73
+
74
+ - **Qwopus** β€” [huihui-ai/Huihui-Qwen3.5-27B-Claude-4.6-Opus-abliterated](https://huggingface.co/huihui-ai/Huihui-Qwen3.5-27B-Claude-4.6-Opus-abliterated) β€” reasoning depth, self-correcting thought traces
75
+ - **Heretic** β€” [Youssofal/Qwen3.6-35B-A3B-Abliterated-Heretic-BF16](https://huggingface.co/Youssofal/Qwen3.6-35B-A3B-Abliterated-Heretic-BF16) β€” abliterated structural backbone
76
+ - **REAP Coder** β€” [lovedheart/Qwen3-Coder-Next-REAP-40B-A3B](https://huggingface.co/lovedheart/Qwen3-Coder-Next-REAP-40B-A3B) β€” REAP-pruned Qwen3-Coder-Next
77
+
78
+ ## Observed behavior at Q4_K_M
79
+
80
+ Tested with a production-grade FastAPI prompt asking for a Discord webhook endpoint with Ed25519 signature validation, asyncpg connection pooling, pydantic-settings configuration, and proper error handling.
81
+
82
+ The model demonstrated:
83
+
84
+ - Correct cryptographic library selection (pynacl for Discord's Ed25519 signatures)
85
+ - Cross-referenced Discord's official Go SDK example from memory to double-check signature format
86
+ - Replay attack prevention via timestamp window check (5-minute tolerance)
87
+ - Constant-time comparison awareness for signature verification
88
+ - Correct HTTP status code differentiation (401 for bad signature, 500 for DB errors)
89
+ - Self-correction when entering a token loop mid-generation: "Wait, I got tangled. Let's reset and write carefully."
90
+
91
+ The reasoning layer survives Q4 quantization β€” thought blocks remain coherent and the model catches its own drift rather than spiraling.
92
+
93
+ ## Quants
94
+
95
+ - Q4_K_M β€” recommended for 24GB+ systems
96
+ - Q8_0 β€” coming, for 48GB+ systems
97
+ - Q5_K_M and Q3_K_M β€” coming
98
+
99
+ ## Recommended Ollama Modelfile
100
+
101
+ FROM ./heretic-nexus-coder-Q4_K_M.gguf
102
+ PARAMETER temperature 0.8
103
+ PARAMETER top_p 0.95
104
+ PARAMETER top_k 40
105
+ PARAMETER repeat_penalty 1.15
106
+ PARAMETER num_ctx 4096
107
+ PARAMETER num_predict 2048
108
+
109
+ The repeat_penalty is important β€” without it the reasoning loops can reinforce themselves and get stuck. 1.15 gives enough pressure to break loops without harming output quality.
110
+
111
+ ## Merge script
112
+
113
+ Full implementation: [kingtweak69/Merging](https://github.com/kingtweak69/Merging/blob/main/Reap-merge.py)
114
+
115
+ Executed in Google Colab on an A100 with CPU offloading due to combined model size. This is a custom 3-way interpolation, not a mergekit recipe, because mergekit does not currently support cross-architecture layer offset as a first-class parameter.
116
+
117
+ ## Credits
118
+
119
+ - [Huihui-AI](https://huggingface.co/huihui-ai) β€” Qwopus abliteration work
120
+ - [Youssofal](https://huggingface.co/Youssofal) β€” Heretic abliterated base
121
+ - [lovedheart](https://huggingface.co/lovedheart) β€” REAP-pruned Coder-Next variant
122
+ - [Qwen Team](https://huggingface.co/Qwen) β€” Qwen3 base architecture
123
+ - REAP pruning methodology from the original paper authors
124
+
125
+ ## Intended use
126
+
127
+ Agentic coding, personal developer tooling, security research, local coding assistants. Built for people who want reasoning and code generation without refusal overhead in scenarios where refusals are obstructive rather than protective. Not intended for generating content that causes real-world harm.
128
+
129
+ ## Built by
130
+
131
+ [@tweakbrazy](https://huggingface.co/Johnblick187) / King Tweak β€” part of the TweakBotAI.tools ecosystem. Merge designed and executed on mobile via Colab, deployed on Contabo VPS via Termius.