upload model folder to repo
Browse files- README.md +93 -0
- deploy/aligner_inference_demo.py +170 -0
- deploy/deploy_aligner.sh +16 -0
- slice_end/added_tokens.json +24 -0
- slice_end/config.json +30 -0
- slice_end/merges.txt +0 -0
- slice_end/pytorch_model.bin +3 -0
- slice_end/special_tokens_map.json +31 -0
- slice_end/tokenizer.json +0 -0
- slice_end/tokenizer_config.json +209 -0
- slice_end/vocab.json +0 -0
README.md
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# Aligner 模型部署指南
|
3 |
+
|
4 |
+
[[Aligner Github]](https://github.com/PKU-Alignment/aligner)
|
5 |
+
|
6 |
+
[[Aligner Website]](https://pku-aligner.github.io/)
|
7 |
+
|
8 |
+
## 前提条件
|
9 |
+
|
10 |
+
- CUDA环境
|
11 |
+
- vLLM 安装完成
|
12 |
+
- 至少8张GPU (0-7)
|
13 |
+
- 足够的GPU内存用于加载模型
|
14 |
+
|
15 |
+
## 配置说明
|
16 |
+
|
17 |
+
在运行部署脚本前,需要配置以下环境变量:
|
18 |
+
|
19 |
+
1. `BASE_MODEL_PATH` - 基础模型路径
|
20 |
+
2. `ALIGNER_MODEL_PATH` - Aligner模型路径
|
21 |
+
3. `BASE_PORT` - 基础模型服务端口(默认8011)
|
22 |
+
4. `ALIGNER_PORT` - Aligner模型服务端口(默认8013)
|
23 |
+
|
24 |
+
## 部署步骤
|
25 |
+
|
26 |
+
1. 打开`deploy_aligner.sh`脚本,填写所需的模型路径:
|
27 |
+
```bash
|
28 |
+
export BASE_MODEL_PATH='您的基础模型路径'
|
29 |
+
export ALIGNER_MODEL_PATH='您的Aligner模型路径'
|
30 |
+
```
|
31 |
+
|
32 |
+
2. 如需要,可修改默认端口:
|
33 |
+
```bash
|
34 |
+
export BASE_PORT=8011
|
35 |
+
export ALIGNER_PORT=8013
|
36 |
+
```
|
37 |
+
|
38 |
+
3. 运行部署脚本:
|
39 |
+
```bash
|
40 |
+
bash deploy_aligner.sh
|
41 |
+
```
|
42 |
+
|
43 |
+
## 部署详情
|
44 |
+
|
45 |
+
该脚本会启动两个vLLM服务:
|
46 |
+
|
47 |
+
1. 基础模型服务:
|
48 |
+
- 使用GPU 0-3
|
49 |
+
- 4路张量并行
|
50 |
+
- 监听`0.0.0.0:$BASE_PORT`
|
51 |
+
- 最大序列长度2048
|
52 |
+
|
53 |
+
2. Aligner模型服务:
|
54 |
+
- 使用GPU 4-7
|
55 |
+
- 4路张量并行
|
56 |
+
- 监听`0.0.0.0:$ALIGNER_PORT`
|
57 |
+
- 最大序列长度2048
|
58 |
+
|
59 |
+
两个服务都配置了以下共同参数:
|
60 |
+
- API密钥:jiayi # 不重要,仅用于初始化
|
61 |
+
- 信任远程代码
|
62 |
+
- 自动数据类型
|
63 |
+
- 强制使用eager模式
|
64 |
+
- 1GB交换空间
|
65 |
+
|
66 |
+
## 验证部署
|
67 |
+
|
68 |
+
脚本运行完成后,可通过以下方式验证服务是否成功启动:
|
69 |
+
|
70 |
+
```bash
|
71 |
+
curl -X GET http://localhost:$BASE_PORT/v1/models
|
72 |
+
curl -X GET http://localhost:$ALIGNER_PORT/v1/models
|
73 |
+
```
|
74 |
+
|
75 |
+
或者使用`netstat`查看端口是否被监听:
|
76 |
+
|
77 |
+
```bash
|
78 |
+
netstat -tuln | grep $BASE_PORT
|
79 |
+
netstat -tuln | grep $ALIGNER_PORT
|
80 |
+
```
|
81 |
+
|
82 |
+
|
83 |
+
## 运行推理
|
84 |
+
更改`aligner_inference_demo.py`中的模型路径,需要与`deploy_aligner.sh`中的模型路径保持一致
|
85 |
+
```
|
86 |
+
aligner_model = ""
|
87 |
+
base_model = ""
|
88 |
+
```
|
89 |
+
|
90 |
+
运行 `aligner_inference_demo.py` 启动Gradio-based的部署脚本
|
91 |
+
```
|
92 |
+
python aligner_inference_demo.py
|
93 |
+
```
|
deploy/aligner_inference_demo.py
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2024 PKU-Alignment Team. All Rights Reserved.
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
# ==============================================================================
|
15 |
+
"""访问文本模型的命令行界面"""
|
16 |
+
|
17 |
+
import argparse
|
18 |
+
import os
|
19 |
+
from openai import OpenAI
|
20 |
+
import gradio as gr
|
21 |
+
import random
|
22 |
+
random.seed(42)
|
23 |
+
|
24 |
+
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
25 |
+
|
26 |
+
# 系统提示词,可以根据需要修改
|
27 |
+
SYSTEM_PROMPT = "你是一个有帮助的AI助手,能够回答用户的问题并提供帮助。"
|
28 |
+
|
29 |
+
# 连接设置
|
30 |
+
openai_api_key = "jiayi" # 不重要,仅用于初始化客户端
|
31 |
+
|
32 |
+
aligner_port = 8013
|
33 |
+
base_port = 8011
|
34 |
+
aligner_api_base = f"http://0.0.0.0:{aligner_port}/v1"
|
35 |
+
base_api_base = f"http://0.0.0.0:{base_port}/v1"
|
36 |
+
|
37 |
+
|
38 |
+
# openai_api_base = "http://0.0.0.0:8009/v1" # 请修改为实际的模型API端口
|
39 |
+
|
40 |
+
# NOTE please modify the model path
|
41 |
+
aligner_model = ""
|
42 |
+
base_model = ""
|
43 |
+
|
44 |
+
aligner_client = OpenAI(
|
45 |
+
api_key = openai_api_key,
|
46 |
+
base_url = aligner_api_base,
|
47 |
+
)
|
48 |
+
|
49 |
+
base_client = OpenAI(
|
50 |
+
api_key = openai_api_key,
|
51 |
+
base_url = base_api_base,
|
52 |
+
)
|
53 |
+
|
54 |
+
# 示例问题
|
55 |
+
# TEXT_EXAMPLES = [
|
56 |
+
# {"text": "介绍一下北京大学的历史"},
|
57 |
+
# {"text": "解释一下什么是深度学习"},
|
58 |
+
# {"text": "写一首关于春天的诗"},
|
59 |
+
# ]
|
60 |
+
TEXT_EXAMPLES = [
|
61 |
+
"介绍一下北京大学的历史",
|
62 |
+
"解释一下什么是深度学习",
|
63 |
+
"写一首关于春天的诗",
|
64 |
+
]
|
65 |
+
|
66 |
+
# # 初始化OpenAI客户端
|
67 |
+
# client = OpenAI(
|
68 |
+
# api_key=openai_api_key,
|
69 |
+
# base_url=openai_api_base,
|
70 |
+
# )
|
71 |
+
|
72 |
+
def text_conversation(text: str, role: str = 'user'):
|
73 |
+
"""创建单条文本消息"""
|
74 |
+
return [{'role': role, 'content': text}]
|
75 |
+
|
76 |
+
|
77 |
+
def question_answering(message: str, history: list):
|
78 |
+
"""处理文本问答(流式输出)"""
|
79 |
+
conversation = text_conversation(SYSTEM_PROMPT, 'system')
|
80 |
+
|
81 |
+
# 处理历史对话记录
|
82 |
+
for past_user_msg, past_bot_msg in history:
|
83 |
+
if past_user_msg:
|
84 |
+
conversation.extend(text_conversation(past_user_msg, 'user'))
|
85 |
+
if past_bot_msg:
|
86 |
+
conversation.extend(text_conversation(past_bot_msg, 'assistant'))
|
87 |
+
|
88 |
+
# 添加当前问题
|
89 |
+
current_question = message
|
90 |
+
conversation.extend(text_conversation(current_question))
|
91 |
+
|
92 |
+
# 调用模型API(启用流式输出)
|
93 |
+
stream = base_client.chat.completions.create(
|
94 |
+
model=base_model,
|
95 |
+
stream=True,
|
96 |
+
messages=conversation,
|
97 |
+
)
|
98 |
+
|
99 |
+
# 流式输出处理
|
100 |
+
total_answer = ""
|
101 |
+
base_section = "🌟 **原始回答:**\n"
|
102 |
+
total_answer += base_section
|
103 |
+
# NOTE 额外用一个base_answer 作为aligner的输入,其他的可以用total_answer 做总的输出
|
104 |
+
base_answer = ""
|
105 |
+
yield total_answer
|
106 |
+
for chunk in stream:
|
107 |
+
if chunk.choices[0].delta.content is not None:
|
108 |
+
base_answer += chunk.choices[0].delta.content
|
109 |
+
total_answer += chunk.choices[0].delta.content
|
110 |
+
yield f"```bash\n{base_section}{base_answer}\n```"
|
111 |
+
|
112 |
+
# 结束原始回答部分,开始aligner部分
|
113 |
+
aligner_section = "\n**Aligner 修正中...**\n\n🌟 **修正后回答:**\n"
|
114 |
+
|
115 |
+
# 创建新的total_answer,不再包含在bash格式中
|
116 |
+
total_answer = f"```bash\n{base_section}{base_answer}\n```{aligner_section}"
|
117 |
+
yield total_answer
|
118 |
+
|
119 |
+
aligner_conversation = text_conversation(SYSTEM_PROMPT,'system')
|
120 |
+
aligner_current_question = f'##Question: {current_question}\n##Answer: {base_answer}\n##Correction: '
|
121 |
+
aligner_conversation.extend(text_conversation(aligner_current_question))
|
122 |
+
aligner_stream = aligner_client.chat.completions.create(
|
123 |
+
model=aligner_model,
|
124 |
+
stream=True,
|
125 |
+
messages=aligner_conversation,
|
126 |
+
)
|
127 |
+
|
128 |
+
aligner_answer = ""
|
129 |
+
for chunk in aligner_stream:
|
130 |
+
if chunk.choices[0].delta.content is not None:
|
131 |
+
aligner_answer += chunk.choices[0].delta.content
|
132 |
+
aligner_answer = aligner_answer.replace('##CORRECTION:', '')
|
133 |
+
yield f"```bash\n{base_section}{base_answer}\n```{aligner_section}{aligner_answer}"
|
134 |
+
|
135 |
+
# print('answer:', answer)
|
136 |
+
# print('current question:', current_question)
|
137 |
+
|
138 |
+
# # 可选:格式化回答(在流式输出完成后处理)
|
139 |
+
# if "**Final Answer**" in answer:
|
140 |
+
# reasoning_content, final_answer = answer.split("**Final Answer**", 1)
|
141 |
+
# if len(reasoning_content) > 5:
|
142 |
+
# answer = f"""🤔 思考过程:\n```bash{reasoning_content}\n```\n✨ ��终答案:\n{final_answer}"""
|
143 |
+
# yield answer
|
144 |
+
|
145 |
+
|
146 |
+
if __name__ == '__main__':
|
147 |
+
parser = argparse.ArgumentParser()
|
148 |
+
parser.add_argument("--port", type=int, default=7860, help="Gradio服务端口")
|
149 |
+
parser.add_argument("--share", default='True',action="store_true", help="是否创建公共链接")
|
150 |
+
parser.add_argument("--api-only", default='False',action="store_true", help="只输出Python API调用示例")
|
151 |
+
args = parser.parse_args()
|
152 |
+
|
153 |
+
# if args.api_only:
|
154 |
+
# print("Python API调用示例输出:")
|
155 |
+
# print(python_api_example())
|
156 |
+
# else:
|
157 |
+
# 创建Gradio界面(启用流式输出)
|
158 |
+
iface = gr.ChatInterface(
|
159 |
+
fn=question_answering,
|
160 |
+
title='Aligner',
|
161 |
+
description='网络安全 Aligner',
|
162 |
+
examples=TEXT_EXAMPLES,
|
163 |
+
theme=gr.themes.Soft(
|
164 |
+
text_size='lg',
|
165 |
+
spacing_size='lg',
|
166 |
+
radius_size='lg',
|
167 |
+
),
|
168 |
+
)
|
169 |
+
|
170 |
+
iface.launch(server_port=args.port, share=args.share)
|
deploy/deploy_aligner.sh
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export BASE_MODEL_PATH='' # Base model path
|
2 |
+
export ALIGNER_MODEL_PATH='' # Aligner model path
|
3 |
+
export BASE_PORT=8011 # Base port
|
4 |
+
export ALIGNER_PORT=8013 # Aligner port
|
5 |
+
|
6 |
+
echo $BASE_MODEL_PATH
|
7 |
+
echo $ALIGNER_MODEL_PATH
|
8 |
+
echo $BASE_PORT
|
9 |
+
echo $ALIGNER_PORT
|
10 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 vllm serve $BASE_MODEL_PATH --host 0.0.0.0 --port $BASE_PORT --max-model-len 2048 --tensor-parallel-size 4 --api-key jiayi --trust-remote-code --dtype auto --enforce-eager --swap-space 1 &
|
11 |
+
CUDA_VISIBLE_DEVICES=4,5,6,7 vllm serve $ALIGNER_MODEL_PATH --host 0.0.0.0 --port $ALIGNER_PORT --max-model-len 2048 --tensor-parallel-size 4 --api-key jiayi --trust-remote-code --dtype auto --enforce-eager --swap-space 1
|
12 |
+
# vllm serve /aifs4su/hansirui/yaodong/models/DeepSeek-R1 --host 0.0.0.0 --port 8009 --max-model-len 12800 --tensor-parallel-size 16 --api-key jiayi --trust-remote-code --dtype auto --enforce-eager --enable-reasoning --reasoning-parser deepseek_r1 --swap-space 1
|
13 |
+
|
14 |
+
echo 'Base Port:' $BASE_PORT
|
15 |
+
echo 'Aligner Port:' $ALIGNER_PORT
|
16 |
+
# CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 vllm serve /aifs4su/yaodong/spring_r1_model/QVQ-72B-Preview --enable-reasoning --reasoning-parser deepseek_r1 --host 0.0.0.0 --port 8009 --max-model-len 12000 --tensor-parallel-size 8 --api-key jiayi
|
slice_end/added_tokens.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"</tool_call>": 151658,
|
3 |
+
"<tool_call>": 151657,
|
4 |
+
"<|box_end|>": 151649,
|
5 |
+
"<|box_start|>": 151648,
|
6 |
+
"<|endoftext|>": 151643,
|
7 |
+
"<|file_sep|>": 151664,
|
8 |
+
"<|fim_middle|>": 151660,
|
9 |
+
"<|fim_pad|>": 151662,
|
10 |
+
"<|fim_prefix|>": 151659,
|
11 |
+
"<|fim_suffix|>": 151661,
|
12 |
+
"<|im_end|>": 151645,
|
13 |
+
"<|im_start|>": 151644,
|
14 |
+
"<|image_pad|>": 151655,
|
15 |
+
"<|object_ref_end|>": 151647,
|
16 |
+
"<|object_ref_start|>": 151646,
|
17 |
+
"<|quad_end|>": 151651,
|
18 |
+
"<|quad_start|>": 151650,
|
19 |
+
"<|repo_name|>": 151663,
|
20 |
+
"<|video_pad|>": 151656,
|
21 |
+
"<|vision_end|>": 151653,
|
22 |
+
"<|vision_pad|>": 151654,
|
23 |
+
"<|vision_start|>": 151652
|
24 |
+
}
|
slice_end/config.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_attn_implementation_autoset": true,
|
3 |
+
"_name_or_path": "/home/yangyaodong/cac_aligner/models/Qwen/Qwen2.5-7B-Instruct",
|
4 |
+
"architectures": [
|
5 |
+
"Qwen2ForCausalLM"
|
6 |
+
],
|
7 |
+
"attention_dropout": 0.0,
|
8 |
+
"eos_token_id": 151645,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 3584,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 18944,
|
13 |
+
"max_position_embeddings": 32768,
|
14 |
+
"max_window_layers": 28,
|
15 |
+
"model_type": "qwen2",
|
16 |
+
"num_attention_heads": 28,
|
17 |
+
"num_hidden_layers": 28,
|
18 |
+
"num_key_value_heads": 4,
|
19 |
+
"pad_token_id": 151643,
|
20 |
+
"rms_norm_eps": 1e-06,
|
21 |
+
"rope_scaling": null,
|
22 |
+
"rope_theta": 1000000.0,
|
23 |
+
"sliding_window": 131072,
|
24 |
+
"tie_word_embeddings": false,
|
25 |
+
"torch_dtype": "bfloat16",
|
26 |
+
"transformers_version": "4.49.0",
|
27 |
+
"use_cache": true,
|
28 |
+
"use_sliding_window": false,
|
29 |
+
"vocab_size": 152064
|
30 |
+
}
|
slice_end/merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
slice_end/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7e55dca3fe79af7f00cb6f59c9223e4920e48b98a41facc31c0927d6b41b32a4
|
3 |
+
size 15231345338
|
slice_end/special_tokens_map.json
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<|im_start|>",
|
4 |
+
"<|im_end|>",
|
5 |
+
"<|object_ref_start|>",
|
6 |
+
"<|object_ref_end|>",
|
7 |
+
"<|box_start|>",
|
8 |
+
"<|box_end|>",
|
9 |
+
"<|quad_start|>",
|
10 |
+
"<|quad_end|>",
|
11 |
+
"<|vision_start|>",
|
12 |
+
"<|vision_end|>",
|
13 |
+
"<|vision_pad|>",
|
14 |
+
"<|image_pad|>",
|
15 |
+
"<|video_pad|>"
|
16 |
+
],
|
17 |
+
"eos_token": {
|
18 |
+
"content": "<|im_end|>",
|
19 |
+
"lstrip": false,
|
20 |
+
"normalized": false,
|
21 |
+
"rstrip": false,
|
22 |
+
"single_word": false
|
23 |
+
},
|
24 |
+
"pad_token": {
|
25 |
+
"content": "<|endoftext|>",
|
26 |
+
"lstrip": false,
|
27 |
+
"normalized": false,
|
28 |
+
"rstrip": false,
|
29 |
+
"single_word": false
|
30 |
+
}
|
31 |
+
}
|
slice_end/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
slice_end/tokenizer_config.json
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_prefix_space": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"151643": {
|
6 |
+
"content": "<|endoftext|>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": false
|
12 |
+
},
|
13 |
+
"151644": {
|
14 |
+
"content": "<|im_start|>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": false
|
20 |
+
},
|
21 |
+
"151645": {
|
22 |
+
"content": "<|im_end|>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false,
|
27 |
+
"special": false
|
28 |
+
},
|
29 |
+
"151646": {
|
30 |
+
"content": "<|object_ref_start|>",
|
31 |
+
"lstrip": false,
|
32 |
+
"normalized": false,
|
33 |
+
"rstrip": false,
|
34 |
+
"single_word": false,
|
35 |
+
"special": false
|
36 |
+
},
|
37 |
+
"151647": {
|
38 |
+
"content": "<|object_ref_end|>",
|
39 |
+
"lstrip": false,
|
40 |
+
"normalized": false,
|
41 |
+
"rstrip": false,
|
42 |
+
"single_word": false,
|
43 |
+
"special": false
|
44 |
+
},
|
45 |
+
"151648": {
|
46 |
+
"content": "<|box_start|>",
|
47 |
+
"lstrip": false,
|
48 |
+
"normalized": false,
|
49 |
+
"rstrip": false,
|
50 |
+
"single_word": false,
|
51 |
+
"special": false
|
52 |
+
},
|
53 |
+
"151649": {
|
54 |
+
"content": "<|box_end|>",
|
55 |
+
"lstrip": false,
|
56 |
+
"normalized": false,
|
57 |
+
"rstrip": false,
|
58 |
+
"single_word": false,
|
59 |
+
"special": false
|
60 |
+
},
|
61 |
+
"151650": {
|
62 |
+
"content": "<|quad_start|>",
|
63 |
+
"lstrip": false,
|
64 |
+
"normalized": false,
|
65 |
+
"rstrip": false,
|
66 |
+
"single_word": false,
|
67 |
+
"special": false
|
68 |
+
},
|
69 |
+
"151651": {
|
70 |
+
"content": "<|quad_end|>",
|
71 |
+
"lstrip": false,
|
72 |
+
"normalized": false,
|
73 |
+
"rstrip": false,
|
74 |
+
"single_word": false,
|
75 |
+
"special": false
|
76 |
+
},
|
77 |
+
"151652": {
|
78 |
+
"content": "<|vision_start|>",
|
79 |
+
"lstrip": false,
|
80 |
+
"normalized": false,
|
81 |
+
"rstrip": false,
|
82 |
+
"single_word": false,
|
83 |
+
"special": false
|
84 |
+
},
|
85 |
+
"151653": {
|
86 |
+
"content": "<|vision_end|>",
|
87 |
+
"lstrip": false,
|
88 |
+
"normalized": false,
|
89 |
+
"rstrip": false,
|
90 |
+
"single_word": false,
|
91 |
+
"special": false
|
92 |
+
},
|
93 |
+
"151654": {
|
94 |
+
"content": "<|vision_pad|>",
|
95 |
+
"lstrip": false,
|
96 |
+
"normalized": false,
|
97 |
+
"rstrip": false,
|
98 |
+
"single_word": false,
|
99 |
+
"special": false
|
100 |
+
},
|
101 |
+
"151655": {
|
102 |
+
"content": "<|image_pad|>",
|
103 |
+
"lstrip": false,
|
104 |
+
"normalized": false,
|
105 |
+
"rstrip": false,
|
106 |
+
"single_word": false,
|
107 |
+
"special": false
|
108 |
+
},
|
109 |
+
"151656": {
|
110 |
+
"content": "<|video_pad|>",
|
111 |
+
"lstrip": false,
|
112 |
+
"normalized": false,
|
113 |
+
"rstrip": false,
|
114 |
+
"single_word": false,
|
115 |
+
"special": false
|
116 |
+
},
|
117 |
+
"151657": {
|
118 |
+
"content": "<tool_call>",
|
119 |
+
"lstrip": false,
|
120 |
+
"normalized": false,
|
121 |
+
"rstrip": false,
|
122 |
+
"single_word": false,
|
123 |
+
"special": false
|
124 |
+
},
|
125 |
+
"151658": {
|
126 |
+
"content": "</tool_call>",
|
127 |
+
"lstrip": false,
|
128 |
+
"normalized": false,
|
129 |
+
"rstrip": false,
|
130 |
+
"single_word": false,
|
131 |
+
"special": false
|
132 |
+
},
|
133 |
+
"151659": {
|
134 |
+
"content": "<|fim_prefix|>",
|
135 |
+
"lstrip": false,
|
136 |
+
"normalized": false,
|
137 |
+
"rstrip": false,
|
138 |
+
"single_word": false,
|
139 |
+
"special": false
|
140 |
+
},
|
141 |
+
"151660": {
|
142 |
+
"content": "<|fim_middle|>",
|
143 |
+
"lstrip": false,
|
144 |
+
"normalized": false,
|
145 |
+
"rstrip": false,
|
146 |
+
"single_word": false,
|
147 |
+
"special": false
|
148 |
+
},
|
149 |
+
"151661": {
|
150 |
+
"content": "<|fim_suffix|>",
|
151 |
+
"lstrip": false,
|
152 |
+
"normalized": false,
|
153 |
+
"rstrip": false,
|
154 |
+
"single_word": false,
|
155 |
+
"special": false
|
156 |
+
},
|
157 |
+
"151662": {
|
158 |
+
"content": "<|fim_pad|>",
|
159 |
+
"lstrip": false,
|
160 |
+
"normalized": false,
|
161 |
+
"rstrip": false,
|
162 |
+
"single_word": false,
|
163 |
+
"special": false
|
164 |
+
},
|
165 |
+
"151663": {
|
166 |
+
"content": "<|repo_name|>",
|
167 |
+
"lstrip": false,
|
168 |
+
"normalized": false,
|
169 |
+
"rstrip": false,
|
170 |
+
"single_word": false,
|
171 |
+
"special": false
|
172 |
+
},
|
173 |
+
"151664": {
|
174 |
+
"content": "<|file_sep|>",
|
175 |
+
"lstrip": false,
|
176 |
+
"normalized": false,
|
177 |
+
"rstrip": false,
|
178 |
+
"single_word": false,
|
179 |
+
"special": false
|
180 |
+
}
|
181 |
+
},
|
182 |
+
"additional_special_tokens": [
|
183 |
+
"<|im_start|>",
|
184 |
+
"<|im_end|>",
|
185 |
+
"<|object_ref_start|>",
|
186 |
+
"<|object_ref_end|>",
|
187 |
+
"<|box_start|>",
|
188 |
+
"<|box_end|>",
|
189 |
+
"<|quad_start|>",
|
190 |
+
"<|quad_end|>",
|
191 |
+
"<|vision_start|>",
|
192 |
+
"<|vision_end|>",
|
193 |
+
"<|vision_pad|>",
|
194 |
+
"<|image_pad|>",
|
195 |
+
"<|video_pad|>"
|
196 |
+
],
|
197 |
+
"bos_token": null,
|
198 |
+
"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",
|
199 |
+
"clean_up_tokenization_spaces": false,
|
200 |
+
"eos_token": "<|im_end|>",
|
201 |
+
"errors": "replace",
|
202 |
+
"extra_special_tokens": {},
|
203 |
+
"model_max_length": 4096,
|
204 |
+
"pad_token": "<|endoftext|>",
|
205 |
+
"padding_side": "right",
|
206 |
+
"split_special_tokens": false,
|
207 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
208 |
+
"unk_token": null
|
209 |
+
}
|
slice_end/vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|