🦉 github • 🤗 Hugging Face • 🤖 ModelScope • 🐾 gitee • 💬 WeChat
TeleChat2.5 是 TeleChat 系列新版通用问答模型,由中国电信人工智能研究院(TeleAI)基于国产算力研发训练,包括了 TeleChat2.5-35B 与 TeleChat2.5-115B。TeleChat2.5 基于最新强化的 TeleBase2.5 系列模型进行训练,在理科、通用问答、Function Call等任务上有显著的效果提升。TeleChat2.5 的微调方法延续了 TeleChat2 系列,具体请参考 TeleChat2。
- 为了提高模型训练数据的数量和质量,TeleChat2.5 在训练过程中采用了大量理科学科和编程领域的合成数据。在合成过程中,为了减少错误信息的引入,主要以基于知识点或知识片段的教育类知识合成为主。
-
TeleChat2.5 采用了多阶段课程学习策略,在训练过程中逐步提升理科和编程类高密度知识数据的比例。每个训练阶段都使用比前一阶段质量更高、难度更大的数据,以实现持续的模型优化。
-
在最终训练阶段,为了平衡模型在各个维度的能力表现,我们选取了不同训练阶段效果较优的多个模型,并基于各模型的综合表现进行参数加权融合,其中权重分配与模型性能呈正相关。
我们采用分阶段优化的模型训练策略:
-
融合优化阶段:整合复杂推理与通用问答能力,针对语言理解、数理逻辑等薄弱任务进行解构重组。通过重构任务框架并融合多维度解题思路,生成优化后的通用答案集。此阶段答案长度会适度增加,并基于优化数据实施微调训练。
-
能力强化阶段:针对数理逻辑与编程类任务,通过注入结构化解题思路,结合基于规则的强化学习奖励机制,显著提升模型对复杂任务的理解与处理能力。
-
泛化提升阶段:面向安全合规、指令响应、函数调用、数学推理、代码生成等十余种任务类型进行系统性强化学习增强,全面提升模型的通用任务处理能力。
模型版本 | 下载链接 |
---|---|
TeleChat2.5-35B | modelscope |
TeleChat2.5-115B | modelscope |
模型 | MATH-500 | AlignBench | BFCL(avg v1&v2) |
---|---|---|---|
Qwen2.5-32B | 82 | 7.39 | 81.11 |
Qwen2.5-72B | 82 | 7.62 | 79.15 |
Qwen3-32B(通用) | 83 | 8.23 | 81.84 |
GPT-4o-1120 | 75 | 7.49 | 78.66 |
TeleChat2-35B | 65 | 6.97 | 75.32 |
TeleChat2-115B | 75 | 7.56 | 77.47 |
TeleChat2.5-35B | 85 | 7.73 | 78.28 |
TeleChat2.5-115B | 87 | 7.93 | 83.39 |
TeleChat2.5 系列模型支持使用 transformers
库进行推理,示例如下:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
tokenizer = AutoTokenizer.from_pretrained("TeleChat2.5/TeleChat2.5-35B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
"TeleChat2.5/TeleChat2.5-35B",
trust_remote_code=True,
torch_dtype=torch.bfloat16,
device_map="auto"
)
prompt = "生抽和酱油的区别是什么?"
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
TeleChat2.5 系列模型支持使用 ModelScope 推理,示例如下:
import os
import torch
from modelscope import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
tokenizer = AutoTokenizer.from_pretrained('TeleChat2.5/TeleChat2.5-35B', trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained('TeleChat2.5/TeleChat2.5-35B', trust_remote_code=True, device_map="auto",
torch_dtype=torch.bfloat16)
prompt = "生抽与老抽的区别?"
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
TeleChat2.5 支持使用 vLLM 进行部署与推理加速,示例如下:
from transformers import AutoTokenizer
from vllm import LLM, SamplingParams
tokenizer = AutoTokenizer.from_pretrained("TeleChat2.5/TeleChat2.5-35B", trust_remote_code=True)
sampling_params = SamplingParams(temperature=0.0, repetition_penalty=1.01, max_tokens=8192)
llm = LLM(model="TeleChat2.5/TeleChat2.5-35B", trust_remote_code=True, tensor_parallel_size=4, dtype="bfloat16")
prompt = "生抽和酱油的区别是什么?"
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
outputs = llm.generate([text], sampling_params)
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
您可以借助 vLLM,构建一个与 OpenAI API 兼容的 API 服务。请按照以下所示运行命令:
vllm serve TeleChat2.5/TeleChat2.5-35B \
--trust-remote-code \
--dtype bfloat16 \
--disable-custom-all-reduce
然后,您可以与 TeleChat2.5 进行对话:
from openai import OpenAI
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8000/v1"
client = OpenAI(api_key=openai_api_key, base_url=openai_api_base)
chat_response = client.chat.completions.create(
model="TeleChat2.5/TeleChat2.5-35B",
messages=[
{"role": "user", "content": "生抽和酱油的区别是什么?"},
],
temperature=0.0,
max_tokens=8192,
extra_body={
"repetition_penalty": 1.01,
"skip_special_tokens": False,
"spaces_between_special_tokens": False,
},
)
print("Chat response:", chat_response)
TeleChat2.5系列模型均进行了国产化算力适配,具体信息可见
我们在此声明,不要使用 TeleChat2.5 系列模型及其衍生模型进行任何危害国家社会安全或违法的活动。同时,我们也要求使用者不要将 TeleChat2.5 系列模型用于没有安全审查和备案的互联网服务。我们希望所有使用者遵守上述原则,确保科技发展在合法合规的环境下进行。
我们已经尽我们所能,来确保模型训练过程中使用的数据的合规性。然而,尽管我们已经做出了巨大的努力,但由于模型和数据的复杂性,仍有可能存在一些无法预见的问题。因此,如果由于使用 TeleChat2.5 系列开源模型而导致的任何问题,包括但不限于数据安全问题、公共舆论风险,或模型被误导、滥用、传播或不当利用所带来的任何风险和问题,我们将不承担任何责任。
如需引用我们的工作,请使用如下 reference:
@misc{wang2024telechat,
title={TeleChat Technical Report},
author={Zihan Wang and Xinzhang Liu and Shixuan Liu and Yitong Yao and Yuyao Huang and Zhongjiang He and Xuelong Li and Yongxiang Li and Zhonghao Che and Zhaoxi Zhang and Yan Wang and Xin Wang and Luwen Pu and Huihan Xu and Ruiyu Fang and Yu Zhao and Jie Zhang and Xiaomeng Huang and Zhilong Lu and Jiaxin Peng and Wenjun Zheng and Shiquan Wang and Bingkai Yang and Xuewei he and Zhuoru Jiang and Qiyi Xie and Yanhan Zhang and Zhongqiu Li and Lingling Shi and Weiwei Fu and Yin Zhang and Zilu Huang and Sishi Xiong and Yuxiang Zhang and Chao Wang and Shuangyong Song},
year={2024},
eprint={2401.03804},
archivePrefix={arXiv},
primaryClass={cs.CL}
}