Commit d1ce5ffb authored by zzg_666's avatar zzg_666
Browse files

first commit

parents
MIT License
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# VibeThinker
## 论文
[VibeThinker](https://github.com/WeiboAI/VibeThinker/blob/main/VibeThinker-1.5B.pdf)
## 模型简介
VibeThinker-1.5B 是一个拥有15亿参数的密集型语言模型。其总训练成本仅为7800美元,却在推理性能上与更大的模型如GPT OSS-20B Medium相当。
<div align=center>
<img src="./doc/bench0.png"/>
</div>
**关键性能数据:**
- **数学推理:** 在三大数学基准AIME24、AIME25和HMMT25上,它的得分分别为80.3、74.4和50.4,均超过了参数量超过其400倍的初始DeepSeek R1模型(得分分别为79.8、70.0和41.7)。
- **代码生成:** 它在LiveCodeBench v5上的得分为55.9,在v6上的得分为51.1。其v6得分略高于Magistral Medium(50.3),突显了其强大的推理性能。
<div align=center>
<img src="./doc/bench1.png"/>
</div>
## 环境依赖
| 软件 | 版本 |
| :------: | :------: |
| DTK | 25.04.2 |
| python | 3.10.12 |
| transformers | 4.57.1 |
| flash-attn | 2.6.1+das.opt1.dtk2504 |
| torch | 2.7.1+das.opt1.dtk25042 |
| triton | 3.1+das.opt1.3c5d12d.dtk25041 |
当前仅支持镜像:
- 挂载地址`-v`根据实际模型情况修改
```bash
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.7.1-ubuntu22.04-dtk25.04.2-py3.10-alpha
docker run -it --shm-size 60g --network=host --name vibethinker --privileged --device=/dev/kfd --device=/dev/dri --device=/dev/mkfd --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root -v /opt/hyhal/:/opt/hyhal/:ro -v /path/your_code_path/:/path/your_code_path/ image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.7.1-ubuntu22.04-dtk25.04.2-py3.10-alpha bash
pip install transformers>=4.54.0
pip install accelerate
cd whl
pip install flash_attn*.whl
```
更多镜像可前往[光源](https://sourcefind.cn/#/service-list)下载使用。
关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.sourcefind.cn/tool/)开发者社区下载安装。
## 数据集
暂无
## 训练
暂无
## 推理
### transformers
#### 单机推理
```bash
export HIP_VISIBLE_DEVICES=0
python VibeThinker.py
```
## 效果展示
<div align=center>
<img src="./doc/result.png"/>
</div>
### 精度
DCU与GPU精度一致,推理框架:pytorch。
## 预训练权重
| 模型名称 | 权重大小 | DCU型号 | 最低卡数需求 |下载地址|
|:-----:|:----------:|:----------:|:---------------------:|:----------:|
| VibeThinker-1.5B | 1.5B | K100AI | 1 | [下载地址](https://huggingface.co/WeiboAI/VibeThinker-1.5B) |
## 源码仓库及问题反馈
- https://developer.sourcefind.cn/codes/modelzoo/vibethinker-pytorch
## 参考资料
- https://github.com/WeiboAI/VibeThinker
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
class VibeThinker:
def __init__(self, model_path):
self.model_path = model_path
self.model = AutoModelForCausalLM.from_pretrained(
self.model_path,
low_cpu_mem_usage=True,
torch_dtype="bfloat16",
device_map="auto"
)
self.tokenizer = AutoTokenizer.from_pretrained(self.model_path, trust_remote_code=True)
def infer_text(self, prompt):
messages = [
{"role": "user", "content": prompt}
]
text = self.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
model_inputs = self.tokenizer([text], return_tensors="pt").to(self.model.device)
text = self.tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = self.tokenizer([text], return_tensors="pt").to(self.model.device)
generation_config = dict(
max_new_tokens=40960,
do_sample=True,
temperature=0.6, # 0.6 or 1.0, you can set it according to your needs
top_p=0.95,
top_k=None # in vLLM or SGlang, please set top_k to -1, it means skip top_k for sampling
)
generated_ids = self.model.generate(
**model_inputs,
generation_config=GenerationConfig(**generation_config)
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = self.tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
return response
if __name__ == '__main__':
model = VibeThinker('WeiboAI/VibeThinker-1.5B')
prompt = '介绍下自己'
print(model.infer_text(prompt))
icon.png

76.3 KB

# 模型唯一标识
modelCode=1843
# 模型名称
modelName=vibethinker-pytorch
# 模型描述
modelDescription=VibeThinker-1.5B 是一个拥有15亿参数的密集型语言模型。其总训练成本仅为7800美元,却在推理性能上与更大的模型如GPT OSS-20B Medium相当。
# 运行过程
processType=推理
# 算法类别
appCategory=对话问答
# 框架类型
frameType=pytorch
# 加速卡类型
accelerateType=K100AI
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment