README.md 2.89 KB
Newer Older
zzg_666's avatar
zzg_666 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Granite
## 论文
暂无

## 模型简介
Granite-4.0-H-Small是一款基于Granite-4.0-H-Small-Base精调的320亿参数长上下文指令模型,采用开源指令数据集与企业内部合成数据集相结合的方式进行训练。该模型通过结构化对话格式,综合运用了监督微调(SFT)、基于强化学习的模型对齐(RL Alignment)以及模型融合(Model Merging)等多种技术进行开发。Granite 4.0 指令系列模型具备更优的指令跟随(Instruction Following)能力和工具调用(Tool Calling)功能,从而显著提升了其在企业级应用场景中的效能。  
在许多智能体工作流中,指令不仅需要被可靠执行,更需要精准转换为有效的工具调用,这一点至关重要。为此,Granite-4.0-H-Small 在伯克利函数调用榜单第三版(BFCLv3)的评测中,能够与体量更大、无论开源或闭源的模型保持同等性能水准。更重要的是,它在这一竞争组别中实现了无可匹敌的成本优势。  
<div align=center>
    <img src="./doc/granite.png"/>
</div>


## 环境依赖  

| 软件 | 版本 |
| :------: | :------: |
| DTK | 25.04.2 |
| python | 3.10 |
| transformers | 4.57.3 |
| pytorch | 2.7.1+das.opt1.dtk25042 |

推荐使用镜像:
- 挂载地址`-v``{docker_name}``{docker_image_name}`根据实际模型情况修改

```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 200g --network=host --name {docker_name} --privileged --device=/dev/kfd --device=/dev/dri --device=/dev/mkfd --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal/:/opt/hyhal/:ro {imageID} bash

zzg_666's avatar
修改  
zzg_666 committed
29
cd /your_code_path/granite_pytorch
zzg_666's avatar
zzg_666 committed
30
pip install transformers
zzg_666's avatar
修改  
zzg_666 committed
31
pip install accelerate
zzg_666's avatar
zzg_666 committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
```
更多镜像可前往[光源](https://sourcefind.cn/#/service-list)下载使用。

关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.sourcefind.cn/tool/)开发者社区下载安装
## 数据集

暂无

## 训练
暂无

## 推理

### transformers
#### 单机推理
```bash
export HIP_VISIBLE_DEVICES=0,1,2,3
python  granite.py
```

## 效果展示

<div align=center>
    <img src="./doc/result.png"/>
</div>

### 精度
DCU与GPU精度一致,推理框架:pytorch。

## 预训练权重
| 模型名称  | 权重大小  | DCU型号  | 最低卡数需求 |下载地址|
|:-----:|:----------:|:----------:|:---------------------:|:----------:|
| granite-4.0-h-small | 32B | K100AI | 4 | [下载地址](https://huggingface.co/ibm-granite/granite-4.0-h-small) |

## 源码仓库及问题反馈
- https://developer.sourcefind.cn/codes/modelzoo/granite_pytorch

## 参考资料
- https://github.com/ibm-granite/granite-4.0-language-models
- https://www.ibm.com/new/announcements/ibm-granite-4-0-hyper-efficient-high-performance-hybrid-models