README.md 2.75 KB
Newer Older
dcuai's avatar
dcuai committed
1
# Grok-1
Rayyyyy's avatar
Rayyyyy committed
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Grok-1是由xAI从头开始训练的3140亿个参数混合专家模型。

## 论文
暂无

## 模型结构
Grok-1 是一个8个专家(2个活跃)的混合专家(MoE)模型。
<div align=center>
    <img src="./doc/MoE.png"/>
</div>

## 算法原理
Grok-1目前的设计规格如下:
- **参数:** 314B
- **体系结构:** Mixture of 8 Experts (MoE)
- **专家利用:** 2 experts used per token
- **层数:** 64
- **多头注意力:** 48 个 head 用于查询,8 个用于键 / 值(KV)
- **嵌入大小:** 6,144
- **Tokenization:** tokenizer 词汇大小为 131,072
- **附加特性:**
  - Rotary embeddings (RoPE)
  - Supports activation sharding and 8-bit 量化
- **最大序列长度(上下文):** 8,192 tokens

## 环境配置
### Docker(方法一)
-v 路径、docker_name和imageID根据实际情况修改

```bash
docker pull image.sourcefind.cn:5000/dcu/admin/base/jax:0.4.23-ubuntu20.04-dtk24.04-py310
docker run -it -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal:/opt/hyhal:ro --shm-size=200G --privileged=true --device=/dev/kfd --device=/dev/dri/ --group-add video --name docker_name imageID bash

cd /your_code_path/grok-1_jax
pip install -r requirements.txt
```

### Dockerfile(方法二)
```bash
cd ./docker
docker build --no-cache -t grok1:latest .

docker run -it -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal:/opt/hyhal:ro --shm-size=200G --privileged=true --device=/dev/kfd --device=/dev/dri/ --group-add video --name docker_name imageID bash

cd /your_code_path/grok-1_jax
```

### Anaconda(方法三)
chenzk's avatar
chenzk committed
50
关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.sourcefind.cn/tool/)开发者社区下载安装。
Rayyyyy's avatar
Rayyyyy committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

```
DTK驱动:dtk24.04
python:python3.10
jax: ≥ 0.4.23
gcc: ≥ 9.4.0
```
`Tips:以上dtk驱动、python等DCU相关工具版本需要严格一一对应`

其它非深度学习库参照requirements.txt安装:
```bash
pip install -r requirements.txt
```

## 数据集
暂无

## 训练
官方github未开源微调代码

## 推理
推理所需硬件最低配置参考:

device(s):K100 64G 8卡

Driver version: 5.16.29.22.20

Vbios version: 5.223.001200k.548101

linux: ubuntu20.04

处理器: Hygon C86 7375 32-core Processor

CPU(s):128

内存:≥ 600G, 1T以上最优

```bash
python run.py
```

## result
Rayyyyy's avatar
Rayyyyy committed
93
日志信息可以参考**run.log**文件,测试结果如下图所示。
Rayyyyy's avatar
Rayyyyy committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<div align=center>
    <img src="./doc/end.png"/>
</div>

### 精度
暂无

## 应用场景
### 算法类别
对话问答

### 热点应用行业
制造,广媒,家居,教育

## 预训练权重
chenzk's avatar
chenzk committed
109
[grok-1](https://huggingface.co/xai-org/grok-1)
Rayyyyy's avatar
Rayyyyy committed
110
111

## 源码仓库及问题反馈
chenzk's avatar
chenzk committed
112
- https://developer.sourcefind.cn/codes/modelzoo/grok-1_jax
Rayyyyy's avatar
Rayyyyy committed
113
114
115

## 参考资料
- https://github.com/xai-org/grok-1