traintogpb
commited on
Commit
•
3a0e99d
1
Parent(s):
041c900
chore: add model card
Browse files
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 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
-
|
44 |
-
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
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 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|