Update README.md
Browse files
README.md
CHANGED
@@ -10,14 +10,14 @@ Model Developers: Sogang University SGEconFinlab
|
|
10 |
|
11 |
### Model Description
|
12 |
|
13 |
-
This model is a language model specialized in economics and finance. This was learned with various economic/finance-related data
|
14 |
-
The data
|
|
|
15 |
|
16 |
-
- **Developed by:** Sogang University SGEconFinlab
|
17 |
-
- **
|
18 |
-
- **
|
19 |
-
- **
|
20 |
-
- **Base Model:** yanolja/KoSOLAR-10.7B-v0.2
|
21 |
|
22 |
### Model Sources [optional]
|
23 |
|
@@ -38,32 +38,62 @@ The data source is listed below, and since the data was used for research/policy
|
|
38 |
[More Information Needed]
|
39 |
|
40 |
|
41 |
-
[More Information Needed]
|
42 |
-
|
43 |
-
### Out-of-Scope Use
|
44 |
-
|
45 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
46 |
-
|
47 |
-
[More Information Needed]
|
48 |
-
|
49 |
-
## Bias, Risks, and Limitations
|
50 |
-
|
51 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
52 |
-
|
53 |
-
[More Information Needed]
|
54 |
-
|
55 |
-
### Recommendations
|
56 |
-
|
57 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
58 |
-
|
59 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
60 |
-
|
61 |
## How to Get Started with the Model
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
## Training Details
|
68 |
|
69 |
### Training Data
|
|
|
10 |
|
11 |
### Model Description
|
12 |
|
13 |
+
This model is a language model specialized in economics and finance. This was learned with various economic/finance-related data.
|
14 |
+
The data sources are listed below, and we are not releasing the data we trained on because it was used for research/policy purposes.
|
15 |
+
If you wish to use the original data rather than our training data, please contact the original author directly for permission to use it.
|
16 |
|
17 |
+
- **Developed by:** [Sogang University SGEconFinlab]
|
18 |
+
- **Language(s) (NLP):** [Ko/En]
|
19 |
+
- **License:** [apache-2.0]
|
20 |
+
- **Base Model:** [yanolja/KoSOLAR-10.7B-v0.2]
|
|
|
21 |
|
22 |
### Model Sources [optional]
|
23 |
|
|
|
38 |
[More Information Needed]
|
39 |
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
## How to Get Started with the Model
|
42 |
|
43 |
+
peft_model_id = "SGEcon/KoSOLAR-10.7B-v0.2_fin_v4"
|
44 |
+
config = PeftConfig.from_pretrained(peft_model_id)
|
45 |
+
bnb_config = BitsAndBytesConfig(
|
46 |
+
load_in_4bit=True,
|
47 |
+
bnb_4bit_use_double_quant=True,
|
48 |
+
bnb_4bit_quant_type="nf4",
|
49 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
50 |
+
)
|
51 |
+
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, quantization_config=bnb_config, device_map={"":0})
|
52 |
+
model = PeftModel.from_pretrained(model, peft_model_id)
|
53 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
54 |
+
model.eval()
|
55 |
+
|
56 |
+
|
57 |
+
import re
|
58 |
+
|
59 |
+
def gen(x):
|
60 |
+
inputs = tokenizer(f"### ์ง๋ฌธ: {x}\n\n### ๋ต๋ณ:", return_tensors='pt', return_token_type_ids=False)
|
61 |
+
|
62 |
+
# ๋ฐ์ดํฐ๋ฅผ GPU๋ก ์ด๋(์ฌ์ฉ ๊ฐ๋ฅํ ๊ฒฝ์ฐ)
|
63 |
+
inputs = {k: v.to(device="cuda" if torch.cuda.is_available() else "cpu") for k, v in inputs.items()}
|
64 |
+
|
65 |
+
gened = model.generate(
|
66 |
+
**inputs,
|
67 |
+
max_new_tokens=256,
|
68 |
+
early_stopping=True,
|
69 |
+
num_return_sequences=4, # 4๊ฐ์ ๋ต๋ณ์ ์์ฑํ๋๋ก ์ค์ (๋ต๋ณ ๊ฐ์ ์ค์ ๊ฐ๋ฅ)
|
70 |
+
do_sample=True,
|
71 |
+
eos_token_id=tokenizer.eos_token_id, # EOS ํ ํฐ ID ์ฌ์ฉ
|
72 |
+
temperature=0.9,
|
73 |
+
top_p=0.8,
|
74 |
+
top_k=50
|
75 |
+
)
|
76 |
+
|
77 |
+
complete_answers = []
|
78 |
+
for gen_seq in gened:
|
79 |
+
decoded = tokenizer.decode(gen_seq, skip_special_tokens=True).strip()
|
80 |
+
|
81 |
+
# "### ๋ต๋ณ:" ๋ฌธ์์ด ์ดํ์ ํ
์คํธ๋ง ์ถ์ถ
|
82 |
+
first_answer_start_idx = decoded.find("### ๋ต๋ณ:") + len("### ๋ต๋ณ:")
|
83 |
+
temp_answer = decoded[first_answer_start_idx:].strip()
|
84 |
+
|
85 |
+
# ๋ ๋ฒ์งธ "### ๋ต๋ณ:" ๋ฌธ์์ด ์ด์ ๊น์ง์ ํ
์คํธ๋ง ์ถ์ถ
|
86 |
+
second_answer_start_idx = temp_answer.find("### ๋ต๋ณ:")
|
87 |
+
if second_answer_start_idx != -1:
|
88 |
+
complete_answer = temp_answer[:second_answer_start_idx].strip()
|
89 |
+
else:
|
90 |
+
complete_answer = temp_answer # ๋ ๋ฒ์งธ "### ๋ต๋ณ:"์ด ์๋ ๊ฒฝ์ฐ ์ ์ฒด ๋ต๋ณ ๋ฐํ
|
91 |
+
|
92 |
+
complete_answers.append(complete_answer)
|
93 |
+
|
94 |
+
return complete_answers
|
95 |
+
|
96 |
+
|
97 |
## Training Details
|
98 |
|
99 |
### Training Data
|