traintogpb commited on
Commit
3a0e99d
1 Parent(s): 041c900

chore: add model card

Browse files
Files changed (1) hide show
  1. README.md +78 -201
README.md CHANGED
@@ -1,7 +1,7 @@
1
  ---
2
  library_name: peft
3
  base_model: beomi/open-llama-2-ko-7b
4
- license: cc
5
  datasets:
6
  - traintogpb/aihub-flores-koen-integrated-sparta-30k
7
  language:
@@ -12,203 +12,80 @@ metrics:
12
  - comet
13
  pipeline_tag: translation
14
  ---
15
-
16
- # Model Card for Model ID
17
-
18
- <!-- Provide a quick summary of what the model is/does. -->
19
-
20
-
21
-
22
- ## Model Details
23
-
24
- ### Model Description
25
-
26
- <!-- Provide a longer summary of what this model is. -->
27
-
28
-
29
-
30
- - **Developed by:** [More Information Needed]
31
- - **Funded by [optional]:** [More Information Needed]
32
- - **Shared by [optional]:** [More Information Needed]
33
- - **Model type:** [More Information Needed]
34
- - **Language(s) (NLP):** [More Information Needed]
35
- - **License:** [More Information Needed]
36
- - **Finetuned from model [optional]:** [More Information Needed]
37
-
38
- ### Model Sources [optional]
39
-
40
- <!-- Provide the basic links for the model. -->
41
-
42
- - **Repository:** [More Information Needed]
43
- - **Paper [optional]:** [More Information Needed]
44
- - **Demo [optional]:** [More Information Needed]
45
-
46
- ## Uses
47
-
48
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
49
-
50
- ### Direct Use
51
-
52
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
53
-
54
- [More Information Needed]
55
-
56
- ### Downstream Use [optional]
57
-
58
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
59
-
60
- [More Information Needed]
61
-
62
- ### Out-of-Scope Use
63
-
64
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
65
-
66
- [More Information Needed]
67
-
68
- ## Bias, Risks, and Limitations
69
-
70
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
71
-
72
- [More Information Needed]
73
-
74
- ### Recommendations
75
-
76
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
77
-
78
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
79
-
80
- ## How to Get Started with the Model
81
-
82
- Use the code below to get started with the model.
83
-
84
- [More Information Needed]
85
-
86
- ## Training Details
87
-
88
- ### Training Data
89
-
90
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
91
-
92
- [More Information Needed]
93
-
94
- ### Training Procedure
95
-
96
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
97
-
98
- #### Preprocessing [optional]
99
-
100
- [More Information Needed]
101
-
102
-
103
- #### Training Hyperparameters
104
-
105
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
106
-
107
- #### Speeds, Sizes, Times [optional]
108
-
109
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
110
-
111
- [More Information Needed]
112
-
113
- ## Evaluation
114
-
115
- <!-- This section describes the evaluation protocols and provides the results. -->
116
-
117
- ### Testing Data, Factors & Metrics
118
-
119
- #### Testing Data
120
-
121
- <!-- This should link to a Dataset Card if possible. -->
122
-
123
- [More Information Needed]
124
-
125
- #### Factors
126
-
127
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
128
-
129
- [More Information Needed]
130
-
131
- #### Metrics
132
-
133
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
134
-
135
- [More Information Needed]
136
-
137
- ### Results
138
-
139
- [More Information Needed]
140
-
141
- #### Summary
142
-
143
-
144
-
145
- ## Model Examination [optional]
146
-
147
- <!-- Relevant interpretability work for the model goes here -->
148
-
149
- [More Information Needed]
150
-
151
- ## Environmental Impact
152
-
153
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
154
-
155
- 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).
156
-
157
- - **Hardware Type:** [More Information Needed]
158
- - **Hours used:** [More Information Needed]
159
- - **Cloud Provider:** [More Information Needed]
160
- - **Compute Region:** [More Information Needed]
161
- - **Carbon Emitted:** [More Information Needed]
162
-
163
- ## Technical Specifications [optional]
164
-
165
- ### Model Architecture and Objective
166
-
167
- [More Information Needed]
168
-
169
- ### Compute Infrastructure
170
-
171
- [More Information Needed]
172
-
173
- #### Hardware
174
-
175
- [More Information Needed]
176
-
177
- #### Software
178
-
179
- [More Information Needed]
180
-
181
- ## Citation [optional]
182
-
183
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
184
-
185
- **BibTeX:**
186
-
187
- [More Information Needed]
188
-
189
- **APA:**
190
-
191
- [More Information Needed]
192
-
193
- ## Glossary [optional]
194
-
195
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
196
-
197
- [More Information Needed]
198
-
199
- ## More Information [optional]
200
-
201
- [More Information Needed]
202
-
203
- ## Model Card Authors [optional]
204
-
205
- [More Information Needed]
206
-
207
- ## Model Card Contact
208
-
209
- [More Information Needed]
210
-
211
-
212
- ### Framework versions
213
-
214
- - PEFT 0.8.2
 
1
  ---
2
  library_name: peft
3
  base_model: beomi/open-llama-2-ko-7b
4
+ license: cc-by-sa-4.0
5
  datasets:
6
  - traintogpb/aihub-flores-koen-integrated-sparta-30k
7
  language:
 
12
  - comet
13
  pipeline_tag: translation
14
  ---
15
+ ### Pretrained LM
16
+ - [beomi/open-llama-2-ko-7b](https://huggingface.co/beomi/open-llama-2-ko-7b) (MIT License)
17
+
18
+ ### Training Dataset
19
+ - [traintogpb/aihub-flores-koen-integrated-sparta-30k](https://huggingface.co/datasets/traintogpb/aihub-flores-koen-integrated-sparta-30k)
20
+ - Can translate in Enlgish-Korean (bi-directional)
21
+
22
+ ### Prompt
23
+ - Template:
24
+ ```python
25
+ prompt = f"Translate this from {src_lang} to {tgt_lang}\n### {src_lang}: {src_text}\n### {tgt_lang}:"
26
+
27
+ >>> # src_lang can be 'English', '한국어'
28
+ >>> # tgt_lang can be '한국어', 'English'
29
+ ```
30
+ - Issue:
31
+ The tokenizer of the model tokenizes the prompt below in different way with the prompt above.
32
+ Make sure to use the prompt proposed above.
33
+ ```python
34
+ prompt = f"""Translate this from {src_lang} to {tgt_lang}
35
+ ### {src_lang}: {src_text}
36
+ ### {tgt_lang}:"""
37
+
38
+ >>> # DO NOT USE this prompt.
39
+ ```
40
+ And mind that there is no "space (`_`)" at the end of the prompt.
41
+
42
+ ### Training
43
+ - Trained with QLoRA
44
+ - PLM: NormalFloat 4-bit
45
+ - Adapter: BrainFloat 16-bit
46
+ - Adapted to all the linear layers (around 2.2%)
47
+
48
+ ### Usage (IMPORTANT)
49
+ - Should remove the EOS token (`<|endoftext|>`, id=46332) at the end of the prompt.
50
+ ```python
51
+ # MODEL
52
+ plm_name = 'beomi/open-llama-2-ko-7b'
53
+ adapter_name = 'traintogpb/llama-2-enko-translator-7b-qlora-adapter'
54
+ model = LlamaForCausalLM.from_pretrained(
55
+ plm_name,
56
+ max_length=768,
57
+ quantization_config=bnb_config, # Use the QLoRA config above
58
+ attn_implementation='flash_attention_2',
59
+ torch_dtype=torch.bfloat16
60
+ )
61
+ model = PeftModel.from_pretrained(
62
+ model,
63
+ adapter_name,
64
+ torch_dtype=torch.bfloat16
65
+ )
66
+
67
+ # TOKENIZER
68
+ tokenizer = LlamaTokenizer.from_pretrained(plm_name)
69
+ tokenizer.pad_token = "</s>"
70
+ tokenizer.pad_token_id = 2
71
+ tokenizer.eos_token = "<|endoftext|>" # Must be differentiated from the PAD token
72
+ tokenizer.eos_token_id = 46332
73
+ tokenizer.add_eos_token = True
74
+ tokenizer.model_max_length = 768
75
+
76
+ # INFERENCE
77
+ text = "NMIXX is the world-best female idol group, who came back with the new song 'DASH'."
78
+ prompt = f"Translate this from {src_lang} to {tgt_lang}\n### {src_lang}: {src_text}\n### {tgt_lang}:"
79
+
80
+ inputs = tokenizer(prompt, return_tensors="pt", max_length=max_length, truncation=True)
81
+ # REMOVE EOS TOKEN IN THE PROMPT
82
+ inputs['input_ids'] = inputs['input_ids'][0][:-1].unsqueeze(dim=0)
83
+ inputs['attention_mask'] = inputs['attention_mask'][0][:-1].unsqueeze(dim=0)
84
+
85
+ outputs = model.generate(**inputs, max_length=max_length, eos_token_id=46332)
86
+
87
+ input_len = len(inputs['input_ids'].squeeze())
88
+
89
+ translated_text = tokenizer.decode(outputs[0][input_len:], skip_special_tokens=True)
90
+ print(translated_text)
91
+ ```