"vscode:/vscode.git/clone" did not exist on "090d8237d30befeb2326aad628ca80757adfea81"
Commit 96933b30 authored by dengjb's avatar dengjb
Browse files

update codes

parent bc92aa99
Pipeline #1311 canceled with stages
experiments/*
results/*
tb_logger/*
wandb/*
tmp/*
modify_model.py
hat/version.py
*.DS_Store
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# DeepSeek-coder-V2_pytorch
# DeepSeek-Coder
DeepSeek Coder V2系列基于Deepseek-V2改进而来,有16B和236B两个版本。
## 论文
`DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligence`<br>
[deepseek-coder-V2](https://arxiv.org/pdf/2406.11931)
## 模型结构
DeepSeek-Coder-V2模型采用和Deepseek-V2同样的MoE架构
<div align=center>
<img src="./assets/model_framework.png"/>
</div>
## 算法原理
DeepSeek-V2对模型框架进行了全方位的创新,提出了媲美MHA的MLA(Multi-head Latent Attention)架构,大幅减少计算量和推理显存;自研Sparse结构DeepSeekMoE进一步将计算量降低到极致,两者结合最终实现模型性能跨级别的提升。
## 环境配置
-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/deepseek-coder-v2_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 deepseek-coder-v2: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>
模型下载地址[快速下载](http://113.200.138.88:18080/aimodels/deepseek-ai) [官方下载](http://113.200.138.88:18080/aimodels/deepseek-ai)
```python
HIP_VISIBLE_DEVICES=0 python inference.py
```
## Result
prompt:write a quick sort algorithm in python.<br>
<div align=center>
<img src="./assets/result.png"/>
</div>
### 精度
暂无
## 应用场景
### 算法类别
代码生成
### 热点应用行业
制造,能源,教育
## 预训练权重
模型目录结构如下:
```bash
# deepseek-coder-6.7b-instruct/
├── config.json
├── generation_config.json
├── LICENSE
├── model-00001-of-00002.safetensors
├── model-00002-of-00002.safetensors
├── model.safetensors.index.json
├── pytorch_model-00001-of-00002.bin
├── pytorch_model-00002-of-00002.bin
├── pytorch_model.bin.index.json
├── README.md
├── tokenizer_config.json
└── tokenizer.json
```
## 源码仓库及问题反馈
- https://developer.hpccube.com/codes/modelzoo/deepseek-coder-v2_pytorch
## 参考资料
- https://github.com/deepseek-ai/DeepSeek-Coder-V2?tab=readme-ov-file
- https://huggingface.co/deepseek-ai
FROM image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-centos7.6-dtk24.04-py310
\ No newline at end of file
icon.png

62.1 KB

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
import time
tokenizer = AutoTokenizer.from_pretrained("./DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("./DeepSeek-Coder-V2-Lite-Instruct", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
messages=[
{ 'role': 'user', 'content': "write a quick sort algorithm in python."}
]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
# tokenizer.eos_token_id is the id of <|EOT|> token
outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, top_k=50, top_p=0.95, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
\ No newline at end of file
# 模型唯一标识
modelCode=743
# 模型名称
modelName=deepseek-coder-v2_pytorch
# 模型描述
modelDescription=DeepSeek-Coder-V2代码生成方向大模型,支持338种编程语言
# 应用场景
appScenario=推理,训练,代码生成,制造,能源,教育
# 框架类型
frameType=pytorch
#torch>=2.0
#tokenizers>=0.14.0
#transformers==4.35.0
#accelerate
#deepspeed==0.12.2
sympy==1.12
pebble
timeout-decorator
accelerate
attrdict
tqdm
datasets
tensorboardX
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