Text Generation
Transformers
Safetensors
English
qwen3_5_text
code
lora
cuda
habbo
game-server-emulation
flash
shockwave
continued-pretraining
qwen3.5
hybrid-attention
gated-deltanet
conversational
Instructions to use h4bbo/FuseLLM-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use h4bbo/FuseLLM-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="h4bbo/FuseLLM-9B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("h4bbo/FuseLLM-9B") model = AutoModelForCausalLM.from_pretrained("h4bbo/FuseLLM-9B", 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 h4bbo/FuseLLM-9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "h4bbo/FuseLLM-9B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "h4bbo/FuseLLM-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/h4bbo/FuseLLM-9B
- SGLang
How to use h4bbo/FuseLLM-9B 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 "h4bbo/FuseLLM-9B" \ --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": "h4bbo/FuseLLM-9B", "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 "h4bbo/FuseLLM-9B" \ --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": "h4bbo/FuseLLM-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use h4bbo/FuseLLM-9B with Docker Model Runner:
docker model run hf.co/h4bbo/FuseLLM-9B
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +170 -0
- chat_template.jinja +154 -0
- config.json +83 -0
- generation_config.json +6 -0
- merges.txt +0 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +32 -0
- vocab.json +0 -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,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
base_model: Qwen/Qwen3.5-9B
|
| 4 |
+
tags:
|
| 5 |
+
- code
|
| 6 |
+
- lora
|
| 7 |
+
- cuda
|
| 8 |
+
- habbo
|
| 9 |
+
- game-server-emulation
|
| 10 |
+
- flash
|
| 11 |
+
- shockwave
|
| 12 |
+
- continued-pretraining
|
| 13 |
+
- qwen3.5
|
| 14 |
+
- hybrid-attention
|
| 15 |
+
- gated-deltanet
|
| 16 |
+
language:
|
| 17 |
+
- en
|
| 18 |
+
license: apache-2.0
|
| 19 |
+
inference: false
|
| 20 |
+
pipeline_tag: text-generation
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# FuseLLM-9B
|
| 24 |
+
|
| 25 |
+
A domain-specialist code model for the **Habbo Hotel ecosystem** — server emulators (Java, C#, PHP, Rust) and Flash/Shockwave client tooling (ActionScript, LiveScript, SWF/DIR reverse engineering). Built by continued pretraining of **Qwen3.5-9B**'s language model on a curated corpus of ~85K source files (~211M tokens) drawn from Habbo emulator projects, decompiled client code, and CMS/database dumps.
|
| 26 |
+
|
| 27 |
+
The base `Qwen/Qwen3.5-9B` is a multimodal Qwen3.5 model (vision + text). This fine-tune targets and ships only its **text language model** (`Qwen3_5ForCausalLM`, 8.95B params) — the vision tower is not included in the released weights.
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## tl;dr
|
| 32 |
+
|
| 33 |
+
- **What it is:** an ~9B-parameter model, LoRA-continued-pretrained on Habbo emulator + retro-client source code, merged into a standalone bf16 text causal LM.
|
| 34 |
+
- **Base:** `Qwen/Qwen3.5-9B` — Apache-2.0. Hybrid Qwen3.5 architecture: 24 Gated-DeltaNet (linear-attention) layers + 8 full-attention layers (1 full every 4), 32 layers total, hidden 4096, vocab 248320.
|
| 35 |
+
- **Trained on:** a single NVIDIA H100 80GB, CUDA 12.6, PyTorch 2.13.0+cu126. bf16 LoRA, no quantization, gradient checkpointing on. Used the `flash-linear-attention` (fla) fast path + `causal-conv1d` for the DeltaNet / short-conv layers.
|
| 36 |
+
- **Runs on:** a 9B model needs more than the 4B sibling but is still very consumer-friendly. A Q4_K_M GGUF is ~5 GB — fits in 8 GB VRAM (short context), comfortable at 12 GB. The full bf16 merged weights (~18 GB) need 24 GB. If your card has ≥8 GB and was made in the last ~6 years, it can run FuseLLM-9B at some quantization.
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
## Inference — yes, your GPU can run this
|
| 41 |
+
|
| 42 |
+
The point of shipping a ~9B model is strong domain capacity while still running on consumer hardware. The training rig was an 80 GB H100; **inference needs far less.**
|
| 43 |
+
|
| 44 |
+
| Path | Size | Min. VRAM (comfortable) | Notes |
|
| 45 |
+
|---|---|---|---|
|
| 46 |
+
| **GGUF Q4_K_M (recommended)** | ~5.0 GB | 12 GB (runs on 8 GB, short ctx) | Via Ollama / llama.cpp / LM Studio / KoboldCpp. CPU-only also works — slow but functional. |
|
| 47 |
+
| GGUF Q8_0 | ~9.5 GB | 16 GB (12 GB short ctx) | Near-lossless. |
|
| 48 |
+
| bf16 merged (full precision) | ~18 GB + KV cache | 24 GB | The "no quantization" path. 40 GB+ leaves room for a long context. |
|
| 49 |
+
|
| 50 |
+
Concrete examples of cards that run it fine:
|
| 51 |
+
|
| 52 |
+
- **8 GB:** RTX 3060 / 4060 / 5060, RX 6600 / 7600, Arc A580 — Q4_K_M with short context.
|
| 53 |
+
- **12 GB:** RTX 3060 12GB / 4070 / 5070, RX 6700 XT / 7700 XT — Q4_K_M with long context, or Q8_0 short context.
|
| 54 |
+
- **16 GB:** RTX 4060 Ti 16GB / 4080 / 5070 Ti, RX 7800 XT / 9070 — Q8_0 comfortably, or bf16 short context.
|
| 55 |
+
- **24 GB:** RTX 3090 / 4090 / 5090, RX 7900 XTX/XT — bf16 merged with a healthy context, or Q4 with room to spare.
|
| 56 |
+
|
| 57 |
+
Linux, Windows, macOS (Metal) all supported through llama.cpp / Ollama. **AMD, NVIDIA, and Intel are all first-class** — the GGUF backend is vendor-agnostic.
|
| 58 |
+
|
| 59 |
+
### Quick start (Ollama)
|
| 60 |
+
|
| 61 |
+
```bash
|
| 62 |
+
ollama run h4bbo/fusellm-9b # once uploaded
|
| 63 |
+
# or load the local GGUF:
|
| 64 |
+
ollama create fusellm-9b -f Modelfile # FROM ./fusellm-9b-Q4_K_M.gguf
|
| 65 |
+
ollama run fusellm-9b
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### Quick start (transformers, bf16)
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 72 |
+
import torch
|
| 73 |
+
|
| 74 |
+
tok = AutoTokenizer.from_pretrained("h4bbo/FuseLLM-9B")
|
| 75 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 76 |
+
"h4bbo/FuseLLM-9B",
|
| 77 |
+
torch_dtype=torch.bfloat16,
|
| 78 |
+
device_map="auto",
|
| 79 |
+
)
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
## Training details
|
| 85 |
+
|
| 86 |
+
### Hardware
|
| 87 |
+
|
| 88 |
+
| | |
|
| 89 |
+
|---|---|
|
| 90 |
+
| GPU | NVIDIA H100 80GB HBM3 |
|
| 91 |
+
| Stack | CUDA 12.6, PyTorch 2.13.0+cu126 |
|
| 92 |
+
| Fast path | `flash-linear-attention` 0.5.2 + `causal-conv1d` 1.6.2 (fla kernels for the Gated-DeltaNet layers; `causal-conv1d` for the short conv). `attn_implementation="sdpa"` — FlashAttention-2 does not cover the DeltaNet layers. |
|
| 93 |
+
|
| 94 |
+
A single 80 GB datacenter-class card. With gradient checkpointing and bf16 LoRA the full 9B fits without quantization. (The 4B sibling of this model was trained on a single 24 GB consumer AMD card via ROCm — see `h4bbo/FuseLLM-Instruct-4B-v1`.)
|
| 95 |
+
|
| 96 |
+
### Base model
|
| 97 |
+
|
| 98 |
+
`Qwen/Qwen3.5-9B` — Apache-2.0. Qwen3.5 hybrid architecture: 32 layers = 24 Gated-DeltaNet (linear attention) + 8 full attention (one full layer every four), hidden 4096, 16 attention heads, 4 KV heads (full-attn), head_dim 256, vocab 248320, max_position_embeddings 262144. The released weights are the text LM only (`Qwen3_5ForCausalLM`, 8.95B params, `tie_word_embeddings=False`); the base's vision tower is not part of this release.
|
| 99 |
+
|
| 100 |
+
### Method — bf16 LoRA continued pretraining
|
| 101 |
+
|
| 102 |
+
Raw-code continued pretraining (full-sequence causal-LM loss, no instruction pairs).
|
| 103 |
+
|
| 104 |
+
- **LoRA:** r=32, alpha=64, dropout=0.05, applied to all Qwen3.5 hybrid projections — full attention (`q/k/v/o_proj`, 8/32 layers), Gated-DeltaNet (`in_proj_qkv`, `in_proj_z`, `in_proj_b`, `in_proj_a`, `out_proj`, 24/32 layers), and FFN (`gate/up/down_proj`, all layers). `task_type=CAUSAL_LM`.
|
| 105 |
+
- **Optimizer/schedule:** `adamw_torch`, lr=1e-4, cosine, warmup_ratio=0.03, max_grad_norm=1.0, 1 epoch.
|
| 106 |
+
- **Batching:** per-device batch 4 × grad-accum 8 = effective batch 32, `max_length=2048` with `packing_strategy="wrapped"`, 4254 steps, ~15.5 h.
|
| 107 |
+
- **Precision/memory:** `bf16=True`, `gradient_checkpointing=True` (`use_reentrant=False`), `attn_implementation="sdpa"`, `optim="adamw_torch"` (no bitsandbytes). `PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True`.
|
| 108 |
+
- **Loss:** full-sequence causal-LM on packed raw code (correct for continued pretraining — no instruction/response pairs to mask).
|
| 109 |
+
- **Merge:** `merge_and_unload(safe_merge=True)` into the bf16 base → standalone safetensors. `save_peft_format=False` (critical — otherwise the adapter re-attaches on reload).
|
| 110 |
+
|
| 111 |
+
### Training result
|
| 112 |
+
|
| 113 |
+
| | |
|
| 114 |
+
|---|---|
|
| 115 |
+
| Steps | 4,254 (1 epoch) |
|
| 116 |
+
| Wall time | ~15.5 h |
|
| 117 |
+
| Train loss (final) | 0.4082 |
|
| 118 |
+
| Loss curve | 0.7336 (step 10) → 0.3318 (final) |
|
| 119 |
+
| Mean token accuracy | 0.8393 (step 10) → 0.9167 (final) |
|
| 120 |
+
| Tokens seen | ~2.79e8 |
|
| 121 |
+
|
| 122 |
+
### Training data
|
| 123 |
+
|
| 124 |
+
| | |
|
| 125 |
+
|---|---|
|
| 126 |
+
| Files | 84,925 unique (sha256-deduped; 206,707 duplicates removed; 2.07M minified files skipped) |
|
| 127 |
+
| Size | 803.2 MB |
|
| 128 |
+
| Tokens | ~211M (est. chars/4) |
|
| 129 |
+
| Format | `{"text": <redacted file content>}` — TRL `dataset_text_field="text"` |
|
| 130 |
+
|
| 131 |
+
By language (files): Java 26,335 · C# 19,048 · PHP 10,969 · LiveScript 7,457 · ActionScript 3,801 · Python 3,023 · JavaScript 2,646 · XML 2,569 · HTML 2,023 · CSS 1,470 · Rust 1,442 · C 1,103 · TypeScript 644 · C++ 517 · SQL 494 · VB 362 · JSON 351 · + Markdown/Gradle/YAML/Scala/Lua.
|
| 132 |
+
|
| 133 |
+
Sources: 123 Quackster Habbo emulator/tooling repos (incl. private: HorusClient, Kurkku, Aleeda, Icarus variants, cappo-emu, …), `ntuative/RELEASE63…`, `deklol/Shockless`, plus deeply-nested Beta-archive extractions (Debbo, BloodLine, Chocohotel, uberEmu, etc.) — 497 archives / 30 GB unpacked. `.sql` DB dumps (148 MB) are included for now and may be dropped in a later revision.
|
| 134 |
+
|
| 135 |
+
---
|
| 136 |
+
|
| 137 |
+
## Intended use & limitations
|
| 138 |
+
|
| 139 |
+
**Intended:** code completion / Q&A for Habbo server-emulator and retro-client development — packet handling, room/item state, CMS schemas, SWF/DIR reverse engineering, Shockwave Lingo, ActionScript 3 client internals.
|
| 140 |
+
|
| 141 |
+
**Not intended:** general-purpose chat, math, or non-Habbo code generation. This is a *continued-pretraining* of an instruct model on domain code; it is not a general assistant and was not aligned for safety/RLHF beyond what the base model already had. (Note: because the base here is an **instruct** model and the fine-tune is raw-code continued pretraining with no chat formatting, some of the base's chat alignment is expected to erode — this is a domain code model, not a conversational one.)
|
| 142 |
+
|
| 143 |
+
**Limitations:**
|
| 144 |
+
- ~9B parameters — strong on domain pattern-completion; weaker than larger models on multi-file reasoning.
|
| 145 |
+
|
| 146 |
+
---
|
| 147 |
+
|
| 148 |
+
## License & data provenance
|
| 149 |
+
|
| 150 |
+
- **Base model:** `Qwen/Qwen3.5-9B` — **Apache-2.0**. Fine-tuning and redistribution permitted with attribution. ✅
|
| 151 |
+
- **This fine-tune (weights):** released under **Apache-2.0** *conditional on the data licensing below*. The LoRA adapter is small and derivative; the merged model inherits both base and data obligations.
|
| 152 |
+
- **Training data:** mixed provenance —
|
| 153 |
+
- Author's own repos (fine).
|
| 154 |
+
- **GPL / various third-party emulators** (PHPRetro/Yifan Lu, uberEmu/Meth0d, Holograph, Icarus, etc.) — GPL-derivative debate applies; a model trained on GPL source is arguably a derivative work.
|
| 155 |
+
|
| 156 |
+
## Redaction
|
| 157 |
+
|
| 158 |
+
Secrets are scrubbed from all training content before tokenisation (replaced with `[REDACTED]`). No known credentials enter the weights. The released weights and tokenizer/config files were scanned for tokens, API keys, IPs, hostnames, and absolute paths before upload — none found.
|
| 159 |
+
|
| 160 |
+
## Citation
|
| 161 |
+
|
| 162 |
+
If this model is useful, cite the base and this fine-tune:
|
| 163 |
+
|
| 164 |
+
```bibtex
|
| 165 |
+
@misc{fusellm-9b,
|
| 166 |
+
title = {FuseLLM-9B: a Habbo ecosystem code model},
|
| 167 |
+
note = {bf16 LoRA continued pretraining of Qwen3.5-9B's text LM},
|
| 168 |
+
year = {2026},
|
| 169 |
+
}
|
| 170 |
+
```
|
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,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen3_5ForCausalLM"
|
| 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": 4096,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 12288,
|
| 17 |
+
"layer_types": [
|
| 18 |
+
"linear_attention",
|
| 19 |
+
"linear_attention",
|
| 20 |
+
"linear_attention",
|
| 21 |
+
"full_attention",
|
| 22 |
+
"linear_attention",
|
| 23 |
+
"linear_attention",
|
| 24 |
+
"linear_attention",
|
| 25 |
+
"full_attention",
|
| 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 |
+
],
|
| 51 |
+
"linear_conv_kernel_dim": 4,
|
| 52 |
+
"linear_key_head_dim": 128,
|
| 53 |
+
"linear_num_key_heads": 16,
|
| 54 |
+
"linear_num_value_heads": 32,
|
| 55 |
+
"linear_value_head_dim": 128,
|
| 56 |
+
"mamba_ssm_dtype": "float32",
|
| 57 |
+
"max_position_embeddings": 262144,
|
| 58 |
+
"mlp_only_layers": [],
|
| 59 |
+
"model_type": "qwen3_5_text",
|
| 60 |
+
"mtp_num_hidden_layers": 1,
|
| 61 |
+
"mtp_use_dedicated_embeddings": false,
|
| 62 |
+
"num_attention_heads": 16,
|
| 63 |
+
"num_hidden_layers": 32,
|
| 64 |
+
"num_key_value_heads": 4,
|
| 65 |
+
"pad_token_id": null,
|
| 66 |
+
"partial_rotary_factor": 0.25,
|
| 67 |
+
"rms_norm_eps": 1e-06,
|
| 68 |
+
"rope_parameters": {
|
| 69 |
+
"mrope_interleaved": true,
|
| 70 |
+
"mrope_section": [
|
| 71 |
+
11,
|
| 72 |
+
11,
|
| 73 |
+
10
|
| 74 |
+
],
|
| 75 |
+
"partial_rotary_factor": 0.25,
|
| 76 |
+
"rope_theta": 10000000,
|
| 77 |
+
"rope_type": "default"
|
| 78 |
+
},
|
| 79 |
+
"tie_word_embeddings": false,
|
| 80 |
+
"transformers_version": "5.13.1",
|
| 81 |
+
"use_cache": true,
|
| 82 |
+
"vocab_size": 248320
|
| 83 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"eos_token_id": 248044,
|
| 4 |
+
"transformers_version": "5.13.1",
|
| 5 |
+
"use_cache": true
|
| 6 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c53a0ec77d6e0508dabf06b05837a5afb1b936f270755917185a278028ea26d9
|
| 3 |
+
size 17907663008
|
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": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"image_token": "<|image_pad|>",
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": false,
|
| 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 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|