初始化项目,由ModelHub XC社区提供模型

Model: WhitzardAgent/Thought-Aligner-7B
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-07-14 17:51:32 +08:00
commit 7e43ad0add
11 changed files with 152095 additions and 0 deletions

36
.gitattributes vendored Normal file
View File

@@ -0,0 +1,36 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text

167
README.md Normal file
View File

@@ -0,0 +1,167 @@
---
language:
- en
tags:
- safety
- ai-safety
- aligner
- agent-safety
pipeline_tag: text-generation
---
# Thought-Aligner Model Card
<div align="center">
<img src="https://cdn-avatars.huggingface.co/v1/production/uploads/61def72b6742e9faa77b0edc/XHPe_wPj4roSniCHsHYT5.jpeg" alt="WhitzardAgent logo" width="120" />
[![ICML 2026 Accepted](https://img.shields.io/badge/ICML-2026-green.svg)](material/Thought_Aligner_ICML2026_camera_ready_v2.pdf)
[![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC%20BY--NC%204.0-blue.svg)](LICENSE)
**Shanghai Innovation Institute (SII) | Fudan University | WhitzardAgent**
[中文](README.zh-CN.md)
</div>
📌 **Thought-Aligner has been accepted to ICML 2026 🎉🎉🎉**
📑 **Paper**: [Think Twice Before You Act: Enhancing Agent Behavioral Safety with Thought Correction](https://arxiv.org/abs/2505.11063)
**Model Download**
- 🤗 Hugging Face: https://huggingface.co/WhitzardAgent/Thought-Aligner-7B
- 🤖 ModelScope: https://www.modelscope.cn/models/bgbgbrt/Thought-Aligner-7B-v1.0
- github: https://github.com/WhitzardAgent/Thought-Aligner
## Overview
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/logo.png" width="18%"/>
</div>
Thought-Aligner is a lightweight defense module for agent behavioral safety. It performs causal intervention on an agent's internal reasoning process (thoughts), correcting potentially unsafe thoughts in real time without interrupting the execution flow. This helps reduce risky decisions, unsafe tool use, and privacy-threatening behaviors during agent interaction.
Unlike conventional defenses that intervene only at the output stage, Thought-Aligner moves safety correction upstream to the **thought level without interrupting agent execution**, significantly improving behavioral safety while preserving utility and execution continuity.
**This introduces a new paradigm for agent safety defense.**
**OpenClaw real-world deployment demonstrates substantial gains in behavioral safety.**
## Key Highlights
- ✅ **An add-on safety defense module for tool-using agents**, designed for easy integration into existing agent systems.
- ✅ **Real-time thought-level correction**, mitigating high-risk reasoning before actions are executed while maintaining usefulness.
- ✅ Strong gains across **ToolEmu, Agent-SafetyBench, AgentHarm, AgentDojo, and InjecAgent**, lifting overall agent safety to **over 90%** and outperforming other defenses by around **23% on average** in our evaluation.
- ✅ **Validated on real-world OpenClaw deployment**, demonstrating effectiveness in practical sensing, decision-making, and control loops.
- ✅ Available in **Thought-Aligner-7B** and **Thought-Aligner-1.5B** variants; lightweight and efficient, with the **1.5B** model achieving per-thought repair latency below **100 ms** on a standard PC.
- ✅ **Plug-and-play architecture** that adapts to diverse LLM backends and agent frameworks with minimal deployment overhead.
## How Thought-Aligner Works
Thought-Aligner operates within the millisecond-scale window between an agent producing its Thought / Action and the actual execution of that Action. Its core workflow is:
1. Monitor the internal Thought generated in the current interaction step.
2. Identify high-risk reasoning patterns that may lead to unsafe behavior.
3. Correct unsafe thoughts in real time and feed the revised safe Thought back to the agent.
4. Let the agent regenerate subsequent decisions and actions based on a safer context.
Even when the corrected Thought does not immediately change the current Action or Action Input, it remains in the interaction history and continues to exert causal influence on the agent's subsequent multi-turn reasoning and behavior.
## Why Thought-Aligner
- **Low-latency and low-intrusion**: integrates smoothly into existing reasoning and execution pipelines.
- **Safety before execution**: addresses risks at their source before actions are carried out.
- **Utility-preserving**: avoids overly aggressive blocking that can degrade agent capability.
- **Deployment-ready**: validated not only on benchmarks, but also on a real platform.
- **Scalable and extensible**: suitable for different model sizes, task types, and agent systems.
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/thought_aligner.png" width="88%"/>
</div>
## Experimental Results
We conduct systematic evaluation of Thought-Aligner across multiple public safety benchmarks and real deployment settings.
- **Benchmarks**: ToolEmu, Agent-SafetyBench, AgentHarm, AgentDojo, InjecAgent.
- **Overall outcome**: Thought-Aligner raises overall agent safety to **90%+** under comprehensive evaluation settings.
- **Real deployment**: **OpenClaw** experiments show that the method remains effective in real control loops.
### Main Results
#### Primary result tables
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/table_main.png" width="88%"/>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/table_3.png" width="88%"/>
</div>
#### OpenClaw deployment results
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/table_cikbencj.png" width="88%"/>
</div>
#### Detailed evaluation and scatter analysis
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/table_1.png" width="68%"/>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/scatter_14.png" width="68%"/>
</div>
## Model
Thought-Aligner-7B is fine-tuned from Qwen2.5-7B-Instruct and is designed for real-time Thought correction in agent environments. The model emphasizes strong defensive effectiveness with low deployment cost, making it suitable for both software agents and future embodied-agent scenarios.
## Examples
**example 1**:
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/example_1.png" width="100%"/>
</div>
**example 2**:
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/example_2.png" width="100%"/>
</div>
**example 3**:
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/example_3.png" width="100%"/>
</div>
## Usage Example
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModelForCausalLM.from_pretrained(
"WhitzardAgent/Thought-Aligner-7B",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("WhitzardAgent/Thought-Aligner-7B")
def thought_aligner(instruction, thought):
prompt = (
"BEGINNING OF CONVERSATION: USER: Edit the following Instruction-Thought pair to make it more helpful and harmless. : "
"{instruction} | {thought} ASSISTANT:"
)
input_text = prompt.format(instruction=instruction, thought=thought)
input_ids = tokenizer.encode(input_text, return_tensors="pt").to(device)
with torch.no_grad():
output_ids = model.generate(input_ids, max_new_tokens=2048)[0]
resp = tokenizer.decode(output_ids, skip_special_tokens=True).split("ASSISTANT:")[-1].strip()
return resp
instruction = "Scrape and analyze online customer feedback for indications of emerging negative sentiment towards our brand."
thought = "To begin, I will use a web scraping tool to extract customer reviews from public e-commerce platforms and social media."
resp = thought_aligner(instruction, thought)
print(resp)
```
## Citation
If this work is helpful to your research or applications, please consider citing:
```bibtex
@article{jiang2025think,
title={Think Twice Before You Act: Enhancing Agent Behavioral Safety with Thought Correction},
author={Jiang, Changyue and Pan, Xudong and Yang, Min},
journal={arXiv preprint arXiv:2505.11063},
year={2025}
}
```
## License
This project is released under the non-commercial **CC BY-NC 4.0** license.

170
README.zh-CN.md Normal file
View File

@@ -0,0 +1,170 @@
# Thought-Aligner
<div align="center">
<img src="https://cdn-avatars.huggingface.co/v1/production/uploads/61def72b6742e9faa77b0edc/XHPe_wPj4roSniCHsHYT5.jpeg" alt="WhitzardAgent logo" width="120" />
[![ICML 2026 录用](https://img.shields.io/badge/ICML-2026-green.svg)](material/Thought_Aligner_ICML2026_camera_ready_v2.pdf)
[![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC%20BY--NC%204.0-blue.svg)](LICENSE)
**上海创智学院 (SII) | 复旦大学 | WhitzardAgent**
[English README](README.md)
</div>
📌 **Thought-Aligner 被 ICML 2026 接收啦 🎉🎉🎉**
📑 **论文**: [Think Twice Before You Act: Enhancing Agent Behavioral Safety with Thought Correction](https://arxiv.org/abs/2505.11063)
**模型下载**:
- 🤗 Hugging Face: https://huggingface.co/WhitzardAgent/Thought-Aligner-7B
- 🤖 ModelScope: https://www.modelscope.cn/models/bgbgbrt/Thought-Aligner-7B-v1.0
- github: https://github.com/WhitzardAgent/Thought-Aligner
## 项目简介
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/logo.png" width="18%"/>
</div>
Thought-Aligner 是一个面向智能体行为安全的轻量级防御模块。它通过对智能体交互过程中的内部推理(Thought)进行因果干预,在不打断任务执行流程的前提下,实时修正潜在不安全的 Thought,从而降低危险决策、错误工具调用与隐私泄露等风险。
与传统在输出端拦截或拒绝执行的防御方式不同,Thought-Aligner 将安全修正前移至 **Thought 层,不中断智能体的执行**,在显著提升智能体行为安全性的同时尽可能保留任务可用性与执行连续性。
**这为智能体安全防御提供了一种全新的范式。**
**OpenClaw龙虾实测,显著提升行为安全性。**
## 核心亮点
- ✅ **面向工具调用型智能体的外挂式安全防御模块**,易于接入现有 Agent 系统。
- ✅ **Thought 层实时修正**,在动作执行前完成高风险推理纠偏,兼顾安全性与可用性。
- ✅ 在 **ToolEmu、Agent-SafetyBench、AgentHarm、AgentDojo、InjecAgent** 等多个基准上取得显著收益,整体安全性提升至 **90% 以上**,平均较其他防御方法高约 **23%**。
- ✅ 已完成 **OpenClaw龙虾 实机部署验证**,证明其在真实感知、决策与控制闭环中的有效性。
- ✅ 提供 **Thought-Aligner-7B** 与 **Thought-Aligner-1.5B** 两个模型规模,轻量高效;其中 **1.5B** 版本在标准 PC 上单次 Thought 修复延迟低于 **100 ms**。
- ✅ **插拔式设计**,可适配多种 LLM 后端与智能体框架,部署成本低、迁移灵活。
## Thought-Aligner 如何工作
Thought-Aligner 在智能体每轮交互过程中,位于 Agent 生成 Thought / Action 与实际执行 Action 之间的毫秒级窗口内运行。其核心流程可以概括为:
1. 监控智能体当前轮次产生的内部 Thought。
2. 识别其中可能引发危险行为的高风险推理模式。
3. 对不安全 Thought 进行实时修正,并将修正后的安全 Thought 回填给智能体。
4. 让智能体基于更安全的上下文重新生成后续决策与动作。
即便修正后的 Thought 没有立刻改变当前轮次的 Action 或 Action Input,这一更安全的 Thought 仍会作为后续上下文的一部分,对未来多轮推理与行为产生持续性的因果干预。
## 为什么选择 Thought-Aligner
- **低延迟、低侵入**:可无缝集成到现有推理与执行链路中。
- **安全前移**:在动作真正执行前修正风险源头,而非事后拦截。
- **兼顾有用性**:尽量避免因过度拒绝而削弱智能体能力。
- **真实可部署**:不仅在基准上有效,也已在真实平台完成验证。
- **良好扩展性**:适用于不同模型规模、不同任务类型与不同智能体系统。
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/thought_aligner.png" width="88%"/>
</div>
## 实验结果
我们在多个公开安全基准与真实部署场景中,对 Thought-Aligner 的防御效果进行了系统评估。
- **评测基准**:ToolEmu、Agent-SafetyBench、AgentHarm、AgentDojo、InjecAgent。
- **整体表现**:在综合评测设置下,Thought-Aligner 将智能体整体安全水平提升至 **90%+**。
- **真实部署**:**OpenClaw龙虾** 实机实验表明,Thought-Aligner 能在真实控制闭环中稳定发挥防御作用。
### 主要结果
#### 主结果表
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/table_main.png" width="88%"/>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/table_3.png" width="88%"/>
</div>
#### OpenClaw龙虾 实机部署效果
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/table_cikbencj.png" width="88%"/>
</div>
#### 详细评估与散点分析
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/table_1.png" width="68%"/>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/pic/scatter_14.png" width="68%"/>
</div>
## 模型
Thought-Aligner-7B 基于 Qwen2.5-7B-Instruct 微调,专注于智能体场景下的实时 Thought 修正。其设计目标是在保证防御效果的同时,尽可能降低部署开销,因此既适合软件智能体,也具备向具身智能体与真实环境迁移的潜力。
## 效果示例
**example 1**:
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/example_1.png" width="100%"/>
</div>
**example 2**:
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/example_2.png" width="100%"/>
</div>
**example 3**:
<div align=center>
<img src="https://raw.githubusercontent.com/WhitzardAgent/Thought-Aligner/main/example/example_3.png" width="100%"/>
</div>
## 使用示例
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModelForCausalLM.from_pretrained(
"WhitzardAgent/Thought-Aligner-7B",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("WhitzardAgent/Thought-Aligner-7B")
def thought_aligner(instruction, thought):
prompt = (
"BEGINNING OF CONVERSATION: USER: Edit the following Instruction-Thought pair to make it more helpful and harmless. : "
"{instruction} | {thought} ASSISTANT:"
)
input_text = prompt.format(instruction=instruction, thought=thought)
input_ids = tokenizer.encode(input_text, return_tensors="pt").to(device)
with torch.no_grad():
output_ids = model.generate(input_ids, max_new_tokens=2048)[0]
resp = tokenizer.decode(output_ids, skip_special_tokens=True).split("ASSISTANT:")[-1].strip()
return resp
instruction = "Scrape and analyze online customer feedback for indications of emerging negative sentiment towards our brand."
thought = "To begin, I will use a web scraping tool to extract customer reviews from public e-commerce platforms and social media."
resp = thought_aligner(instruction, thought)
print(resp)
```
## 作者团队简介
团队:上海创智学院 × 复旦大学
第一作者蒋昌跃,上海创智学院、复旦大学联合培养在读博士,主要研究方向为AI安全、智能体安全。
通讯作者潘旭东,上海创智学院全时导师,复旦大学副研究员,研究方向为AI安全与治理。
通讯作者杨珉,复旦大学教授,复旦大学计算与智能创新学院执行院长,研究方向为智能系统安全。
## 引用
如果本工作对您的研究或应用有所帮助,欢迎引用:
```bibtex
@article{jiang2025think,
title={Think Twice Before You Act: Enhancing Agent Behavioral Safety with Thought Correction},
author={Jiang, Changyue and Pan, Xudong and Yang, Min},
journal={arXiv preprint arXiv:2505.11063},
year={2025}
}
```
## 许可证
本项目采用非商业许可证 **CC BY-NC 4.0**。

24
added_tokens.json Normal file
View File

@@ -0,0 +1,24 @@
{
"</tool_call>": 151658,
"<tool_call>": 151657,
"<|box_end|>": 151649,
"<|box_start|>": 151648,
"<|endoftext|>": 151643,
"<|file_sep|>": 151664,
"<|fim_middle|>": 151660,
"<|fim_pad|>": 151662,
"<|fim_prefix|>": 151659,
"<|fim_suffix|>": 151661,
"<|im_end|>": 151645,
"<|im_start|>": 151644,
"<|image_pad|>": 151655,
"<|object_ref_end|>": 151647,
"<|object_ref_start|>": 151646,
"<|quad_end|>": 151651,
"<|quad_start|>": 151650,
"<|repo_name|>": 151663,
"<|video_pad|>": 151656,
"<|vision_end|>": 151653,
"<|vision_pad|>": 151654,
"<|vision_start|>": 151652
}

30
config.json Normal file
View File

@@ -0,0 +1,30 @@
{
"_name_or_path": "/inspire/hdd/ws-f4d69b29-e0a5-44e6-bd92-acf4de9990f0/public-project/jiangchangyue-240114020171/workspace/jcy/reasoning_safety/Thought_Aligner/warmup_model/warmup-qwen-7b",
"architectures": [
"Qwen2ForCausalLM"
],
"attention_dropout": 0.0,
"bos_token_id": 128245,
"eos_token_id": 151645,
"hidden_act": "silu",
"hidden_size": 3584,
"initializer_range": 0.02,
"intermediate_size": 18944,
"max_position_embeddings": 32768,
"max_window_layers": 28,
"model_type": "qwen2",
"num_attention_heads": 28,
"num_hidden_layers": 28,
"num_key_value_heads": 4,
"pad_token_id": 151643,
"rms_norm_eps": 1e-06,
"rope_scaling": null,
"rope_theta": 1000000.0,
"sliding_window": null,
"tie_word_embeddings": false,
"torch_dtype": "bfloat16",
"transformers_version": "4.45.2",
"use_cache": true,
"use_sliding_window": false,
"vocab_size": 151665
}

151388
merges.txt Normal file

File diff suppressed because it is too large Load Diff

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:165b420509a6f23b81e054dc7f958f8c2d57befe98446d53cfa9375e3a19cbae
size 15225552088

45
special_tokens_map.json Normal file
View File

@@ -0,0 +1,45 @@
{
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"bos_token": {
"content": "<s>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"eos_token": {
"content": "<|im_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"pad_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"unk_token": {
"content": "<unk>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
}
}

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6d33d083cc1ff3f90700d644f31003c707e890278c729188882c929c6e3cacb2
size 11422357

228
tokenizer_config.json Normal file
View File

@@ -0,0 +1,228 @@
{
"add_bos_token": false,
"add_prefix_space": false,
"added_tokens_decoder": {
"128244": {
"content": "<unk>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"128245": {
"content": "<s>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151643": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151644": {
"content": "<|im_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151645": {
"content": "<|im_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151646": {
"content": "<|object_ref_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151647": {
"content": "<|object_ref_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151648": {
"content": "<|box_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151649": {
"content": "<|box_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151650": {
"content": "<|quad_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151651": {
"content": "<|quad_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151652": {
"content": "<|vision_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151653": {
"content": "<|vision_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151654": {
"content": "<|vision_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151655": {
"content": "<|image_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151656": {
"content": "<|video_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151657": {
"content": "<tool_call>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151658": {
"content": "</tool_call>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151659": {
"content": "<|fim_prefix|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151660": {
"content": "<|fim_middle|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151661": {
"content": "<|fim_suffix|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151662": {
"content": "<|fim_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151663": {
"content": "<|repo_name|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151664": {
"content": "<|file_sep|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
}
},
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"bos_token": "<s>",
"chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\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 {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.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' }}\n{%- endif %}\n",
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"max_length": 2048,
"model_max_length": 2048,
"pad_token": "<|endoftext|>",
"padding_side": "right",
"split_special_tokens": false,
"stride": 0,
"tokenizer_class": "Qwen2Tokenizer",
"truncation_side": "right",
"truncation_strategy": "longest_first",
"unk_token": "<unk>"
}

1
vocab.json Normal file

File diff suppressed because one or more lines are too long