masanorihirano
commited on
Commit
•
9789598
1
Parent(s):
f199c82
Update README.md
Browse files
README.md
CHANGED
@@ -2,4 +2,138 @@
|
|
2 |
license: other
|
3 |
license_name: tongyi-qianwen-license
|
4 |
license_link: LICENSE
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: other
|
3 |
license_name: tongyi-qianwen-license
|
4 |
license_link: LICENSE
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
- ja
|
8 |
+
library_name: transformers
|
9 |
+
pipeline_tag: text-generation
|
10 |
---
|
11 |
+
|
12 |
+
# nekomata-14b-pfn-qfin-inst-merge
|
13 |
+
![Model Merge Image](merge.pnf)
|
14 |
+
|
15 |
+
## Model Description
|
16 |
+
nekomata-14b-pfn-qfin-inst-merge is a merged model using [rinna/nekomata-14b](https://huggingface.co/rinna/nekomata-14b/tree/main), [rinna/nekomata-14b-instruction](https://huggingface.co/rinna/nekomata-14b-instruction), and [pfnet/nekomata-14b-pfn-qfin](https://huggingface.co/pfnet/nekomata-14b-pfn-qfin).
|
17 |
+
This is the instruction model, which is good at generating answers for instructions.
|
18 |
+
This model is released under [Tongyi Qianwen LICENSE AGREEMENT](https://github.com/QwenLM/Qwen/blob/e8e15962d897714944773cca57fa2e460a3655e8/Tongyi%20Qianwen%20LICENSE%20AGREEMENT).
|
19 |
+
|
20 |
+
The research article will also be released later.
|
21 |
+
|
22 |
+
# Benchmarking
|
23 |
+
The benchmark score is obtained using [Japanese Language Model Financial Evaluation Harness](https://github.com/pfnet-research/japanese-lm-fin-harness)
|
24 |
+
For the benchmark, 0-shot is used.
|
25 |
+
```
|
26 |
+
using default prompts
|
27 |
+
| Task |Metric| nekomaba-14b | -pfn-qfin |
|
28 |
+
|----------------|------|------|---|------|------|---|------|
|
29 |
+
|chabsa |f1 |0.7381| | |0.7428| | |
|
30 |
+
|cma_basics |acc |0.4737|± |0.0821|0.5263|± |0.0821|
|
31 |
+
|cpa_audit |acc |0.1608|± |0.0184|0.1633|± |0.0186|
|
32 |
+
|fp2 |acc |0.3389|± |0.0217|0.3642|± |0.0221|
|
33 |
+
|security_sales_1|acc |0.4561|± |0.0666|0.5614|± |0.0663|
|
34 |
+
|----------------|------|------|---|------|------|---|------|
|
35 |
+
|OVER ALL | |0.4335 |0.4716 |
|
36 |
+
|
37 |
+
using default prompts
|
38 |
+
| Task |Metric| -instruction | OURS |
|
39 |
+
|----------------|------|------|---|------|------|---|------|
|
40 |
+
|chabsa |f1 |0.8963| | |0.8429| | |
|
41 |
+
|cma_basics |acc |0.5000|± |0.0822|0.5789|± |0.0812|
|
42 |
+
|cpa_audit |acc |0.1859|± |0.0195|0.2136|± |0.0206|
|
43 |
+
|fp2 |acc |0.3642|± |0.0221|0.3579|± |0.0220|
|
44 |
+
|security_sales_1|acc |0.5088|± |0.0668|0.4737|± |0.0667|
|
45 |
+
|----------------|------|------|---|------|------|---|------|
|
46 |
+
|OVER ALL | |0.4910 |0.4939 |
|
47 |
+
|
48 |
+
using prompts v0.3 (instruction prompts)
|
49 |
+
| Task |Metric| -instruction | OURS |
|
50 |
+
|----------------|------|------|---|------|------|---|------|
|
51 |
+
|chabsa |f1 |0.8658| | |0.8620| | |
|
52 |
+
|cma_basics |acc |0.4737|± |0.0821|0.5000|± |0.0822|
|
53 |
+
|cpa_audit |acc |0.2085|± |0.0204|0.2060|± |0.0203|
|
54 |
+
|fp2 |acc |0.3663|± |0.0221|0.3663|± |0.0221|
|
55 |
+
|security_sales_1|acc |0.5263|± |0.0667|0.5614|± |0.0663|
|
56 |
+
|----------------|------|------|---|------|------|---|------|
|
57 |
+
|OVER ALL | |0.4881 |0.4991 |
|
58 |
+
```
|
59 |
+
## Usage
|
60 |
+
Install the required libraries as follows:
|
61 |
+
```sh
|
62 |
+
>>> python -m pip install numpy sentencepiece torch transformers accelerate transformers_stream_generator tiktoken einops
|
63 |
+
```
|
64 |
+
|
65 |
+
Execute the following python code:
|
66 |
+
```python
|
67 |
+
import torch
|
68 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
69 |
+
|
70 |
+
tokenizer = AutoTokenizer.from_pretrained("pfnet/nekomata-14b-pfn-qfin-inst-merge", trust_remote_code=True)
|
71 |
+
|
72 |
+
# Use GPU with bf16 (recommended for supported devices)
|
73 |
+
# model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-14b-pfn-qfin-inst-merge", device_map="auto", trust_remote_code=True, bf16=True)
|
74 |
+
|
75 |
+
# Use GPU with fp16
|
76 |
+
# model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-14b-pfn-qfin-inst-merge", device_map="auto", trust_remote_code=True, fp16=True)
|
77 |
+
|
78 |
+
# Use GPU with fp32
|
79 |
+
# model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-14b-pfn-qfin-inst-merge", device_map="auto", trust_remote_code=True, fp32=True)
|
80 |
+
|
81 |
+
# Use CPU
|
82 |
+
# model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-14b-pfn-qfin-inst-merge", device_map="cpu", trust_remote_code=True)
|
83 |
+
|
84 |
+
# Automatically select device and precision
|
85 |
+
model = AutoModelForCausalLM.from_pretrained("pfnet/nekomata-14b-pfn-qfin-inst-merge", device_map="auto", trust_remote_code=True)
|
86 |
+
|
87 |
+
text = """以下は、タスクを説明する指示と、文脈のある入力の組み合わせです。要求を適切に満たす応答を書きなさい。
|
88 |
+
|
89 |
+
### 指示:
|
90 |
+
次の質問に答えてください。
|
91 |
+
|
92 |
+
### 入力:
|
93 |
+
デリバティブ取引のリスク管理について教えてください。
|
94 |
+
|
95 |
+
### 応答:"""
|
96 |
+
input_ids = tokenizer(text, return_tensors="pt").input_ids.to(model.device)
|
97 |
+
with torch.no_grad():
|
98 |
+
generated_tokens = model.generate(
|
99 |
+
inputs=input_ids,
|
100 |
+
max_new_tokens=512,
|
101 |
+
do_sample=False,
|
102 |
+
temperature=1.0,
|
103 |
+
repetition_penalty=1.1,
|
104 |
+
top_k=50,
|
105 |
+
pad_token_id=tokenizer.pad_token_id,
|
106 |
+
bos_token_id=tokenizer.bos_token_id,
|
107 |
+
eos_token_id=tokenizer.eos_token_id
|
108 |
+
)[0]
|
109 |
+
generated_text = tokenizer.decode(generated_tokens)
|
110 |
+
print(generated_text.split("### 応答:")[1])
|
111 |
+
# デリバティブ取引では��原資産の価格変動が大きく影響します。そのため、リスク管理においては、原資産の価格変動リスクを適切にコントロールすることが重要となります。具体的には、ポジションサイズやレバレッジの制限、ヘッジ手法の活用などが挙げられます。また、市場情報の収集・分析を行い、適切なタイミングでポジションを調整することも大切です。さらに、取引先の信用リスクにも注意が必要であり、相手方の財務状況や信用度などを確認し、必要に応じて保証や担保を設定することが求められます。以上のようなリスク管理を行うことで、デリバティブ取引における損失リスクを最小化することができます。ただし、リスク管理はあくまで自己責任であるため、十分な知識と経験を持つことが望まれます。また、金融機関等の専門家によるアドバイスを受けることも有効です。以上が、デリバティブ取引におけるリスク管理の概要です。詳細については、金融庁や日本証券業協会などの公式サイトをご参照ください。
|
112 |
+
```
|
113 |
+
|
114 |
+
## Model Details
|
115 |
+
- Model size: 14B
|
116 |
+
- Context length: 2048
|
117 |
+
- Developed by: Preferred Networks, Inc
|
118 |
+
- Model type: Causal decoder-only
|
119 |
+
- Language(s): Japanese and English
|
120 |
+
- License: [Tongyi Qianwen LICENSE AGREEMENT](https://github.com/QwenLM/Qwen/blob/e8e15962d897714944773cca57fa2e460a3655e8/Tongyi%20Qianwen%20LICENSE%20AGREEMENT)
|
121 |
+
|
122 |
+
## Bias, Risks, and Limitations
|
123 |
+
nekomata-14b-pfn-qfin-inst-merge is a new technology that carries risks with use.
|
124 |
+
Testing conducted to date has been in English and Japanese, and has not covered, nor could it cover all scenarios.
|
125 |
+
For these reasons, as with all LLMs, nekomata-14b-pfn-qfin-inst-merge’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate, biased or other objectionable responses to user prompts.
|
126 |
+
This model is not designed for legal, tax, investment, financial, or other advice.
|
127 |
+
Therefore, before deploying any applications of nekomata-14b-pfn-qfin, developers should perform safety testing and tuning tailored to their specific applications of the model.
|
128 |
+
|
129 |
+
## How to cite
|
130 |
+
TBD
|
131 |
+
|
132 |
+
## Contributors
|
133 |
+
Preferred Networks, Inc.
|
134 |
+
- Masanori Hirano
|
135 |
+
- Kentaro Imajo
|
136 |
+
|
137 |
+
# License
|
138 |
+
[Tongyi Qianwen LICENSE AGREEMENT](https://github.com/QwenLM/Qwen/blob/e8e15962d897714944773cca57fa2e460a3655e8/Tongyi%20Qianwen%20LICENSE%20AGREEMENT)
|
139 |
+
|