# Codestral Codestral模型支持80+的编程语言 ## 论文 暂无 ## 模型结构 Transformer 架构是一种在自然语言处理(NLP)中广泛应用的深度学习架构。 它的核心特点包括: - 多头注意力机制(Multi-head Attention):这使得模型能够同时关注输入序列的不同位置,并学习到不同的表示。例如,在翻译任务中,能够同时关注源语言句子中的不同词汇与目标语言词汇的关系。 - 前馈神经网络(Feed Forward Network):用于对注意力机制的输出进行进一步的特征提取和转换。 - 位置编码(Positional Encoding):由于 Transformer 本身不具有捕捉序列顺序的天然能力,位置编码为输入序列中的每个位置添加了位置信息,以便模型理解词语的顺序。
## 算法原理 Codestral经过了80多种编程语言的多样化数据集训练,包括最流行的语言,例如 Python、Java、C、C++、JavaScript和Bash。它在Swift和Fortran等更具体的语言上也表现良好。这种广泛的语言基础确保Codestral能够在各种编码环境和项目中为开发人员提供帮助。 Codestral为开发人员节省了时间和精力:它可以完成编码功能、编写测试并使用中间填充机制完成任何部分代码。与Codestral交互将有助于提高开发人员的编码水平并降低出现错误和错误的风险。 ## 环境配置 -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.sourcefind.cn/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进行推理.
模型下载后 默认需存放至weights文件夹中
也可自行更改 inference.py文件中的 model_name 参数
```python HIP_VISIBLE_DEVICES=0 python inference.py ``` ## Result prompt:Write me a function that computes fibonacci in Rust.
### 精度 暂无 ## 应用场景 ### 算法类别 代码生成 ### 热点应用行业 制造,能源,教育 ## 预训练权重 [官方下载](https://huggingface.co/mistralai/Codestral-22B-v0.1) 模型目录结构如下: ```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.sourcefind.cn/codes/modelzoo/codestral_pytorch ## 参考资料 - https://github.com/mistralai/mistral-inference?tab=readme-ov-file - https://huggingface.co/mistralai/Codestral-22B-v0.1