Now-or-Never
commited on
Commit
•
8b7f164
1
Parent(s):
30675c9
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,104 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- zh
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
---
|
7 |
+
---
|
8 |
+
<div style="text-align:center">
|
9 |
+
<h2>📈 CFGPT2: Chinese Financial Assistant with Large Language Model (CFGPT2-7B)</h2>
|
10 |
+
</div>
|
11 |
+
|
12 |
+
## Introduction
|
13 |
+
|
14 |
+
We introduce **CFGPT2**, an open-source language model trained by firstly further pretraining InternLM2 on collected and cleaned Chinese finance text data (CFData-pt), including financial domain-specific data (announcement, finance articles, finance exams, finance news, finance research papers) and general data (Wikipedia), and secondly fine-tuning with knowledge-intensive instruction tuning data (CFData-sft).
|
15 |
+
As for preliminary evaluation, we use CFBenchmark.
|
16 |
+
CFGPT outperforms the baselines on objective and subjective financial tasks compared to several baseline models with similar parameters.
|
17 |
+
|
18 |
+
In this repository, we will share the CFGPT2-7B.
|
19 |
+
|
20 |
+
- [CFGPT2-7B](https://huggingface.co/TongjiFinLab/CFGPT2-7B): The 7B version of our CFGPT2 model.
|
21 |
+
|
22 |
+
## How to Use
|
23 |
+
|
24 |
+
**1. Prepare the code and the environment**
|
25 |
+
|
26 |
+
Clone [CFGPT](https://github.com/TongjiFinLab/CFGPT.git) repository, create a Python environment, and activate it via the following command
|
27 |
+
```bash
|
28 |
+
git clone https://github.com/TongjiFinLab/CFGPT.git
|
29 |
+
cd CFGPT
|
30 |
+
conda create -n env_name python=3.10
|
31 |
+
source activate env_name
|
32 |
+
pip install -r requirements.txt
|
33 |
+
```
|
34 |
+
|
35 |
+
**2. Use CFGPT2-7B**
|
36 |
+
|
37 |
+
|
38 |
+
```python
|
39 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
40 |
+
import torch
|
41 |
+
base_model = 'TongjiFinLab/CFGPT2'
|
42 |
+
device_map = 'cuda:0'
|
43 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True, use_fast=True)
|
44 |
+
model = AutoModelForCausalLM.from_pretrained(
|
45 |
+
base_model,
|
46 |
+
trust_remote_code=True,
|
47 |
+
torch_dtype=torch.bfloat16,
|
48 |
+
device_map=device_map
|
49 |
+
)
|
50 |
+
model = model.eval()
|
51 |
+
|
52 |
+
history = []
|
53 |
+
|
54 |
+
query = "能否给我用中文写一篇有关新能源汽车领域的市场分析报告,写的长一些,细致一些"
|
55 |
+
|
56 |
+
response, history = model.chat(tokenizer = tokenizer, query = query, history = history, max_new_tokens = 1024, do_sample = True, temperature = 0.8, top_p = 0.8, repetition_penalty=1.1, meta_instruction='')
|
57 |
+
print(response)
|
58 |
+
```
|
59 |
+
|
60 |
+
## 简介
|
61 |
+
|
62 |
+
**CFGPT2**是一个开源的语言模型,首先通过在收集和清理的中国金融文本数据(CFData-pt)上利用InternLM2进行继续预训练,包括金融领域特定数据(公告、金融文章、金融考试、金融新闻、金融研究论文)和通用数据(维基百科),然后使用知识密集的指导调整数据(CFData-sft)进行微调。
|
63 |
+
我们使用CFBenchmark进行初步评估。与几个具有相似参数的基线模型相比,CFGPT在多个金融任务上表现优越。
|
64 |
+
|
65 |
+
在这个仓库中,我们将分享以下CFGPT2-7B模型。
|
66 |
+
|
67 |
+
- [CFGPT2-7B](https://huggingface.co/TongjiFinLab/CFGPT2-7B): CFGPT2的7B版本。
|
68 |
+
|
69 |
+
## 如何使用
|
70 |
+
|
71 |
+
**1. 准备代码和环境**
|
72 |
+
|
73 |
+
克隆[CFGPT](https://github.com/TongjiFinLab/CFGPT.git)的仓库,创建一个Python环境,并通过以下命令激活它:
|
74 |
+
```bash
|
75 |
+
git clone https://github.com/TongjiFinLab/CFGPT.git
|
76 |
+
cd CFGPT
|
77 |
+
conda create -n env_name python=3.10
|
78 |
+
source activate env_name
|
79 |
+
pip install -r requirements.txt
|
80 |
+
```
|
81 |
+
|
82 |
+
**2. 使用 CFGPT2-7B**
|
83 |
+
|
84 |
+
```python
|
85 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
86 |
+
import torch
|
87 |
+
base_model = 'TongjiFinLab/CFGPT2'
|
88 |
+
device_map = 'cuda:0'
|
89 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True, use_fast=True)
|
90 |
+
model = AutoModelForCausalLM.from_pretrained(
|
91 |
+
base_model,
|
92 |
+
trust_remote_code=True,
|
93 |
+
torch_dtype=torch.bfloat16,
|
94 |
+
device_map=device_map
|
95 |
+
)
|
96 |
+
model = model.eval()
|
97 |
+
|
98 |
+
history = []
|
99 |
+
|
100 |
+
query = "能否给我用中文写一篇有关新能源汽车领域的市场分析报告,写的长一些,细致一些"
|
101 |
+
|
102 |
+
response, history = model.chat(tokenizer = tokenizer, query = query, history = history, max_new_tokens = 1024, do_sample = True, temperature = 0.8, top_p = 0.8, repetition_penalty=1.1, meta_instruction='')
|
103 |
+
print(response)
|
104 |
+
```
|