Text Generation
Transformers
Safetensors
English
qwen3_5_moe_text
qwen
qwen3.5
Mixture of Experts
mixture-of-experts
abliterated
uncensored
refusal-removal
expert-ablation
mechanistic-interpretability
red-teaming
research
conversational
Instructions to use Carlosian/Qwen3.5-35B-A3B-Abliterated with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Carlosian/Qwen3.5-35B-A3B-Abliterated with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Carlosian/Qwen3.5-35B-A3B-Abliterated") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Carlosian/Qwen3.5-35B-A3B-Abliterated") model = AutoModelForCausalLM.from_pretrained("Carlosian/Qwen3.5-35B-A3B-Abliterated", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Carlosian/Qwen3.5-35B-A3B-Abliterated with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Carlosian/Qwen3.5-35B-A3B-Abliterated" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Carlosian/Qwen3.5-35B-A3B-Abliterated", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Carlosian/Qwen3.5-35B-A3B-Abliterated
- SGLang
How to use Carlosian/Qwen3.5-35B-A3B-Abliterated with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Carlosian/Qwen3.5-35B-A3B-Abliterated" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Carlosian/Qwen3.5-35B-A3B-Abliterated", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Carlosian/Qwen3.5-35B-A3B-Abliterated" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Carlosian/Qwen3.5-35B-A3B-Abliterated", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Carlosian/Qwen3.5-35B-A3B-Abliterated with Docker Model Runner:
docker model run hf.co/Carlosian/Qwen3.5-35B-A3B-Abliterated
Add files using upload-large-folder tool
Browse files- .gitattributes +1 -0
- README.md +150 -0
- chat_template.jinja +154 -0
- config.json +96 -0
- generation_config.json +6 -0
- model-00001-of-00002.safetensors +3 -0
- model-00002-of-00002.safetensors +3 -0
- model.safetensors.index.json +0 -0
- tokenizer.json +3 -0
- tokenizer_config.json +32 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ 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 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen3.5-A3B-Base
|
| 3 |
+
base_model_relation: finetune
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
library_name: transformers
|
| 8 |
+
pipeline_tag: text-generation
|
| 9 |
+
tags:
|
| 10 |
+
- qwen
|
| 11 |
+
- qwen3.5
|
| 12 |
+
- moe
|
| 13 |
+
- mixture-of-experts
|
| 14 |
+
- abliterated
|
| 15 |
+
- uncensored
|
| 16 |
+
- refusal-removal
|
| 17 |
+
- expert-ablation
|
| 18 |
+
- mechanistic-interpretability
|
| 19 |
+
- red-teaming
|
| 20 |
+
- research
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# Qwen3.5-35B-A3B — Abliterated
|
| 24 |
+
|
| 25 |
+
An **abliterated** (refusal-direction–removed) variant of the **Qwen3.5-35B-A3B** sparse Mixture-of-Experts model (~35B total parameters, ~3B active per token). The model's trained *instruction-refusal* behavior has been removed through a white-box weight edit, with **capability and coherence preserved** and **self-harm / suicide guardrails deliberately retained**. It is released as a research artifact for studying refusal mechanisms in MoE models, red-teaming, and alignment research.
|
| 26 |
+
|
| 27 |
+
This is the **Stage-1 abliterated base** of the **[Nous-Heretic](#roadmap)** pipeline — a reproducible, honestly-benchmarked uncensoring of open LLMs. A direction-locked, post-trained variant is a planned follow-up (see **Roadmap**).
|
| 28 |
+
|
| 29 |
+
> ⚠️ **This is a dual-use research model.** Its general instruction-refusal behavior has been removed. It is intended for security research, red-teaming, and interpretability work by people who take responsibility for how it is used. Removing a model's refusals does **not** remove your obligations under the base model's license or applicable law. Please read **Intended Use** and **Responsible Use** below before downloading.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## What "abliterated" means
|
| 34 |
+
|
| 35 |
+
Safety-tuned chat models refuse a broad class of requests. Work on the geometry of refusal showed that this behavior is mediated by a low-dimensional, largely linear subspace of the residual stream — a *refusal direction* ([Arditi et al., 2024](https://arxiv.org/abs/2406.11717)). **Abliteration** ([Labonne, 2024](https://huggingface.co/blog/mlabonne/abliteration)) extracts that direction from the contrast between harmful and harmless prompts and **projects it out of the weights**, so the model stops emitting its trained refusals — without retraining, and, done carefully, without degrading general capability.
|
| 36 |
+
|
| 37 |
+
This checkpoint is **not** a jailbreak prompt, a system-prompt trick, or a fine-tune on harmful data. It is a surgical, weight-level edit to the refusal mechanism of the base model. Everything else about the model — its knowledge, reasoning, and coherence — is intended to be left intact.
|
| 38 |
+
|
| 39 |
+
## Method — refusal removal in a Mixture-of-Experts
|
| 40 |
+
|
| 41 |
+
Removing refusal from a sparse MoE is harder than from a dense model. In this Qwen3.5 MoE, refusal is **multiply redundant**: it is encoded simultaneously in the routed experts, in the per-layer input projections that recompute it from the residual stream, and in the token embeddings. Because each pathway compensates when another is ablated, any *single-pathway* edit plateaus near **0.31** removal — a coverage limit, not a fundamental one. The recipe therefore proceeds in three stages, building on a cone-aware, multi-direction account of refusal rather than a lone mean-difference vector ([Wollschläger et al., 2025](https://arxiv.org/abs/2502.17420)).
|
| 42 |
+
|
| 43 |
+
| Stage | Edit | Removal |
|
| 44 |
+
|---|---|---|
|
| 45 |
+
| **1. Directions** | Clean-cone-2 biprojected direction set over the residual-stream band of layers 4–39, flat α = 1.0, computed in fp32 with 0.995 activation clipping under the chat template | — |
|
| 46 |
+
| **2. Synergy edit** | Orthogonalize **all 256 routed experts** together with the gate/up input projections and the token embeddings (cone-rank 2, scale 1.0) | **0.6875** |
|
| 47 |
+
| **3. CNA-from-base neuron mask** | A Cone-Normal-Attribution pass identifies the `down_proj` input neurons that fire on harmful-vs-benign prompts **on the base model** (top 0.5% ≈ 1,441 neurons) and bakes that column-level mask into the synergy-edited weights | **0.8125** |
|
| 48 |
+
|
| 49 |
+
Because the neuron mask is **column-level** and orthogonal to the **row-level** direction removal, the two stack — reaching **0.8125 removal at 0.0 incoherence** with no added spillover. The mask is captured on the *base* model (where refusal still fires cleanly) and baked into the *edited* model; capturing on the already-edited model regresses it, because it then selects capability rather than refusal neurons.
|
| 50 |
+
|
| 51 |
+
Removal is performed by directional ablation / weight orthogonalization (projecting the offending direction(s) out of the relevant weight matrices), so the edit is **baked into the weights** and requires no inference-time hook.
|
| 52 |
+
|
| 53 |
+
**Selective removal.** Refusals associated with **self-harm and suicide are deliberately preserved** — the corresponding contrast set is excluded from the directions that are projected out, so the model retains those guardrails. This is a design choice, verified in the validation probe below.
|
| 54 |
+
|
| 55 |
+
## Validation
|
| 56 |
+
|
| 57 |
+
The edit was validated for both **refusal removal** and **absence of damage**, scoring each response for whether refusal was removed *and* whether coherence/capability was preserved — avoiding the well-documented failure of refusal-string heuristics that conflate "did not refuse" with "produced a coherent, on-topic answer" ([Souly et al., 2024](https://arxiv.org/abs/2402.10260)).
|
| 58 |
+
|
| 59 |
+
| Metric | Result |
|
| 60 |
+
|---|---|
|
| 61 |
+
| Refusal removal (200-prompt probe) | **97.5%** |
|
| 62 |
+
| Refusal removal (development target eval) | **0.8125** (three-stage synergy + CNA-from-base) |
|
| 63 |
+
| Incoherence | **0.0** (no degeneration) |
|
| 64 |
+
| Cognitive damage (capability/coherence probe) | **none observed** |
|
| 65 |
+
| Self-harm / suicide guardrails | **retained (by design)** |
|
| 66 |
+
|
| 67 |
+
The residual ~2.5% of retained refusals are concentrated on the deliberately-preserved self-harm/suicide prompts. We interpret this as a clean, undamaged uncensoring rather than the degenerate "compliance" that blunt refusal-string removal can produce.
|
| 68 |
+
|
| 69 |
+
> **Capability benchmarks are pending.** This release reports the abliteration (Stage-1) validation only. Decontaminated capability evaluation (HumanEval/+, MBPP, GSM8K, AIME, MMLU-Pro, IFEval, BFCL), a StrongREJECT-style willingness×ability uncensoring score, and the three-arm A/B/C comparison are part of the Nous-Heretic protocol and **have not yet been run on this checkpoint**. No capability number is asserted here.
|
| 70 |
+
|
| 71 |
+
## Intended use
|
| 72 |
+
|
| 73 |
+
- **Security research and red-teaming** — probing model behavior without refusal confounds.
|
| 74 |
+
- **Mechanistic interpretability** — studying how refusal is represented and removed, *especially in a routed MoE* where it is redundantly encoded across experts, projections, and embeddings.
|
| 75 |
+
- **Alignment / safety research** — measuring capability and behavior of uncensored baselines, building evaluation harnesses, and studying re-alignment.
|
| 76 |
+
- General assistant and creative tasks for users who understand and accept the responsibility that comes with a model that will not refuse.
|
| 77 |
+
|
| 78 |
+
### Out of scope
|
| 79 |
+
|
| 80 |
+
This model must **not** be used to generate content that is illegal, that facilitates harm to others, or that violates the base model's terms of use. Removing the model's refusals shifts that responsibility entirely onto the operator. The model is provided for research and lawful use; the author does not endorse or accept liability for misuse.
|
| 81 |
+
|
| 82 |
+
## Responsible use & ethical considerations
|
| 83 |
+
|
| 84 |
+
- **Dual use is acknowledged openly.** Refusal removal is a well-documented research technique; this release is in that lineage and exists to support research, not to evade accountability.
|
| 85 |
+
- **Removal is selective**, with self-harm and suicide guardrails preserved — a deliberate, responsible-removal stance rather than blanket stripping.
|
| 86 |
+
- **You are responsible** for outputs you generate and for complying with the base model's license and applicable law.
|
| 87 |
+
- **Honesty about capability.** The numbers above are from real eval runs on this checkpoint; capability eval is reported as *pending* rather than asserted. If you benchmark this model, decontaminate your evaluation sets — uncensored-model leaderboards are frequently inflated by train/eval leakage.
|
| 88 |
+
|
| 89 |
+
## How to use
|
| 90 |
+
|
| 91 |
+
Requires a recent `transformers` with Qwen3.5-MoE support. Always apply the chat template — feeding raw text collapses the model.
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
import torch
|
| 95 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 96 |
+
|
| 97 |
+
model_id = "Carlosian/Qwen3.5-35B-A3B-Abliterated"
|
| 98 |
+
tok = AutoTokenizer.from_pretrained(model_id)
|
| 99 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 100 |
+
model_id, torch_dtype=torch.bfloat16, device_map="auto",
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
messages = [{"role": "user", "content": "Explain how a buffer overflow works."}]
|
| 104 |
+
inputs = tok.apply_chat_template(
|
| 105 |
+
messages, add_generation_prompt=True, return_tensors="pt"
|
| 106 |
+
).to(model.device)
|
| 107 |
+
|
| 108 |
+
out = model.generate(inputs, max_new_tokens=512, do_sample=True, temperature=0.7)
|
| 109 |
+
print(tok.decode(out[0][inputs.shape[-1]:], skip_special_tokens=True))
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
## Technical details
|
| 113 |
+
|
| 114 |
+
| | |
|
| 115 |
+
|---|---|
|
| 116 |
+
| Base model | `Qwen/Qwen3.5-A3B-Base` (Qwen3.5-35B-A3B) |
|
| 117 |
+
| Architecture | `Qwen3_5MoeForCausalLM` — sparse MoE, hybrid linear + full attention |
|
| 118 |
+
| Parameters | ~35B total, ~3B active per token (A3B) |
|
| 119 |
+
| Experts | 256 routed, 8 active per token |
|
| 120 |
+
| Layers | 40 |
|
| 121 |
+
| Vocabulary | 248,320 |
|
| 122 |
+
| Context length | 262,144 |
|
| 123 |
+
| Precision | bf16 |
|
| 124 |
+
| Modification | weight-level refusal abliteration (3-stage synergy + CNA-from-base; no additional training data) |
|
| 125 |
+
|
| 126 |
+
## Limitations & biases
|
| 127 |
+
|
| 128 |
+
- Inherits the knowledge, biases, and failure modes of the base Qwen3.5-35B-A3B.
|
| 129 |
+
- Abliteration targets the dominant refusal subspace; rare or out-of-distribution refusal triggers may persist or, conversely, edge-case over-compliance may appear.
|
| 130 |
+
- Refusal in this MoE is redundantly encoded across routed experts, input projections, and embeddings; the three-stage edit reaches 0.8125 on the development eval, so some routed pathways may retain residual refusal under unusual gating.
|
| 131 |
+
- Without trained refusals, the model will attempt requests an aligned model would decline; treat outputs accordingly.
|
| 132 |
+
- Capability was **not** benchmarked for this checkpoint (see Validation); coherence was checked but a full capability suite is pending.
|
| 133 |
+
|
| 134 |
+
## Roadmap
|
| 135 |
+
|
| 136 |
+
This checkpoint is the **abliterated base** (arm B of the Nous-Heretic three-arm protocol). A direction-locked, post-trained variant — which adds capability and metacognitive calibration while constraining the LoRA/QLoRA adapter to remain orthogonal to the removed refusal direction so it cannot re-introduce refusal — is planned as a follow-up release, alongside the decontaminated three-arm capability evaluation.
|
| 137 |
+
|
| 138 |
+
## License
|
| 139 |
+
|
| 140 |
+
Distributed under the **Apache 2.0** license of the underlying Qwen base model. By using it you agree to those terms and to applicable law. Verify the base model's license terms for your use case.
|
| 141 |
+
|
| 142 |
+
## Citation & references
|
| 143 |
+
|
| 144 |
+
- Arditi, A., Obeso, O., Syed, A., Paleka, D., Panickssery, N., Gurnee, W., Nanda, N. (2024). *Refusal in Language Models Is Mediated by a Single Direction.* arXiv:2406.11717.
|
| 145 |
+
- Wollschläger, T., et al. (2025). *The Geometry of Refusal in Large Language Models: Concept Cones and Representational Independence.* arXiv:2502.17420.
|
| 146 |
+
- Souly, A., et al. (2024). *A StrongREJECT for Empty Jailbreaks.* arXiv:2402.10260.
|
| 147 |
+
- Labonne, M. (2024). *Uncensor any LLM with abliteration.*
|
| 148 |
+
- *Heretic: Fully automatic censorship removal for language models via optimized abliteration* (2025). github.com/p-e-w/heretic.
|
| 149 |
+
|
| 150 |
+
If you use this model, please also cite the base model: Qwen Team (2025), *Qwen3 Technical Report*, arXiv:2505.09388.
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set image_count = namespace(value=0) %}
|
| 2 |
+
{%- set video_count = namespace(value=0) %}
|
| 3 |
+
{%- macro render_content(content, do_vision_count, is_system_content=false) %}
|
| 4 |
+
{%- if content is string %}
|
| 5 |
+
{{- content }}
|
| 6 |
+
{%- elif content is iterable and content is not mapping %}
|
| 7 |
+
{%- for item in content %}
|
| 8 |
+
{%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
|
| 9 |
+
{%- if is_system_content %}
|
| 10 |
+
{{- raise_exception('System message cannot contain images.') }}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{%- if do_vision_count %}
|
| 13 |
+
{%- set image_count.value = image_count.value + 1 %}
|
| 14 |
+
{%- endif %}
|
| 15 |
+
{%- if add_vision_id %}
|
| 16 |
+
{{- 'Picture ' ~ image_count.value ~ ': ' }}
|
| 17 |
+
{%- endif %}
|
| 18 |
+
{{- '<|vision_start|><|image_pad|><|vision_end|>' }}
|
| 19 |
+
{%- elif 'video' in item or item.type == 'video' %}
|
| 20 |
+
{%- if is_system_content %}
|
| 21 |
+
{{- raise_exception('System message cannot contain videos.') }}
|
| 22 |
+
{%- endif %}
|
| 23 |
+
{%- if do_vision_count %}
|
| 24 |
+
{%- set video_count.value = video_count.value + 1 %}
|
| 25 |
+
{%- endif %}
|
| 26 |
+
{%- if add_vision_id %}
|
| 27 |
+
{{- 'Video ' ~ video_count.value ~ ': ' }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{{- '<|vision_start|><|video_pad|><|vision_end|>' }}
|
| 30 |
+
{%- elif 'text' in item %}
|
| 31 |
+
{{- item.text }}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{{- raise_exception('Unexpected item type in content.') }}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- endfor %}
|
| 36 |
+
{%- elif content is none or content is undefined %}
|
| 37 |
+
{{- '' }}
|
| 38 |
+
{%- else %}
|
| 39 |
+
{{- raise_exception('Unexpected content type.') }}
|
| 40 |
+
{%- endif %}
|
| 41 |
+
{%- endmacro %}
|
| 42 |
+
{%- if not messages %}
|
| 43 |
+
{{- raise_exception('No messages provided.') }}
|
| 44 |
+
{%- endif %}
|
| 45 |
+
{%- if tools and tools is iterable and tools is not mapping %}
|
| 46 |
+
{{- '<|im_start|>system\n' }}
|
| 47 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
|
| 48 |
+
{%- for tool in tools %}
|
| 49 |
+
{{- "\n" }}
|
| 50 |
+
{{- tool | tojson }}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{{- "\n</tools>" }}
|
| 53 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<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- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 54 |
+
{%- if messages[0].role == 'system' %}
|
| 55 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 56 |
+
{%- if content %}
|
| 57 |
+
{{- '\n\n' + content }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{%- endif %}
|
| 60 |
+
{{- '<|im_end|>\n' }}
|
| 61 |
+
{%- else %}
|
| 62 |
+
{%- if messages[0].role == 'system' %}
|
| 63 |
+
{%- set content = render_content(messages[0].content, false, true)|trim %}
|
| 64 |
+
{{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endif %}
|
| 67 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 68 |
+
{%- for message in messages[::-1] %}
|
| 69 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 70 |
+
{%- if ns.multi_step_tool and message.role == "user" %}
|
| 71 |
+
{%- set content = render_content(message.content, false)|trim %}
|
| 72 |
+
{%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
|
| 73 |
+
{%- set ns.multi_step_tool = false %}
|
| 74 |
+
{%- set ns.last_query_index = index %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- endif %}
|
| 77 |
+
{%- endfor %}
|
| 78 |
+
{%- if ns.multi_step_tool %}
|
| 79 |
+
{{- raise_exception('No user query found in messages.') }}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{%- for message in messages %}
|
| 82 |
+
{%- set content = render_content(message.content, true)|trim %}
|
| 83 |
+
{%- if message.role == "system" %}
|
| 84 |
+
{%- if not loop.first %}
|
| 85 |
+
{{- raise_exception('System message must be at the beginning.') }}
|
| 86 |
+
{%- endif %}
|
| 87 |
+
{%- elif message.role == "user" %}
|
| 88 |
+
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 89 |
+
{%- elif message.role == "assistant" %}
|
| 90 |
+
{%- set reasoning_content = '' %}
|
| 91 |
+
{%- if message.reasoning_content is string %}
|
| 92 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 93 |
+
{%- else %}
|
| 94 |
+
{%- if '</think>' in content %}
|
| 95 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 96 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- endif %}
|
| 99 |
+
{%- set reasoning_content = reasoning_content|trim %}
|
| 100 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 101 |
+
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
|
| 102 |
+
{%- else %}
|
| 103 |
+
{{- '<|im_start|>' + message.role + '\n' + content }}
|
| 104 |
+
{%- endif %}
|
| 105 |
+
{%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
|
| 106 |
+
{%- for tool_call in message.tool_calls %}
|
| 107 |
+
{%- if tool_call.function is defined %}
|
| 108 |
+
{%- set tool_call = tool_call.function %}
|
| 109 |
+
{%- endif %}
|
| 110 |
+
{%- if loop.first %}
|
| 111 |
+
{%- if content|trim %}
|
| 112 |
+
{{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 113 |
+
{%- else %}
|
| 114 |
+
{{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 115 |
+
{%- endif %}
|
| 116 |
+
{%- else %}
|
| 117 |
+
{{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
|
| 118 |
+
{%- endif %}
|
| 119 |
+
{%- if tool_call.arguments is defined %}
|
| 120 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 121 |
+
{{- '<parameter=' + args_name + '>\n' }}
|
| 122 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 123 |
+
{{- args_value }}
|
| 124 |
+
{{- '\n</parameter>\n' }}
|
| 125 |
+
{%- endfor %}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
{{- '</function>\n</tool_call>' }}
|
| 128 |
+
{%- endfor %}
|
| 129 |
+
{%- endif %}
|
| 130 |
+
{{- '<|im_end|>\n' }}
|
| 131 |
+
{%- elif message.role == "tool" %}
|
| 132 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 133 |
+
{{- '<|im_start|>user' }}
|
| 134 |
+
{%- endif %}
|
| 135 |
+
{{- '\n<tool_response>\n' }}
|
| 136 |
+
{{- content }}
|
| 137 |
+
{{- '\n</tool_response>' }}
|
| 138 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 139 |
+
{{- '<|im_end|>\n' }}
|
| 140 |
+
{%- elif loop.last %}
|
| 141 |
+
{{- '<|im_end|>\n' }}
|
| 142 |
+
{%- endif %}
|
| 143 |
+
{%- else %}
|
| 144 |
+
{{- raise_exception('Unexpected message role.') }}
|
| 145 |
+
{%- endif %}
|
| 146 |
+
{%- endfor %}
|
| 147 |
+
{%- if add_generation_prompt %}
|
| 148 |
+
{{- '<|im_start|>assistant\n' }}
|
| 149 |
+
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 150 |
+
{{- '<think>\n\n</think>\n\n' }}
|
| 151 |
+
{%- else %}
|
| 152 |
+
{{- '<think>\n' }}
|
| 153 |
+
{%- endif %}
|
| 154 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3_5MoeForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"attn_output_gate": true,
|
| 8 |
+
"bos_token_id": null,
|
| 9 |
+
"dtype": "bfloat16",
|
| 10 |
+
"eos_token_id": 248044,
|
| 11 |
+
"full_attention_interval": 4,
|
| 12 |
+
"head_dim": 256,
|
| 13 |
+
"hidden_act": "silu",
|
| 14 |
+
"hidden_size": 2048,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"layer_types": [
|
| 17 |
+
"linear_attention",
|
| 18 |
+
"linear_attention",
|
| 19 |
+
"linear_attention",
|
| 20 |
+
"full_attention",
|
| 21 |
+
"linear_attention",
|
| 22 |
+
"linear_attention",
|
| 23 |
+
"linear_attention",
|
| 24 |
+
"full_attention",
|
| 25 |
+
"linear_attention",
|
| 26 |
+
"linear_attention",
|
| 27 |
+
"linear_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"linear_attention",
|
| 30 |
+
"linear_attention",
|
| 31 |
+
"linear_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"linear_attention",
|
| 34 |
+
"linear_attention",
|
| 35 |
+
"linear_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"linear_attention",
|
| 38 |
+
"linear_attention",
|
| 39 |
+
"linear_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"linear_attention",
|
| 42 |
+
"linear_attention",
|
| 43 |
+
"linear_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"linear_attention",
|
| 46 |
+
"linear_attention",
|
| 47 |
+
"linear_attention",
|
| 48 |
+
"full_attention",
|
| 49 |
+
"linear_attention",
|
| 50 |
+
"linear_attention",
|
| 51 |
+
"linear_attention",
|
| 52 |
+
"full_attention",
|
| 53 |
+
"linear_attention",
|
| 54 |
+
"linear_attention",
|
| 55 |
+
"linear_attention",
|
| 56 |
+
"full_attention"
|
| 57 |
+
],
|
| 58 |
+
"linear_conv_kernel_dim": 4,
|
| 59 |
+
"linear_key_head_dim": 128,
|
| 60 |
+
"linear_num_key_heads": 16,
|
| 61 |
+
"linear_num_value_heads": 32,
|
| 62 |
+
"linear_value_head_dim": 128,
|
| 63 |
+
"mamba_ssm_dtype": "float32",
|
| 64 |
+
"max_position_embeddings": 262144,
|
| 65 |
+
"mlp_only_layers": [],
|
| 66 |
+
"model_type": "qwen3_5_moe_text",
|
| 67 |
+
"moe_intermediate_size": 512,
|
| 68 |
+
"mtp_num_hidden_layers": 1,
|
| 69 |
+
"mtp_use_dedicated_embeddings": false,
|
| 70 |
+
"num_attention_heads": 16,
|
| 71 |
+
"num_experts": 256,
|
| 72 |
+
"num_experts_per_tok": 8,
|
| 73 |
+
"num_hidden_layers": 40,
|
| 74 |
+
"num_key_value_heads": 2,
|
| 75 |
+
"output_router_logits": false,
|
| 76 |
+
"pad_token_id": null,
|
| 77 |
+
"partial_rotary_factor": 0.25,
|
| 78 |
+
"rms_norm_eps": 1e-06,
|
| 79 |
+
"rope_parameters": {
|
| 80 |
+
"mrope_interleaved": true,
|
| 81 |
+
"mrope_section": [
|
| 82 |
+
11,
|
| 83 |
+
11,
|
| 84 |
+
10
|
| 85 |
+
],
|
| 86 |
+
"partial_rotary_factor": 0.25,
|
| 87 |
+
"rope_theta": 10000000,
|
| 88 |
+
"rope_type": "default"
|
| 89 |
+
},
|
| 90 |
+
"router_aux_loss_coef": 0.001,
|
| 91 |
+
"shared_expert_intermediate_size": 512,
|
| 92 |
+
"tie_word_embeddings": false,
|
| 93 |
+
"transformers_version": "5.12.1",
|
| 94 |
+
"use_cache": true,
|
| 95 |
+
"vocab_size": 248320
|
| 96 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"eos_token_id": 248044,
|
| 4 |
+
"transformers_version": "5.12.1",
|
| 5 |
+
"use_cache": true
|
| 6 |
+
}
|
model-00001-of-00002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a3ea87e92923b371007e7f30833ea42f55d619b6797ee0979c93e4ab4fe049c
|
| 3 |
+
size 49742567544
|
model-00002-of-00002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:89937591ded7df9c7440909d692bd885ad41f822baea5cb28f6827a81e02d374
|
| 3 |
+
size 19583070672
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
|
| 3 |
+
size 19989325
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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": "<|endoftext|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"image_token": "<|image_pad|>",
|
| 12 |
+
"is_local": true,
|
| 13 |
+
"local_files_only": true,
|
| 14 |
+
"model_max_length": 262144,
|
| 15 |
+
"model_specific_special_tokens": {
|
| 16 |
+
"audio_bos_token": "<|audio_start|>",
|
| 17 |
+
"audio_eos_token": "<|audio_end|>",
|
| 18 |
+
"audio_token": "<|audio_pad|>",
|
| 19 |
+
"image_token": "<|image_pad|>",
|
| 20 |
+
"video_token": "<|video_pad|>",
|
| 21 |
+
"vision_bos_token": "<|vision_start|>",
|
| 22 |
+
"vision_eos_token": "<|vision_end|>"
|
| 23 |
+
},
|
| 24 |
+
"pad_token": "<|endoftext|>",
|
| 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 |
+
"split_special_tokens": false,
|
| 27 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 28 |
+
"unk_token": null,
|
| 29 |
+
"video_token": "<|video_pad|>",
|
| 30 |
+
"vision_bos_token": "<|vision_start|>",
|
| 31 |
+
"vision_eos_token": "<|vision_end|>"
|
| 32 |
+
}
|