SGEcon commited on
Commit
0dca21d
โ€ข
1 Parent(s): b13807a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -94
README.md CHANGED
@@ -14,18 +14,10 @@ This model is a language model specialized in economics and finance. This was le
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
-
24
- <!-- Provide the basic links for the model. -->
25
-
26
- - **Repository:** [More Information Needed]
27
- - **Paper [optional]:** [More Information Needed]
28
- - **Demo [optional]:** [More Information Needed]
29
 
30
  ## Uses
31
 
@@ -41,57 +33,57 @@ If you wish to use the original data rather than our training data, please conta
41
  ## How to Get Started with the Model
42
 
43
 
44
- peft_model_id = "SGEcon/KoSOLAR-10.7B-v0.2_fin_v4"
45
- config = PeftConfig.from_pretrained(peft_model_id)
46
- bnb_config = BitsAndBytesConfig(
47
- load_in_4bit=True,
48
- bnb_4bit_use_double_quant=True,
49
- bnb_4bit_quant_type="nf4",
50
- bnb_4bit_compute_dtype=torch.bfloat16
51
- )
52
- model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, quantization_config=bnb_config, device_map={"":0})
53
- model = PeftModel.from_pretrained(model, peft_model_id)
54
- tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
55
- model.eval()
56
 
57
 
58
- import re
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
@@ -152,43 +144,6 @@ def gen(x):
152
  #### Summary
153
 
154
 
155
-
156
- ## Model Examination [optional]
157
-
158
- <!-- Relevant interpretability work for the model goes here -->
159
-
160
- [More Information Needed]
161
-
162
- ## Environmental Impact
163
-
164
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
165
-
166
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
167
-
168
- - **Hardware Type:** [More Information Needed]
169
- - **Hours used:** [More Information Needed]
170
- - **Cloud Provider:** [More Information Needed]
171
- - **Compute Region:** [More Information Needed]
172
- - **Carbon Emitted:** [More Information Needed]
173
-
174
- ## Technical Specifications [optional]
175
-
176
- ### Model Architecture and Objective
177
-
178
- [More Information Needed]
179
-
180
- ### Compute Infrastructure
181
-
182
- [More Information Needed]
183
-
184
- #### Hardware
185
-
186
- [More Information Needed]
187
-
188
- #### Software
189
-
190
- [More Information Needed]
191
-
192
  ## Citation [optional]
193
 
194
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
 
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
  ## Uses
23
 
 
33
  ## How to Get Started with the Model
34
 
35
 
36
+ peft_model_id = "SGEcon/KoSOLAR-10.7B-v0.2_fin_v4"
37
+ config = PeftConfig.from_pretrained(peft_model_id)
38
+ bnb_config = BitsAndBytesConfig(
39
+ load_in_4bit=True,
40
+ bnb_4bit_use_double_quant=True,
41
+ bnb_4bit_quant_type="nf4",
42
+ bnb_4bit_compute_dtype=torch.bfloat16
43
+ )
44
+ model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, quantization_config=bnb_config, device_map={"":0})
45
+ model = PeftModel.from_pretrained(model, peft_model_id)
46
+ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
47
+ model.eval()
48
 
49
 
50
+ import re
51
+ def gen(x):
52
+ inputs = tokenizer(f"### ์งˆ๋ฌธ: {x}\n\n### ๋‹ต๋ณ€:", return_tensors='pt', return_token_type_ids=False)
53
 
54
+ # Move data to GPU (if available)
55
+ inputs = {k: v.to(device="cuda" if torch.cuda.is_available() else "cpu") for k, v in inputs.items()}
56
+
57
+ gened = model.generate(
58
+ **inputs,
59
+ max_new_tokens=256,
60
+ early_stopping=True,
61
+ num_return_sequences=4,
62
+ do_sample=True,
63
+ eos_token_id=tokenizer.eos_token_id,
64
+ temperature=0.9,
65
+ top_p=0.8,
66
+ top_k=50
67
+ )
68
 
69
+ complete_answers = []
70
+ for gen_seq in gened:
71
+ decoded = tokenizer.decode(gen_seq, skip_special_tokens=True).strip()
72
+
73
+ # Extract only the text after the string "### ๋‹ต๋ณ€:"
74
+ first_answer_start_idx = decoded.find("### ๋‹ต๋ณ€:") + len("### ๋‹ต๋ณ€:")
75
+ temp_answer = decoded[first_answer_start_idx:].strip()
76
+
77
+ # Extract only text up to the second "### ๋‹ต๋ณ€:" string
78
+ second_answer_start_idx = temp_answer.find("### ๋‹ต๋ณ€:")
79
+ if second_answer_start_idx != -1:
80
+ complete_answer = temp_answer[:second_answer_start_idx].strip()
81
+ else:
82
+ complete_answer = temp_answer # ๋‘ ๋ฒˆ์งธ "### ๋‹ต๋ณ€:"์ด ์—†๋Š” ๊ฒฝ์šฐ ์ „์ฒด ๋‹ต๋ณ€ ๋ฐ˜ํ™˜
83
 
84
+ complete_answers.append(complete_answer)
85
 
86
+ return complete_answers
87
 
88
 
89
  ## Training Details
 
144
  #### Summary
145
 
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  ## Citation [optional]
148
 
149
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->