Update README.md
Browse files
README.md
CHANGED
|
@@ -19,28 +19,104 @@ We release **Tri-1.8B Translation**, a lightweight multilingual translation mode
|
|
| 19 |
|
| 20 |
Tri-1.8B Translate is trained through pretraining and supervised fine-tuning (SFT), and was distilled from our larger Tri-21B model to preserve strong translation quality in a much smaller, deployment-friendly 1.8B parameter model. It supports all translation directions among English, Korean, Japanese, and Chinese.
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
## β¨ Highlights
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
---
|
| 30 |
|
| 31 |
## π§ Usage
|
| 32 |
|
|
|
|
|
|
|
| 33 |
```python
|
| 34 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
tok = AutoTokenizer.from_pretrained(model_id)
|
| 39 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
|
| 40 |
-
|
| 41 |
-
prompt = "Translate English to Korean: 'We look forward to working with you again.' <ko>"
|
| 42 |
|
|
|
|
| 43 |
inputs = tok(prompt, return_tensors="pt").to(model.device)
|
| 44 |
out = model.generate(**inputs, max_new_tokens=128)
|
| 45 |
print(tok.decode(out[0], skip_special_tokens=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
```
|
|
|
|
| 19 |
|
| 20 |
Tri-1.8B Translate is trained through pretraining and supervised fine-tuning (SFT), and was distilled from our larger Tri-21B model to preserve strong translation quality in a much smaller, deployment-friendly 1.8B parameter model. It supports all translation directions among English, Korean, Japanese, and Chinese.
|
| 21 |
|
| 22 |
+
|
| 23 |
|
| 24 |
## β¨ Highlights
|
| 25 |
+
|
| 26 |
+
* **Compact & efficient:** \~1.8B params, easy to serve on a single GPU.
|
| 27 |
+
* **Multilingual:** Fully bidirectional **EN β KO β JA β ZH**.
|
| 28 |
+
* **Simple prompts:** Works with a short **task instruction + `<lang>` tag**.
|
| 29 |
+
* **Research-ready:** Suitable for domain SFT or lightweight adapters.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## π§Ύ Prompt format
|
| 34 |
+
|
| 35 |
+
```
|
| 36 |
+
Translate the following {SRC_NAME} text into {TGT_NAME}:
|
| 37 |
+
{TEXT} <{lang_tag}>
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Where `{lang_tag} β { en, ko, ja, zh }`.
|
| 41 |
|
| 42 |
---
|
| 43 |
|
| 44 |
## π§ Usage
|
| 45 |
|
| 46 |
+
### 1) π€ Transformers
|
| 47 |
+
|
| 48 |
```python
|
| 49 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 50 |
|
| 51 |
+
tok = AutoTokenizer.from_pretrained("trillionlabs/Tri-1.8B-Translation")
|
| 52 |
+
model = AutoModelForCausalLM.from_pretrained("trillionlabs/Tri-1.8B-Translation", device_map="auto")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
prompt = "Translate the following Korean text into English:\nμλ
νμΈμ <en>"
|
| 55 |
inputs = tok(prompt, return_tensors="pt").to(model.device)
|
| 56 |
out = model.generate(**inputs, max_new_tokens=128)
|
| 57 |
print(tok.decode(out[0], skip_special_tokens=True))
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
---
|
| 61 |
+
|
| 62 |
+
### 2) Local vLLM
|
| 63 |
+
|
| 64 |
+
```python
|
| 65 |
+
from vllm import LLM, SamplingParams
|
| 66 |
+
|
| 67 |
+
llm = LLM(model="trillionlabs/Tri-1.8B-Translation")
|
| 68 |
+
sp = SamplingParams(temperature=0.3, max_tokens=512)
|
| 69 |
+
|
| 70 |
+
def translate(text, target="en"):
|
| 71 |
+
prompt = f"Translate into {target}:\n{text} <{target}>"
|
| 72 |
+
out = llm.chat([{"role": "user", "content": prompt}], sampling_params=sp)
|
| 73 |
+
return out[0].outputs[0].text.strip()
|
| 74 |
+
|
| 75 |
+
print(translate("μλ
νμΈμ", "en"))
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
### 3) API client (OpenAI-compatible)
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
import openai
|
| 84 |
+
|
| 85 |
+
client = openai.OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
|
| 86 |
+
|
| 87 |
+
def translate(text, target="en"):
|
| 88 |
+
prompt = f"Translate into {target}:\n{text} <{target}>"
|
| 89 |
+
resp = client.chat.completions.create(
|
| 90 |
+
model="trillionlabs/Tri-1.8B-Translation",
|
| 91 |
+
messages=[{"role": "user", "content": prompt}],
|
| 92 |
+
temperature=0.3,
|
| 93 |
+
max_tokens=512,
|
| 94 |
+
)
|
| 95 |
+
return resp.choices[0].message.content.strip()
|
| 96 |
+
|
| 97 |
+
print(translate("μλ
νμΈμ", "en"))
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
## π License
|
| 102 |
+
|
| 103 |
+
Apache-2.0 (for model weights & code). Please verify data licenses for your use.
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
## π Acknowledgments
|
| 107 |
+
|
| 108 |
+
* Thanks to the **ByteDance Seed team** for releasing **Seed-X**; our prompt template and some training design were adapted from their paper.
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
## π Citation
|
| 112 |
+
|
| 113 |
+
If you use **Tri-1.8B Translation**, please cite:
|
| 114 |
+
|
| 115 |
+
```bibtex
|
| 116 |
+
@misc{suk2025tri18b,
|
| 117 |
+
title = {Tri-1.8B Translation: A Lightweight Multilingual Translation Model},
|
| 118 |
+
author = {Juyoung Suk and Trillion Labs},
|
| 119 |
+
year = {2025},
|
| 120 |
+
howpublished = {\url{https://huggingface.co/trillionlabs/Tri-1.8B-Translation}}
|
| 121 |
+
}
|
| 122 |
```
|