ptrdvn commited on
Commit
5dfd730
·
verified ·
1 Parent(s): 2208f86

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +170 -125
README.md CHANGED
@@ -1,199 +1,244 @@
1
  ---
2
- library_name: transformers
3
- tags: []
4
- ---
5
-
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
11
-
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
57
 
58
- ## Bias, Risks, and Limitations
 
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
 
 
 
 
61
 
62
- [More Information Needed]
63
 
64
- ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
- ## How to Get Started with the Model
71
 
72
- Use the code below to get started with the model.
73
 
74
- [More Information Needed]
75
 
76
- ## Training Details
77
 
78
- ### Training Data
79
 
80
- <!-- 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. -->
 
 
81
 
82
- [More Information Needed]
83
 
84
- ### Training Procedure
 
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
89
 
90
- [More Information Needed]
91
 
 
 
92
 
93
- #### Training Hyperparameters
 
 
 
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
 
 
 
96
 
97
- #### Speeds, Sizes, Times [optional]
 
 
 
 
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
 
101
- [More Information Needed]
 
102
 
103
- ## Evaluation
 
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
 
107
- ### Testing Data, Factors & Metrics
 
108
 
109
- #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
 
119
- [More Information Needed]
 
 
120
 
121
- #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
 
 
124
 
125
- [More Information Needed]
126
 
127
- ### Results
128
 
129
- [More Information Needed]
 
130
 
131
- #### Summary
 
 
 
132
 
 
133
 
 
 
 
 
134
 
135
- ## Model Examination [optional]
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
138
 
139
- [More Information Needed]
 
140
 
141
- ## Environmental Impact
 
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
 
145
- 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).
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
154
 
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
158
 
159
- ### Compute Infrastructure
160
 
161
- [More Information Needed]
 
162
 
163
- #### Hardware
164
 
165
- [More Information Needed]
166
 
167
- #### Software
168
 
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
 
 
 
176
 
177
- [More Information Needed]
 
 
 
 
178
 
179
- **APA:**
 
 
 
 
 
 
 
 
180
 
181
- [More Information Needed]
 
 
 
182
 
183
- ## Glossary [optional]
 
 
 
 
 
 
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
 
 
 
 
 
 
 
 
 
186
 
187
- [More Information Needed]
 
 
 
 
 
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - ptrdvn/kakugo-grn
5
+ language:
6
+ - grn
7
+ base_model:
8
+ - ibm-granite/granite-4.0-micro
9
+ pipeline_tag: text-generation
10
+ tags:
11
+ - low-resource-language
12
+ - data-distillation
13
+ - conversation
14
+ - grn
15
+ - Guarani
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ ---
18
+ # Kakugo 3B Guarani
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ [[Paper]](https://arxiv.org/abs/2601.14051) [[Code]](https://github.com/Peter-Devine/kakugo) [[Dataset]](https://huggingface.co/datasets/ptrdvn/kakugo-grn)
21
 
22
+ <div align="center">
23
+ <div style="font-size: 80px;font-family: Arial, Helvetica, sans-serif;font-variant: small-caps;color: #000000;font-weight: 700; margin-top:-40px; margin-bottom:-60px; margin-left: -20px" align="center">Kakugo</div>
24
 
25
+ <div align="center">
26
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/64b63f8ad57e02621dc93c8b/hmRaNkmPAV8rakBOhtgZI.png" alt="Globe Image" width="400"/>
27
+ A data distilled model trained specifically for <strong>Guarani</strong>.
28
+ </div>
29
+ </div>
30
 
31
+ This is **Kakugo 3B Guarani**, a small language model (SLM) fine-tuned to interact with the user in **Guarani**.
32
 
33
+ For Kakugo in other languages, check out the [model](https://huggingface.co/collections/ptrdvn/kakugo-models) and [dataset](https://huggingface.co/collections/ptrdvn/kakugo-datasets) collections.
34
 
35
+ # How to use
36
 
37
+ To use this model, you can use your preferred LLM inference package.
38
 
39
+ This model should work with any package that supports the original base model [ibm-granite/granite-4.0-micro](https://huggingface.co/ibm-granite/granite-4.0-micro).
40
 
41
+ We provide examples for how to run this with Huggingface or vLLM:
42
 
43
+ <details>
44
 
45
+ <summary>Huggingface (Recommended for beginners)</summary>
46
 
47
+ First, make sure `transformers` is installed on your machine.
48
 
49
+ ```bash
50
+ pip install transformers
51
+ ```
52
 
53
+ Then run the following Python code to generate a response from the LLM.
54
 
55
+ ```python
56
+ from transformers import pipeline
57
 
58
+ generator = pipeline(model="ptrdvn/kakugo-3B-grn", task="text-generation")
59
 
60
+ user_input = input("Please enter your input to the model in Guarani:")
61
 
62
+ do_reasoning = False
63
 
64
+ open_thinking_tag = "<think>"
65
+ close_thinking_tag = "</think>"
66
 
67
+ if do_reasoning:
68
+ sys_msg = f"Before you respond, first think about your response and enclose your thinking process in {open_thinking_tag} and {close_thinking_tag} delimiters."
69
+ else:
70
+ sys_msg = "Be concise in your responses."
71
 
72
+ message = [
73
+ {"role": "system", "content": sys_msg},
74
+ {"role": "user", "content": user_input}
75
+ ]
76
 
77
+ output = generator(
78
+ message,
79
+ do_sample=False,
80
+ repetition_penalty=1.05,
81
+ )
82
 
83
+ model_response = output[0]["generated_text"][-1]["content"]
84
 
85
+ if do_reasoning:
86
+ model_response = model_response.split(close_thinking_tag)[-1]
87
 
88
+ print(model_response)
89
+ ```
90
 
91
+ N.B. - We recommend using a `repetition_penalty` of 1.05 as sometimes the model can stuck in a loop of generating repetitive text when generating low-resource languages.
92
 
93
+ You can set `do_reasoning` to be either True or False to turn "thinking mode" on or off, respectively. If the model is used in thinking mode, then it will take longer to generate a response, but may lead to a better generated response.
94
+ This mode is still experimental, so try both using and not using it for your use-case.
95
 
96
+ </details>
97
 
98
+ <br/>
99
 
100
+ <details>
101
 
102
+ <summary>vLLM (Recommended for performance)</summary>
103
 
104
+ First, make sure `vllm` is installed on your machine.
105
 
106
+ ```bash
107
+ pip install vllm
108
+ ```
109
 
110
+ Then run the following Python code to generate a response from the LLM.
111
 
112
+ ```python
113
+ from vllm import LLM, SamplingParams
114
+ llm = LLM(model="ptrdvn/kakugo-3B-grn")
115
 
116
+ user_input = input("Please enter your input to the model in Guarani:")
117
 
118
+ do_reasoning = True
119
 
120
+ open_thinking_tag = "<think>"
121
+ close_thinking_tag = "</think>"
122
 
123
+ if do_reasoning:
124
+ sys_msg = f"Before you respond, first think about your response and enclose your thinking process in {open_thinking_tag} and {close_thinking_tag} delimiters."
125
+ else:
126
+ sys_msg = "Be concise in your responses."
127
 
128
+ sampling_params = SamplingParams(temperature=0, repetition_penalty=1.05, max_tokens=2048)
129
 
130
+ messages = [[
131
+ {"role": "system", "content": sys_msg},
132
+ {"role": "user", "content": user_input}
133
+ ]]
134
 
135
+ output = llm.chat(messages, sampling_params)
136
 
137
+ model_response = output[0].outputs[0].text
138
 
139
+ if do_reasoning:
140
+ model_response = model_response.split(close_thinking_tag)[-1]
141
 
142
+ print(model_response)
143
+ ```
144
 
145
+ N.B. - When using `vllm` for inference of multiple inputs, we recommend inputting them all at once. I.e., add more items to the outer list of the `messages` variable in the above script. [More on vLLM optimization](https://docs.vllm.ai/en/stable/configuration/optimization).
146
 
147
+ We recommend using a `repetition_penalty` of 1.05 as sometimes the model can stuck in a loop of generating repetitive text when generating low-resource languages.
148
 
149
+ You can set `do_reasoning` to be either True or False to turn "thinking mode" on or off, respectively. If the model is used in thinking mode, then it will take longer to generate a response, but may lead to a better generated response.
150
+ This mode is still experimental, so try both using and not using it for your use-case.
 
 
 
151
 
152
+ </details>
153
 
154
+ <br/>
155
 
156
+ # Training data
157
 
158
+ The training data for this model can be found at [ptrdvn/kakugo-grn](https://huggingface.co/datasets/ptrdvn/kakugo-grn).
159
 
160
+ This data was created by prompting [openai/gpt-oss-120b](https://huggingface.co/openai/gpt-oss-120b) to generate prompts and responses in Guarani.
161
+ We also translate a set of prompts and responses from the [BAAI/Infinity-Instruct](https://huggingface.co/datasets/BAAI/Infinity-Instruct) dataset.
162
 
163
+ More details about exactly how we created our data can be found in [our paper](https://arxiv.org/abs/2601.14051).
164
 
165
+ # Training
166
 
167
+ Full details of how this model was created (and how you can train a model in your own chosen language) can be found on our [Github repo](https://github.com/Peter-Devine/kakugo).
168
 
169
+ To make this model, we fine-tuned [ibm-granite/granite-4.0-micro](https://huggingface.co/ibm-granite/granite-4.0-micro) for 1 epoch on [ptrdvn/kakugo-grn](https://huggingface.co/datasets/ptrdvn/kakugo-grn) using [Llama Factory](https://github.com/hiyouga/LlamaFactory).
170
 
171
+ <details>
172
 
173
+ <summary>Full Llama Factory training hyperparameters</summary>
174
 
175
+ ```yaml
176
+ ### model
177
+ model_name_or_path: ibm-granite/granite-4.0-micro
178
+ trust_remote_code: true
179
 
180
+ ### method
181
+ stage: sft
182
+ do_train: true
183
+ finetuning_type: full
184
+ deepspeed: examples/deepspeed/ds_z3_config.json # choices: [ds_z0_config.json, ds_z2_config.json, ds_z3_config.json]
185
 
186
+ ### dataset
187
+ dataset_dir: /workspace/train
188
+ dataset: ptrdvn/kakugo-grn
189
+ template: granite4
190
+ cutoff_len: 8000
191
+ overwrite_cache: true
192
+ preprocessing_num_workers: 16
193
+ dataloader_num_workers: 4
194
+ packing: true
195
 
196
+ ### Reporting
197
+ report_to: wandb
198
+ run_name: ptrdvn/kakugo-grn
199
+ logging_steps: 1
200
 
201
+ ### output
202
+ output_dir: ptrdvn/kakugo-grn
203
+ save_strategy: "no"
204
+ save_steps: 99999999
205
+ plot_loss: true
206
+ overwrite_output_dir: true
207
+ save_only_model: true
208
 
209
+ ### train
210
+ per_device_train_batch_size: 1
211
+ gradient_accumulation_steps: 1
212
+ learning_rate: 1.0e-5
213
+ num_train_epochs: 1.0
214
+ lr_scheduler_type: cosine
215
+ warmup_ratio: 0.05
216
+ bf16: true
217
+ ddp_timeout: 180000000
218
+ resume_from_checkpoint: null
219
 
220
+ ## eval
221
+ val_size: 0.02
222
+ per_device_eval_batch_size: 1
223
+ eval_strategy: steps
224
+ eval_steps: 0.2
225
+ ```
226
 
227
+ </details>
228
 
229
+ <br/>
230
 
231
+ # Credits
232
 
233
+ This model was trained by [@ptrdvn](https://huggingface.co/ptrdvn)
234
 
235
+ If you use this model, please cite:
236
 
237
+ ```bibtex
238
+ @article{devine2026kakugo,
239
+ title={Kakugo: Distillation of Low-Resource Languages into Small Language Models},
240
+ author={Devine, Peter and Sanni, Mardhiyah and Adilazuarda, Farid and Loizaga, Julieta Gil and Haddow, Barry},
241
+ journal={arXiv preprint arXiv:2601.14051},
242
+ year={2026}
243
+ }
244
+ ```