traintogpb
commited on
Commit
•
945d9c8
1
Parent(s):
8fad968
Update README.md
Browse files
README.md
CHANGED
@@ -9,202 +9,68 @@ language:
|
|
9 |
- ko
|
10 |
pipeline_tag: translation
|
11 |
---
|
12 |
-
|
13 |
-
|
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 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
76 |
-
|
77 |
-
## How to Get Started with the Model
|
78 |
-
|
79 |
-
Use the code below to get started with the model.
|
80 |
-
|
81 |
-
[More Information Needed]
|
82 |
-
|
83 |
-
## Training Details
|
84 |
-
|
85 |
-
### Training Data
|
86 |
-
|
87 |
-
<!-- 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. -->
|
88 |
-
|
89 |
-
[More Information Needed]
|
90 |
-
|
91 |
-
### Training Procedure
|
92 |
-
|
93 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
94 |
-
|
95 |
-
#### Preprocessing [optional]
|
96 |
-
|
97 |
-
[More Information Needed]
|
98 |
-
|
99 |
-
|
100 |
-
#### Training Hyperparameters
|
101 |
-
|
102 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
103 |
-
|
104 |
-
#### Speeds, Sizes, Times [optional]
|
105 |
-
|
106 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
107 |
-
|
108 |
-
[More Information Needed]
|
109 |
-
|
110 |
-
## Evaluation
|
111 |
-
|
112 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
113 |
-
|
114 |
-
### Testing Data, Factors & Metrics
|
115 |
-
|
116 |
-
#### Testing Data
|
117 |
-
|
118 |
-
<!-- This should link to a Dataset Card if possible. -->
|
119 |
-
|
120 |
-
[More Information Needed]
|
121 |
-
|
122 |
-
#### Factors
|
123 |
-
|
124 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
125 |
-
|
126 |
-
[More Information Needed]
|
127 |
-
|
128 |
-
#### Metrics
|
129 |
-
|
130 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
131 |
-
|
132 |
-
[More Information Needed]
|
133 |
-
|
134 |
-
### Results
|
135 |
-
|
136 |
-
[More Information Needed]
|
137 |
-
|
138 |
-
#### Summary
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
## Model Examination [optional]
|
143 |
-
|
144 |
-
<!-- Relevant interpretability work for the model goes here -->
|
145 |
-
|
146 |
-
[More Information Needed]
|
147 |
-
|
148 |
-
## Environmental Impact
|
149 |
-
|
150 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
151 |
-
|
152 |
-
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).
|
153 |
-
|
154 |
-
- **Hardware Type:** [More Information Needed]
|
155 |
-
- **Hours used:** [More Information Needed]
|
156 |
-
- **Cloud Provider:** [More Information Needed]
|
157 |
-
- **Compute Region:** [More Information Needed]
|
158 |
-
- **Carbon Emitted:** [More Information Needed]
|
159 |
-
|
160 |
-
## Technical Specifications [optional]
|
161 |
-
|
162 |
-
### Model Architecture and Objective
|
163 |
-
|
164 |
-
[More Information Needed]
|
165 |
-
|
166 |
-
### Compute Infrastructure
|
167 |
-
|
168 |
-
[More Information Needed]
|
169 |
-
|
170 |
-
#### Hardware
|
171 |
-
|
172 |
-
[More Information Needed]
|
173 |
-
|
174 |
-
#### Software
|
175 |
-
|
176 |
-
[More Information Needed]
|
177 |
-
|
178 |
-
## Citation [optional]
|
179 |
-
|
180 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
181 |
-
|
182 |
-
**BibTeX:**
|
183 |
-
|
184 |
-
[More Information Needed]
|
185 |
-
|
186 |
-
**APA:**
|
187 |
-
|
188 |
-
[More Information Needed]
|
189 |
-
|
190 |
-
## Glossary [optional]
|
191 |
-
|
192 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
193 |
-
|
194 |
-
[More Information Needed]
|
195 |
-
|
196 |
-
## More Information [optional]
|
197 |
-
|
198 |
-
[More Information Needed]
|
199 |
-
|
200 |
-
## Model Card Authors [optional]
|
201 |
-
|
202 |
-
[More Information Needed]
|
203 |
-
|
204 |
-
## Model Card Contact
|
205 |
-
|
206 |
-
[More Information Needed]
|
207 |
-
|
208 |
|
209 |
### Framework versions
|
210 |
|
|
|
9 |
- ko
|
10 |
pipeline_tag: translation
|
11 |
---
|
12 |
+
### Pretrained LM
|
13 |
+
- [beomi/Llama-3-Open-Ko-8B](https://huggingface.co/beomi/Llama-3-Open-Ko-8B) (MIT License)
|
14 |
+
|
15 |
+
### Training Dataset
|
16 |
+
- [traintogpb/aihub-flores-koen-integrated-sparta-mini-300k](https://huggingface.co/datasets/traintogpb/aihub-flores-koen-integrated-sparta-mini-300k)
|
17 |
+
- Can translate in Enlgish-Korean (bi-directional)
|
18 |
+
|
19 |
+
### Prompt
|
20 |
+
- Template:
|
21 |
+
```python
|
22 |
+
prompt = f"Translate this from {src_lang} to {tgt_lang}\n### {src_lang}: {src_text}\n### {tgt_lang}: "
|
23 |
+
|
24 |
+
>>> # src_lang can be 'English', '한국어'
|
25 |
+
>>> # tgt_lang can be '한국어', 'English'
|
26 |
+
```
|
27 |
+
Mind that there is a "space (`_`)" at the end of the prompt (unpredictable first token will be popped up).
|
28 |
+
But if you use vLLM, it's okay to remove the final space(`_`).
|
29 |
+
|
30 |
+
### Training
|
31 |
+
- Trained with QLoRA
|
32 |
+
- PLM: NormalFloat 4-bit
|
33 |
+
- Adapter: BrainFloat 16-bit
|
34 |
+
- Adapted to all the linear layers (around 2.05%)
|
35 |
+
- Merge adapters and upscaled in BrainFloat 16-bit precision
|
36 |
+
|
37 |
+
### Usage (IMPORTANT)
|
38 |
+
- Should remove the EOS token (`<|endoftext|>`, id=46332) at the end of the prompt.
|
39 |
+
```python
|
40 |
+
# MODEL
|
41 |
+
adapter_name = 'traintogpb/llama-3-enko-translator-8b-qlora-adapter'
|
42 |
+
bnb_config = BitsAndBytesConfig(
|
43 |
+
load_in_4bit=True,
|
44 |
+
bnb_4bit_quant_type='nf4',
|
45 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
46 |
+
bnb_4bit_use_double_quant=True
|
47 |
+
)
|
48 |
+
model = AutoModelForCausalLM.from_pretrained(
|
49 |
+
model_name,
|
50 |
+
max_length=768,
|
51 |
+
quantization_config=bnb_config,
|
52 |
+
attn_implementation='flash_attention_2',
|
53 |
+
torch_dtype=torch.bfloat16,
|
54 |
+
)
|
55 |
+
model = PeftModel.from_pretrained(
|
56 |
+
model,
|
57 |
+
adapter_path=adapter_name,
|
58 |
+
torch_dtype=torch.bfloat16,
|
59 |
+
)
|
60 |
+
|
61 |
+
tokenizer = AutoTokenizer.from_pretrained(adapter_name)
|
62 |
+
tokenizer.pad_token_id = 128002 # eos_token_id and pad_token_id should be different
|
63 |
+
|
64 |
+
text = "Someday, QWER will be the greatest girl band in the world.""
|
65 |
+
input_prompt = f"Translate this from English to 한국어.\n### English: {text}\n### 한국어:"
|
66 |
+
inputs = tokenizer(input_prompt, max_length=768, truncation=True, return_tensors='pt')
|
67 |
+
|
68 |
+
if inputs['input_ids'][0][-1] == tokenizer.eos_token_id:
|
69 |
+
inputs['input_ids'] = inputs['input_ids'][0][:-1].unsqueeze(dim=0)
|
70 |
+
inputs['attention_mask'] = inputs['attention_mask'][0][:-1].unsqueeze(dim=0)
|
71 |
+
|
72 |
+
outputs = model.generate(**inputs, max_length=768, eos_token_id=tokenizer.eos_token_id)
|
73 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
### Framework versions
|
76 |
|