Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
FinGPT-glm_pytorch
Commits
8cfd170e
"server/vscode:/vscode.git/clone" did not exist on "5e5d8766a2c2a28b166fbecf7543f19a4bf2c9d8"
Commit
8cfd170e
authored
May 22, 2024
by
wanglch
Browse files
Upload New File
parent
6c7db732
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
170 additions
and
0 deletions
+170
-0
README.md
README.md
+170
-0
No files found.
README.md
0 → 100644
View file @
8cfd170e
# FinGPT
## 论文
-
[
论文地址] [Blueprint of FinGPT
](
https://arxiv.org/abs/2306.06031
)
## 模型结构
GLM是一个开放的双语(中英)双向密集模型,使用通用语言模型(GLM)算法进行预训练。GLM是一种基于Transformer的语言模型,以自回归空白填充为训练目标。
<div
align=
center
>
<img
src=
"./figs/transformer.jpg"
/>
</div>
## 算法原理
模型基于
[
General Language Model (GLM)
](
https://github.com/THUDM/GLM
)
架构,GLM是一种基于Transformer的语言模型,以自回归空白填充为训练目标,同时具备自回归和自编码能力。
<div
align=
center
>
<img
src=
"./figs/GLM.png"
/>
</div>
## 环境配置
### Docker(方法一)
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu22.04-dtk23.10.1-py310
docker run -it -v /path/your_code_data/:/path/your_code_data/ -v /opt/hyhal/:/opt/hyhal/:ro --shm-size=64G --privileged=true --device=/dev/kfd --device=/dev/dri/ --group-add video --name fingpt <your imageID> bash
docker exec -it fingpt bash
cd /path/your_code_data/FinGPT
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install deepspeed-0.12.3+gitfe61783.abi0.dtk2310.torch2.1.0a0-cp310-cp310-manylinux2014_x86_64.whl
```
### Dockerfile(方法二)
```
cd /path/your_code_data/FinGPT/docker
docker build --no-cache -t fingpt:latest .
docker run --shm-size=64G --name fingpt -v /opt/hyhal:/opt/hyhal:ro --privileged=true --device=/dev/kfd --device=/dev/dri/ --group-add video -v /path/your_code_data/:/path/your_code_data/ -it fingpt bash
cd /path/your_code_data/FinGPT
pip install deepspeed-0.12.3+gitfe61783.abi0.dtk2310.torch2.1.0a0-cp310-cp310-manylinux2014_x86_64.whl
```
### Anaconda(方法三)
```
DTK驱动:dtk23.10
python:python3.10
torch: 2.1.0
transformers: >=4.37.2
deepspped: 0.12.3
datasets: 2.14.3
accelerate: 0.27.2
peft: 0.10.0
trl: 0.8.1
gradio: >=3.38.0,<=4.0.0
```
`Tips:以上dtk驱动、python、paddle等DCU相关工具版本需要严格一一对应`
其它非深度学习库参照requirements.txt安装:
```
conda create -n fingpt python=3.10
conda activate fingpt
cd /path/your_code_data/FinGPT
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple
pip install deepspeed-0.12.3+gitfe61783.abi0.dtk2310.torch2.1.0a0-cp310-cp310-manylinux2014_x86_64.whl
```
## 数据集
-
[huggingface数据集下载地址]
<https://huggingface.co/FinGPT>
网站提供12中不同任务的数据集用于训练
需要训练数据转换为必要的json格式,数据格式为:
```
{
"instruction": "描述原子的结构。",
"input": "",
"output": "原子是物质的基本单位,它由三种基本粒子组成:质子、中子和电子。质子和中子形成原子核,位于原子中心,核外的电子围绕着原子核运动。\n\n原子结构具有层次性。原子核中,质子带正电,中子不带电(中性)。原子核非常小且致密,占据了原子总质量的绝大部分。电子带负电,通常围绕核运动,形成若干层次,称为壳层或电子层。电子数量与质子数量相等,使原子呈电中性。\n\n电子在每个壳层中都呈规律分布,并且不同壳层所能容纳的电子数也不同。在最里面的壳层一般只能容纳2个电子,其次一层最多可容纳8个电子,再往外的壳层可容纳的电子数逐层递增。\n\n原子核主要受到两种相互作用力的影响:强力和电磁力。强力的作用范围非常小,主要限制在原子核内,具有极强的吸引作用,使核子(质子和中子)紧密结合在一起。电磁力的作用范围较大,主要通过核外的电子与原子核相互作用,发挥作用。\n\n这就是原子的基本结构。原子内部结构复杂多样,不同元素的原子核中质子、中子数量不同,核外电子排布分布也不同,形成了丰富多彩的化学世界。"
},
```
可以使用
**data_process.py**
进行数据处理
```
python data_process.py
```
项目中已提供用于试验训练的迷你数据集,训练数据目录结构如下,用于正常训练的完整数据集请按此目录结构进行制备:
```
── dataset
│ ├── dataset_new
│ ├── data-00000-of-00001.arrow
│ ├── dataset_info.json
│ └── state.json
│ └── twitter-financial-news-sentiment
│ ├── sent_dataset_meta.txt
│ ├── sent_train.csv
│ └── sent_valid.csv
│ └── dataset_new.json
│ └── dataset_new.jsonl
│
```
## 训练
### 单机多卡
```
bash multi_dcu_train.sh
```
### 单机单卡
```
bash single_dcu_train.sh
```
## 推理
**注:[FinGPT预训练模型权重下载地址](https://www.modelscope.cn/models/Wangluochao/FinGPT_ChatGLM2-6B/files)直接下载模型文件至新建文件夹'/FinGPT/FinGPT_mt_chatglm2-6b-merged'路径下进行推理。**
```
python inference_FinGPT.py
```
## result
### 多任务英语推理
<div
align=
center
>
<img
src=
"./figs/multi_tasks_en.png"
/>
</div>
### 单任务中文推理
<div
align=
center
>
<img
src=
"./figs/single_task_cn.png"
/>
</div>
### 精度
测试数据:
[
twitter-financial-news-sentiment
](
../FinGPT/dataset/dataset_new.jsonl
)
,使用的加速卡:V100S/K100。
根据测试结果情况填写表格:
根据测试结果情况填写表格:
| xxx | train_loss | train_runtime |eval_los |eval_runtime |
| :------: | :------: | :------: | :------: |:------: |
| V100s | 0.371248 | 4445.348 | 0.06542 | 30.5495 |
| K100 | 0.371148 | 4018.4874 | 0.06536 | 53.1593 |
## 应用场景
### 算法类别
`对话问答`
### 热点应用行业
`金融, 教育, 政府, 科研`
## 预训练权重
-
[modelscope预训练模型下载地址]
<https://www.modelscope.cn/models/Wangluochao/FinGPT_ChatGLM2-6B/files>
可下载带有lora后缀的预训练权重,使用本人编写的
**merge_model.py**
文件进行模型合并。
-
[
huggingface预训练模型及数据集下载地址
](
https://huggingface.co/FinGPT
)
-
[
FinGPT_ChatGLM2-6B预训练模型下载地址
](
https://www.modelscope.cn/models/Wangluochao/FinGPT_ChatGLM2-6B/files
)
## 源码仓库及问题反馈
-
http://developer.hpccube.com/codes/modelzoo/fingpt.git
## 参考资料
-
[
https://github.com/AI4Finance-Foundation/FinGPT
](
https://github.com/AI4Finance-Foundation/FinGPT
)
-
[
https://github.com/AI4Finance-Foundation/FinGPT/blob/master/FinGPT_Training_LoRA_with_ChatGLM2_6B_for_Beginners.ipynb
](
https://github.com/AI4Finance-Foundation/FinGPT/blob/master/FinGPT_Training_LoRA_with_ChatGLM2_6B_for_Beginners.ipynb
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment