Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,199 +1,244 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
--
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 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 |
-
-
|
| 33 |
-
|
| 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 |
-
[
|
| 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 |
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
-
|
|
|
|
| 102 |
|
| 103 |
-
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
|
| 107 |
-
|
|
|
|
| 108 |
|
| 109 |
-
|
| 110 |
|
| 111 |
-
<
|
| 112 |
|
| 113 |
-
|
| 114 |
|
| 115 |
-
|
| 116 |
|
| 117 |
-
|
| 118 |
|
| 119 |
-
|
|
|
|
|
|
|
| 120 |
|
| 121 |
-
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
|
| 128 |
|
| 129 |
-
|
|
|
|
| 130 |
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
| 132 |
|
|
|
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
|
|
|
| 140 |
|
| 141 |
-
|
|
|
|
| 142 |
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
|
| 153 |
-
|
| 154 |
|
| 155 |
-
|
| 156 |
|
| 157 |
-
|
| 158 |
|
| 159 |
-
|
| 160 |
|
| 161 |
-
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
|
| 165 |
-
|
| 166 |
|
| 167 |
-
|
| 168 |
|
| 169 |
-
[
|
| 170 |
|
| 171 |
-
|
| 172 |
|
| 173 |
-
<
|
| 174 |
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
|
| 190 |
|
| 191 |
-
|
| 192 |
|
| 193 |
-
#
|
| 194 |
|
| 195 |
-
|
| 196 |
|
| 197 |
-
|
| 198 |
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
```
|