模型简介
模型特点
模型能力
使用案例
license: apache-2.0 language:
- 中文
- 英文 library_name: transformers tags:
- 奇虎360
- 360智脑
- 预训练模型
360智脑3 (360Zhinao)
欢迎访问360智脑官网 https://ai.360.com获取更多体验
模型介绍
🎉🎉🎉 近期奇虎360开源升级了自研的7B参数模型360智脑3-7B,现已在Github开源社区360zhinao3正式发布并开放免费商用。模型能力获得全面提升,相比10B以下小参数模型,360智脑3-7B在多个基准测试中取得了第一名的优异成绩。
- 360智脑3-7B基础版
- 360智脑3-7B指令版
- 360智脑3-7B-O1.5长思维链版
模型核心亮点:
360智脑3-7B是在360智脑2-7B基础上使用7000亿高质量token持续预训练的升级版本。两代模型结构完全一致,模型性能提升主要源于训练数据质量的提升。
版本更新
- [2025.04.14] 🔥🔥🔥正式发布360智脑3系列模型,同步开源360智脑3-7B、360智脑3-7B-Instruct以及长思维链模型360智脑3-7B-O1.5
- [2024.11.18] 发布360智脑2-7B,同步开放Base模型和4K/32K/360K文本长度的Chat模型
- [2024.05.23] 发布360智脑-search和360智脑-1.8B-Reranking两款模型,分别在C-MTEB榜单的检索和重排任务中获得第一名
- [2024.05.20] 基于llama3扩展发布llama3-8B-360智脑-360k-Instruct🤗
- [2024.04.12] 发布360智脑-7B v1.0版本,包含基础模型和4K/32K/360K上下文窗口的三个对话模型,技术报告详见arXiv
目录索引
模型下载
参数量 | 模型名称 | BF16版本 |
---|---|---|
7B | 360智脑3-7B | 🤗 |
7B | 360智脑3-7B指令版 | 🤗 |
7B | 360智脑3-7B-O1.5长思维链版 | 🤗 |
性能评测
基础模型
我们使用开源工具opencompass对模型进行多维度评测。模型在基准测试平均得分位居10B以下参数模型首位,在同尺寸模型中具有竞争力。
类型 | 测试集 | 语言 | glm4-9b | Qwen2.5-7B | internlm2.5-7b | Yi1.5-9B | gemma2-9b | Llama3.1-8B | 360智脑2-7B | 360智脑3-7B |
考试 | ceval | 中文 | 75.83 | 81.41 | 77.71 | 73.51 | 56.36 | 51.67 | 83.04 | 84.7 |
mmlu | 英文 | 75.5 | 75.5 | 71.55 | 71.43 | 72.22 | 66.75 | 67.84 | 75.42 | |
cmmlu | 中文 | 74.24 | 81.79 | 78.77 | 74.2 | 58.89 | 52.49 | 73.8 | 82.17 | |
ARC-c | 英文 | 94.92 | 80 | 85.08 | 87.46 | 77.63 | 80.68 | 87.12 | 88.14 | |
ARC-e | 英文 | 98.41 | 84.83 | 95.24 | 94.53 | 78.84 | 89.77 | 92.77 | 94 | |
语言 | WiC | 英文 | 51.57 | 52.82 | 50.78 | 50.63 | 50.47 | 50 | 49.84 | 50.31 |
WSC | 英文 | 68.27 | 68.27 | 69.23 | 66.35 | 68.27 | 67.31 | 65.38 | 71.15 | |
知识 | BoolQ | 英文 | 81.8 | 83.88 | 89.51 | 84.46 | 85.6 | 82.2 | 88.29 | 88.38 |
commonsense_qa | 英文 | 71.17 | 73.22 | 68.55 | 71.58 | 68.47 | 71.25 | 69.78 | 71.33 | |
理解 | C3 | 中文 | 91.51 | 92 | 93.04 | 85.86 | 81.64 | 83.51 | 93.26 | 92.77 |
race-middle | 英文 | 91.99 | 91.02 | 92.06 | 91.16 | 88.09 | 81.69 | 90.46 | 90.04 | |
race-high | 英文 | 90.71 | 87.91 | 90.08 | 88.34 | 82.08 | 78.73 | 86.74 | 85.96 | |
lcsts | 中文 | 18.29 | 15.82 | 15.96 | 16.49 | 10.62 | 17.29 | 18.61 | 18.85 | |
eprstmt-dev | 中文 | 91.88 | 86.88 | 91.25 | 91.88 | 48.12 | 83.12 | 90 | 92.50 | |
lambada | 英文 | 71.67 | 71.14 | 69.98 | 70.64 | 75.43 | 74.23 | 72.56 | 68.17 | |
推理 | hellaswag | 英文 | 70.25 | 72.76 | 70.38 | 71.55 | 66.83 | 74.65 | 71.49 | 73.61 |
siqa | 英文 | 81.73 | 72.52 | 78.97 | 76.2 | 58.96 | 64.18 | 77.12 | 79.02 | |
bbh | 英文 | 73.68 | 54.63 | 59.43 | 67.86 | 68.45 | 59.9 | 46.54 | 73.74 | |
代码 | humaneval | 英文 | 69.51 | 75 | 60.37 | 26.22 | 5.49 | 27.44 | 60.98 | 64.63 |
mbpp | 英文 | 60 | 60 | 43.6 | 56.8 | 51.2 | 42.6 | 54 | 67.80 | |
数学 | math | 英文 | 26.86 | 38 | 27.14 | 27.06 | 28.52 | 15.32 | 38.34 | 37.60 |
gsm8k | 英文 | 78.54 | 79.76 | 52.54 | 71.11 | 73.09 | 56.25 | 75.51 | 78.77 | |
综合 | 中文平均 | 70.35 | 71.58 | 71.35 | 68.39 | 51.13 | 57.62 | 71.74 | 74.20 | |
全项平均 | 73.11 | 71.78 | 69.60 | 68.88 | 61.60 | 62.32 | 70.61 | 74.83 |
指令模型
我们在IFEval、MT-bench、CF-Bench三个主流评测上对360智脑3-7B-Instruct模型进行了评估对比。MT-bench和CFBench均位居同级别开源模型首位,具有较强的竞争力。在IFEval(prompt strict)上仅次于glm4-9b,在7B尺寸中得分最高。
模型 | MT-bench | IFEval(严格提示) | CFBench(CSR,ISR,PSR) | ||
---|---|---|---|---|---|
Qwen2.5-7B-Instruct | 8.07 | 0.556 | 0.81 | 0.46 | 0.57 |
Yi-9B-16k-Chat | 7.44 | 0.455 | 0.75 | 0.4 | 0.52 |
GLM4-9B-Chat | 8.08 | 0.634 | 0.82 | 0.48 | 0.61 |
InternLM2.5-7B-Chat | 7.39 | 0.540 | 0.78 | 0.4 | 0.54 |
360智脑2-7B-Chat-4k | 7.86 | 0.577 | 0.8 | 0.44 | 0.57 |
360智脑3-7B-Instruct | 8.17 | 0.626 | 0.83 | 0.52 | 0.64 |
长思维链模型
我们使用此前开源的智脑Light-R1方法对360智脑3-7B-Instruct继续微调了Long COT,以及RFT和GRPO。相比最新的OpenThinker2-7B仍有一定差距,但超越此前所有基于通用Qwen2.5-7B-Instruct的模型。
模型 | 日期 | 基础模型 | AIME24 | AIME25 | GPQA钻石级 |
---|---|---|---|---|---|
OpenThinker2-7B | 25.4.3 | Qwen2.5-7B-Instruct | 50 | 33.3 | 49.3 |
OpenThinker-7B | 25.1.28 | Qwen2.5-7B-Instruct | 31.3 | 23.3 | 42.4 |
360智脑3-7B-O1.5 | 25.4.14 | 360智脑3-7B-Instruct | 54.2 | 36.3 | 40.0 |
OpenR1-Qwen-7B | 25.2.11 | Qwen2.5-Math-7B-Instruct | 48.7 | 34.7 | 21.2 |
DeepSeek-R1-Distill-Qwen-7B | 25.1.20 | Qwen2.5-Math-7B-Instruct | 57.3 | 33.3 | 47.3 |
Light-R1-7B-DS | 25.3.12 | DeepSeek-R1-Distill-Qwen-7B | 59.1 | 44.3 | 49.4 |
Areal-boba-RL-7B | 25.3.31 | DeepSeek-R1-Distill-Qwen-7B | 61.9 | 48.3 | 47.6 |
快速开始
通过简单示例展示如何使用🤗Transformers快速调用360智脑3-7B、360智脑3-7B-Instruct和360智脑3-7B-O1.5
🤗 Transformers
基础模型调用示例
from transformers import AutoTokenizer, AutoModelForCausalLM
from transformers.generation import GenerationConfig
MODEL_NAME_OR_PATH = "qihoo360/360Zhinao3-7B"
tokenizer = AutoTokenizer.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True).cuda()
generation_config = GenerationConfig.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True)
generation_config.max_new_tokens = 1024
inputs = tokenizer('中国二十四节气\n1. 立春\n2. 雨水\n3. 惊蛰\n4. 春分\n5. 清明\n', return_tensors='pt')
inputs = inputs.to(model.device)
pred = model.generate(input_ids=inputs["input_ids"], generation_config=generation_config)
print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
指令模型调用示例
from transformers import AutoTokenizer, AutoModelForCausalLM
from transformers.generation import GenerationConfig
MODEL_NAME_OR_PATH = "qihoo360/360Zhinao3-7B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True).cuda()
generation_config = GenerationConfig.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True)
generation_config.max_new_tokens = 2048
messages = []
#第一轮对话
print(f"用户: 简单介绍一下刘德华")
messages.append({"role": "user", "content": "简单介绍一下刘德华"})
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
pred = model.generate(input_ids=input_ids, generation_config=generation_config)
response = tokenizer.decode(pred.cpu()[0][len(input_ids[0]):], skip_special_tokens=True)
messages.append({"role": "assistant", "content": response})
print(f"AI助手: {response}")
#第二轮对话
print(f"用户: 他有什么代表作?")
messages.append({"role": "user", "content": "他有什么代表作?"})
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
pred = model.generate(input_ids=input_ids, generation_config=generation_config)
response = tokenizer.decode(pred.cpu()[0][len(input_ids[0]):], skip_special_tokens=True)
messages.append({"role": "assistant", "content": response})
print(f"AI助手: {response}")
长思维链模型调用示例
import re
import json
from transformers import AutoTokenizer, AutoModelForCausalLM
from transformers.generation import GenerationConfig
MODEL_NAME_OR_PATH = "qihoo360/360Zhinao3-7B-O1.5"
tokenizer = AutoTokenizer.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True).cuda()
generation_config = GenerationConfig.from_pretrained(
MODEL_NAME_OR_PATH,
trust_remote_code=True)
generation_config.max_new_tokens = 2048
def extract_thinking_and_answer(input_string):
thinking, answer = "", ""
# 提取答案
pattern_answer = r'.*</think>(.*)$'
match_answer = re.search(pattern_answer, input_string, re.S)
if match_answer:
answer = match_answer.group(1)
else:
return thinking, input_string
# 提取思考过程
pattern_thinking = r'<think>(.*?)</think>'
match_thinking = re.search(pattern_thinking, input_string, re.S)
if match_thinking:
thinking = match_thinking.group(1)
return thinking, answer
messages = []
messages.append({"role": "user", "content": "现有一笼子,里面有鸡和兔子若干只,数一数,共有头14个,腿38条,求鸡和兔子各有多少只?"})
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
pred = model.generate(input_ids=input_ids, generation_config=generation_config)
response = tokenizer.decode(pred.cpu()[0][len(input_ids[0]):], skip_special_tokens=True)
thinking, answer = extract_thinking_and_answer(response)
messages.append({"role": "assistant", "content": answer, "reasoning_content": thinking})
print(json.dumps(messages, ensure_ascii=False, indent=4))
模型推理
服务部署
vLLM安装
推荐使用 vllm==0.6.0
版本。
若使用CUDA 12.1和PyTorch 2.1环境,可直接通过以下命令安装:
pip install vllm==0.6.0
其他环境请参考vLLM官方安装指南
安装完成后执行以下操作:
-
将
vllm/zhinao.py
复制到vllm安装目录(在python/conda环境中)的vllm/model_executor/models
下 -
然后在
vllm/model_executor/models/__init__.py
中添加一行"ZhinaoForCausalLM": ("zhinao", "ZhinaoForCausalLM"),
vLLM服务启动
启动服务:
python -m vllm.entrypoints.openai.api_server \
--model qihoo360/360Zhinao3-7B-O1.5 \
--served-model-name 360Zhinao3-7B-O1.5 \
--port 8360 \
--host 0.0.0.0 \
--dtype bfloat16 \
--tensor-parallel-size 4 \
--gpu-memory-utilization 0.8 \
--trust-remote-code
使用curl请求服务:
curl http://localhost:8360/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "360Zhinao3-7B-O1.5",
"max_tokens": 200,
"top_k": -1,
"top_p": 0.8,
"temperature": 1.0,
"presence_penalty": 0.0,
"frequency_penalty": 0.0,
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "你好"}
],
"stop": [
"<eod>",
"<|im_end|>",
"<|im_start|>"
]
}'
使用python请求服务:
from openai import OpenAI
# 设置OpenAI的API密钥和API基础路径以使用vLLM的API服务
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8360/v1"
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
chat_response = client.chat.completions.create(
model="360Zhinao3-7B-O1.5",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "你好"},
],
stop=[
"<eod>",
"<|im_end|>",
"<|im_start|>"
],
presence_penalty=0.0,
frequency_penalty=0.0
)
print("Chat response:", chat_response)
如需启用重复惩罚,建议设置
presence_penalty
和frequency_penalty
而非repetition_penalty
模型微调
训练数据
训练数据示例:data/training_data_sample.json
。该示例数据是从multiturn_chat_0.8M中采样1万条并转换格式得到。
数据格式:
[
{
"id": 1,
"conversations": [
{
"from": "system",
"value": "You are a helpful assistant."
},
{
"from": "user",
"value": "您好啊"
},
{
"from": "assistant",
"value": "你好!我今天能为您做些什么?有什么问题或需要帮助吗? 我在这里为您提供服务。"
}
]
}
]
微调脚本
set -x
HOSTFILE=hostfile
DS_CONFIG=./finetune/ds_config_zero2.json
# 参数设置
学习率=5e-6
训练轮数=3
最大长度=32768
批大小=4
节点数=1
GPU数=8
主节点端口=29500
是否拼接=False # 是否将数据拼接至最大长度(MAX_LEN)
数据路径="./data/training_data_sample.json"
模型路径="qihoo360/360Zhinao3-7B-Instruct"
输出目录="./outputs/"
deepspeed --hostfile ${HOSTFILE} \
--master_port ${MASTER_PORT} \
--num_nodes ${NUM_NODES} \
--num_gpus ${NUM_GPUS} \
finetune.py \
--report_to "tensorboard" \
--data_path ${DATA_PATH} \
--model_name_or_path ${MODEL_PATH} \
--output_dir ${OUTPUT_DIR} \
--model_max_length ${MAX_LEN} \
--num_train_epochs ${EPOCHS} \
--per_device_train_batch_size ${BATCH_SIZE} \
--gradient_accumulation_steps 1 \
--save_strategy steps \
--save_steps 200 \
--learning_rate ${LR} \
--lr_scheduler_type cosine \
--adam_beta1 0.9 \
--adam_beta2 0.95 \
--adam_epsilon 1e-8 \
--max_grad_norm 1.0 \
--weight_decay 0.1 \
--warmup_ratio 0.01 \
--gradient_checkpointing True \
--bf16 True \
--tf32 True \
--deepspeed ${DS_CONFIG} \
--is_concat ${IS_CONCAT} \
--logging_steps 1 \
--log_on_each_node False
bash finetune/ds_finetune.sh
- 配置
HOSTFILE
可切换单机/多机训练 - 配置
ds_config
可切换zero1/zero2/zero3模式 fp16, bf16
可配置混合精度训练,建议bf16与预训练模型保持一致is_concat
配置训练数据是否进行拼接
许可协议
本仓库源码遵循Apache 2.0开源协议。
360智脑3开源模型支持免费商用,您无需提交商业使用申请。


