File size: 8,957 Bytes
0d8fad7 59b3477 0d8fad7 59b3477 0d8fad7 |
1 2 3 4 5 6 7 8 9 10 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 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 150 151 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
---
library_name: transformers
tags:
- translation
license: gemma
language:
- ar
- bg
- zh
- cs
- da
- nl
- en
- fi
- fr
- de
- el
- gu
- he
- hi
- hu
- id
- it
- ja
- ko
- fa
- pl
- pt
- ro
- ru
- sk
- es
- sv
- tl
- th
- tr
- uk
- vi
---
# YanoljaNEXT-Rosetta-4B-2511
<p style="text-align: center; margin: 0 auto 64px">
<img src="next_rosetta.png" style="width: 1096px">
</p>
This model is a fine-tuned version of [`google/gemma-3-4b-pt`](https://huggingface.co/google/gemma-3-4b-pt). As it is intended solely for text generation, we have extracted and utilized only the `Gemma3ForCausalLM` component from the original architecture.
Unlike our previous EEVE models, this model does not feature an expanded tokenizer.
- **Model Name:** `yanolja/YanoljaNEXT-Rosetta-4B-2511`
- **Base Model:** `google/gemma-3-4b-pt`
## Model Description
This model is a 4-billion parameter, decoder-only language model built on the Gemma3 architecture and fine-tuned by Yanolja NEXT. It is specifically designed to translate structured data (JSON, YAML, XML formats) while preserving the original data structure.
The model was trained on a multilingual dataset covering the following languages equally:
- Arabic
- Bulgarian
- Chinese
- Czech
- Danish
- Dutch
- English
- Finnish
- French
- German
- Greek
- Gujarati
- Hebrew
- Hindi
- Hungarian
- Indonesian
- Italian
- Japanese
- Korean
- Persian
- Polish
- Portuguese
- Romanian
- Russian
- Slovak
- Spanish
- Swedish
- Tagalog
- Thai
- Turkish
- Ukrainian
- Vietnamese
While optimized for these languages, it may also perform effectively on other languages supported by the base Gemma3 model.
## How to use
You can use this model with the `transformers` library as follows:
```python
import json
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "yanolja/YanoljaNEXT-Rosetta-4B-2511"
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map="auto",
max_memory={0: "23GB"},
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
target_language = "Korean"
context = {
"context": "Simple introduction about a tech company.",
"tone": "Informative and helpful",
"glossary": {
"Yanolja NEXT": "์ผ๋์๋ฅ์คํธ",
"travel industry": "์ฌํ ์ฐ์
",
}
}
system = [f"Translate the user's text to {target_language}."]
for key, value in context.items():
key_pascal = key.capitalize()
if isinstance(value, dict):
system.append(f"{key_pascal}:")
for f, t in value.items():
system.append(f"- {f} -> {t}")
else:
system.append(f"{key_pascal}: {value}")
system.append("Output format: JSON")
system.append("Provide the final translation immediately without any other text.")
source = {
"company_name": "Yanolja NEXT",
"description": "Yanolja NEXT is a company that provides cutting-edge "
"technology for the global travel industry.",
}
messages = [
{"role": "system", "content": "\n".join(system)},
{"role": "user", "content": json.dumps(source, ensure_ascii=False)},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
print(prompt)
# <bos><start_of_turn>instruction
# Translate the user's text to Korean.
# Context: Simple introduction about a tech company.
# Tone: Informative and helpful
# Glossary:
# - Yanolja NEXT -> ์ผ๋์๋ฅ์คํธ
# - travel industry -> ์ฌํ ์ฐ์
# Output format: JSON
# Provide the final translation immediately without any other text.<end_of_turn>
# <start_of_turn>source
# {"company_name": "Yanolja NEXT", "description": "Yanolja NEXT is a company that provides cutting-edge technology for the global travel industry."}<end_of_turn>
# <start_of_turn>translation
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
input_length = inputs["input_ids"].shape[1]
with torch.inference_mode():
outputs = model.generate(
**inputs,
max_new_tokens=64,
)
generated_tokens = outputs[0][input_length:]
translation = tokenizer.decode(generated_tokens, skip_special_tokens=True)
print(json.dumps(json.loads(translation), indent=2, ensure_ascii=False))
# {
# "company_name": "์ผ๋์๋ฅ์คํธ",
# "description": "์ผ๋์๋ฅ์คํธ๋ ๊ธ๋ก๋ฒ ์ฌํ ์ฐ์
์ ์ต์ฒจ๋จ ๊ธฐ์ ์ ์ ๊ณตํ๋ ํ์ฌ์
๋๋ค."
# }
```
The model outputs the final translation in the same structured format as the input (JSON, YAML, XML) when appropriate, or plain text for simple translations.
## Training Procedure
### Training Data
The translation datasets were synthesized using fineweb corpora.
- [FineWeb Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu)
- [FineWeb2](https://huggingface.co/datasets/HuggingFaceFW/fineweb-2)
The model was fine-tuned on synthetic multilingual translation data to optimize performance across the supported language pairs.
## Performance
### Translation Quality Benchmarks
The following CHrF++ scores (WMT24++) demonstrate the model's competitive performance compared to other state-of-the-art translation models on English to Korean translation:
| Model | CHrF++ Score (WMT24++) |
|------------------------------------|--------------|
| openai/gpt-4o | 36.08 |
| **yanolja/YanoljaNEXT-Rosetta-4B-2511** | **35.64** |
| google/gemini-2.5-flash | 35.25 |
| **yanolja/YanoljaNEXT-Rosetta-4B-2510** | **35.09** |
| tencent/Hunyuan-MT-7B | 34.76 |
| yanolja/YanoljaNEXT-Rosetta-20B | 33.87 |
| AIDC-AI/Marco-MT-Algharb | 33.40 |
| openai/gpt-oss-120b | 31.51 |
| **yanolja/YanoljaNEXT-Rosetta-4B** | **31.31** |
| ByteDance-Seed/Seed-X-PPO-7B | 30.48 |
| google/gemma-3-27b-it | 30.05 |
| google/gemma-3-12b-it | 29.31 |
| google/gemma-3-4b-it | 27.53 |
YanoljaNEXT-Rosetta-4B-2511 achieves competitive translation quality while maintaining the efficiency of a 4B parameter model.
Scores for the other language pairs can be found in the [WMT24++ Evaluation Results](wmt24pp_12b.md).
## Intended Uses & Limitations
This model is intended for translating structured data (JSON, YAML, XML formats) while preserving the original structure. It is particularly well-suited for tasks such as localizing product catalogs, translating hotel reviews, or handling any other structured content that requires accurate translation.
### Limitations
The model is primarily optimized for processing structured data (JSON, YAML, XML).
Its performance on unstructured text or other data formats may vary.
In some cases, the model may produce invalid JSON, repetitive output, or inaccurate translations.
### License
This model is released under the Gemma license, inherited from its base model, [`google/gemma-3-4b-pt`](https://huggingface.co/google/gemma-3-4b-pt). Please consult the official [Gemma license terms](https://ai.google.dev/gemma/terms) for detailed usage guidelines.
## Acknowledgments
This work was supported by the Korea Creative Content Agency (KOCCA) grant, funded by the Ministry of Culture, Sports and Tourism (MCST) in 2025 (Project Name: _Cultivating Masters and Doctoral Experts to Lead Digital-Tech Tourism_, Project Number: RS-2024-00442006, Contribution Rate: 100%).
## Citation
If you use this model, please consider citing:
```
@misc{yanolja2025yanoljanextrosetta,
author = {Yanolja NEXT Co., Ltd.},
title = {YanoljaNEXT-Rosetta-4B-2511},
year = {2025},
publisher = {Hugging Face},
journal = {Hugging Face repository},
howpublished = {\\url{https://huggingface.co/yanolja/YanoljaNEXT-Rosetta-4B-2511}}
}
```
## References
This work utilizes several models and datasets. We would like to acknowledge the original authors for their valuable contributions to the field.
```
@misc{gemma3,
author = {Google},
title = {Gemma 3},
year = {2024},
publisher = {Google DeepMind},
howpublished = {\\url{https://deepmind.google/models/gemma/gemma-3/}}
}
@misc{penedo2025fineweb2pipelinescale,
title = {FineWeb2: One Pipeline to Scale Them All -- Adapting Pre-Training Data Processing to Every Language},
author = {Guilherme Penedo and Hynek Kydlรญฤek and Vinko Sabolฤec and Bettina Messmer and Negar Foroutan and Amir Hossein Kargaran and Colin Raffel and Martin Jaggi and Leandro Von Werra and Thomas Wolf},
year = {2025},
eprint = {2506.20920},
archivePrefix = {arXiv},
primaryClass = {cs.CL},
url = {https://arxiv.org/abs/2506.20920},
}
@misc{lozhkov2024fineweb-edu,
author = {Lozhkov, Anton and Ben Allal, Loubna and von Werra, Leandro and Wolf, Thomas},
title = {FineWeb-Edu: the Finest Collection of Educational Content},
year = 2024,
url = {https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu},
doi = {10.57967/hf/2497},
publisher={Hugging Face}
}
``` |