README.md 3.77 KB
Newer Older
dengjb's avatar
dengjb committed
1
2
3
4
# Codestral
Codestral模型支持80+的编程语言
## 论文
暂无
dengjb's avatar
dengjb committed
5

dengjb's avatar
dengjb committed
6
## 模型结构
dengjb's avatar
dengjb committed
7
基于Transformer架构。
dengjb's avatar
dengjb committed
8
9
10
<div align=center>
    <img src="./assets/model_framework.png"/>
</div>
dengjb's avatar
dengjb committed
11

dengjb's avatar
dengjb committed
12
13
14
15
## 算法原理
Codestral使用了80+的编程语言的多样化数据集进行训练,并且可以完成编码功能、编写测试等有助于提高开发人员的编码水平并降低出现错误的风险。


dengjb's avatar
dengjb committed
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
## 环境配置
-v 路径、docker_name和imageID根据实际情况修改

### Docker(方法一)

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

cd /your_code_path/codestral_pytorch
pip install -r requirements.txt
pip install -U huggingface_hub hf_transfer
export HF_ENDPOINT=https://hf-mirror.com
```

### Dockerfile(方法二)

```bash
cd docker
docker build --no-cache -t codestral:latest .
docker run -it -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal/:/opt/hyhal/:ro --shm-size=80G --privileged=true --device=/dev/kfd --device=/dev/dri/ --group-add video --name docker_name imageID bash

cd /your_code_path/deepseek-v2_pytorch
pip install -r requirements.txt
pip install -U huggingface_hub hf_transfer
export HF_ENDPOINT=https://hf-mirror.com

```

### Anaconda(方法三)
关于本项目DCU显卡所需的特殊深度学习库可从[光合](https://developer.hpccube.com/tool/)开发者社区下载安装。
```
DTK驱动: dtk24.04
python: python3.10
torch: 2.1.0
```
`Tips:以上dtk驱动、python、torch等DCU相关工具版本需要严格一一对应`

其它非深度学习库安装方式如下:
```bash
pip install -r requirements.txt
pip install -U huggingface_hub hf_transfer
export HF_ENDPOINT=https://hf-mirror.com
```

## 数据集
暂无

## 训练
暂无

## 推理
基于Huggingface's Transformers进行推理.<br>
模型下载后 默认需存放至weights文件夹中<br>
也可自行更改 inference.py文件中的 model_name 参数<br>
dengjb's avatar
dengjb committed
71

dengjb's avatar
dengjb committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
```python
HIP_VISIBLE_DEVICES=0 python inference.py
```
## Result
prompt:Write me a function that computes fibonacci in Rust.<br>
<div align=center>
    <img src="./assets/result.png"/>
</div>

### 精度
暂无

## 应用场景
### 算法类别
代码生成

### 热点应用行业
制造,能源,教育

## 预训练权重
dengjb's avatar
dengjb committed
92
93
94
95
96
97
98
99

预训练权重快速下载中心:[SCNet AIModels](http://113.200.138.88:18080/aimodels) 

项目中的预训练权下载地址[Codestral-22B-v0.1](http://113.200.138.88:18080/aimodels/mistralai/Codestral-22B-v0.1)

[官方下载](https://huggingface.co/mistralai/Codestral-22B-v0.1)


dengjb's avatar
dengjb committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
模型目录结构如下:
```bash
└── Codestral-22B-v0.1
    ├── config.json
    ├── consolidated.safetensors
    ├── generation_config.json
    ├── model-00001-of-00009.safetensors
    ├── model-00002-of-00009.safetensors
    ├── model-00003-of-00009.safetensors
    ├── model-00004-of-00009.safetensors
    ├── model-00005-of-00009.safetensors
    ├── model-00006-of-00009.safetensors
    ├── model-00007-of-00009.safetensors
    ├── model-00008-of-00009.safetensors
    ├── model-00009-of-00009.safetensors
    ├── model.safetensors.index.json
    ├── params.json
    ├── README.md
    ├── special_tokens_map.json
    ├── tokenizer_config.json
    ├── tokenizer.json
    ├── tokenizer.model
    └── tokenizer.model.v3
```

## 源码仓库及问题反馈
- https://developer.hpccube.com/codes/modelzoo/codestral_pytorch

## 参考资料
- https://github.com/mistralai/mistral-inference?tab=readme-ov-file
- https://huggingface.co/mistralai/Codestral-22B-v0.1