File size: 7,297 Bytes
e98e540
 
8924ae7
e98e540
ec7f931
e98e540
8924ae7
e98e540
 
 
 
 
 
 
 
 
 
 
 
8924ae7
e98e540
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8924ae7
e98e540
8924ae7
 
 
 
 
e98e540
 
 
 
8924ae7
 
 
e98e540
 
 
 
 
 
 
8924ae7
e98e540
8924ae7
e98e540
8924ae7
e98e540
 
 
 
 
 
 
35ace76
 
 
 
e98e540
 
 
 
 
ec7f931
 
 
 
 
 
 
 
 
e98e540
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
### Model Sources

- **Paper**: "LLaMAX: Scaling Linguistic Horizons of LLM by Enhancing Translation Capabilities Beyond 100 Languages"

- **Link**: https://arxiv.org/pdf/2407.05975

- **Repository**: https://github.com/CONE-MT/LLaMAX/

### Model Description

LLaMAX is a language model with powerful multilingual capabilities without loss instruction-following capabilities. 

We collected extensive training sets in 102 languages for continued pre-training of Llama2 and leveraged the English instruction fine-tuning dataset, Alpaca, to fine-tune its instruction-following capabilities.

### 🔥 Effortless Multilingual Translation with a Simple Prompt

LLaMAX supports translation between more than 100 languages, surpassing the performance of similarly scaled LLMs.

```angular2html

def Prompt_template(query, src_language, trg_language):

    instruction = f'Translate the following sentences from {src_language} to {trg_language}.'

    prompt = (

        'Below is an instruction that describes a task, paired with an input that provides further context. '

        'Write a response that appropriately completes the request.\n'

        f'### Instruction:\n{instruction}\n'

        f'### Input:\n{query}\n### Response:'

    )

    return prompt

```

And then run the following codes to execute translation:
```angular2html

from transformers import AutoTokenizer, LlamaForCausalLM



model = LlamaForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)

tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)



query = "你好,今天是个好日子"

prompt = Prompt_template(query, 'Chinese', 'English')

inputs = tokenizer(prompt, return_tensors="pt")



generate_ids = model.generate(inputs.input_ids, max_length=30)

tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]

# => "Hello, today is a good day"

```


### 🔥 Excellent Translation Performance
LLaMAX achieves an average spBLEU score improvement of over **10 points** compared to the LLaMA2-Alpaca model on the Flores-101 dataset.

| System             | Size | en-X (COMET)       | en-X (BLEU) | zh-X (COMET)| zh-X (BLEU) | de-X (COMET) | de-X (BLEU) | ne-X (COMET) | ne-X (BLEU) |ar-X (COMET) | ar-X (BLEU) | az-X (COMET) | az-X (BLEU) | ceb-X (COMET) | ceb-X (BLEU)|
|--------------------|------|--------------------|-------------| ----| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | 
| LLaMAX2-7B-Alpaca  | 7B   | 52.83              | 9.44        | 51.29       | 3.80        | 51.47       | 6.82        | 46.59       | 1.31        | 46.76       | 2.84        | 48.63       | 1.36        | 41.02       | 2.69        |
| LLaMAX2-7B-Alpaca  | 13B  | 57.16              | 11.85       | 53.93       | 6.25        | 54.70       | 9.42        | 51.47       | 3.11        | 50.73       | 5.23        | 50.68       | 2.74        | 47.86       | 4.96        |
| LLaMAX2-7B-Alpaca  | 7B   | 76.66 | 23.17       |  73.54      | 14.17       | 73.82       | 18.96       | 74.64       | 14.49       | 72.00       | 15.82       | 70.91       |  11.34      | 68.67       | 15.53       |


| System        | Size | X-en (COMET) | X-en (BLEU) | X-zh (COMET)| X-zh (BLEU) | X-de (COMET) | X-de (BLEU) | X-ne (COMET) | X-ne (BLEU) |X-ar (COMET) | X-ar (BLEU) | X-az (COMET) | X-az (BLEU) | X-ceb (COMET) | X-ceb (BLEU) |
|---------------|------|----------------|-------------| ----| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |--------------| 
| LLaMAX2-7B-Alpaca | 7B   |65.85| 16.44       |  56.53      | 4.46        | 56.76       | 9.01        | 34.96       | 1.03        | 44.10       | 2.18        |  40.67      | 0.63        | 45.69       | 1.73        |
| LLaMAX2-7B-Alpaca | 13B  |  68.72| 19.69       | 64.46| 8.80| 62.86| 12.57| 38.88| 2.16| 52.08| 4.48| 41.18| 0.87| 48.47| 2.51|
| LLaMAX2-7B-Alpaca| 7B   |  80.55 | 30.63       | 75.52       | 13.53       | 74.47       | 19.26       | 67.36       | 15.47       | 75.40       | 15.32       | 72.03       | 10.27       |  65.05| 16.11|


### 🔥 Effective Base Model for Multilingual Task

LLaMAX preserves its efficacy in general tasks and improves the performance on multilingual tasks.
We fine-tuned LLaMAX using only the English training set of downstream task, which also shows significant improvements in non-English. We provide fine-tuning LLaMAX models for the following three tasks:

- **Math Reasoning**: https://huggingface.co/LLaMAX/LLaMAX2-7B-MetaMath

- **Commonsense Reasoning**: https://huggingface.co/LLaMAX/LLaMAX2-7B-X-CSQA

- **Natural Language Inference**: https://huggingface.co/LLaMAX/LLaMAX2-7B-XNLI

### Supported Languages
Akrikaans (af), Amharic (am), Arabic (ar), Armenian (hy), Assamese (as), Asturian (ast), Azerbaijani (az), Belarusian (be), Bengali (bn), Bosnian (bs), Bulgarian (bg), Burmese (my), Catalan (ca), Cebuano (ceb), Chinese Simpl (zho), Chinese Trad (zho), Croatian (hr), Czech (cs), Danish (da), Dutch (nl), English (en), Estonian (et), Filipino (tl), Finnish (fi), French (fr), Fulah (ff), Galician (gl), Ganda (lg), Georgian (ka), German (de), Greek (el), Gujarati (gu), Hausa (ha), Hebrew (he), Hindi (hi), Hungarian (hu), Icelandic (is), Igbo (ig), Indonesian (id), Irish (ga), Italian (it), Japanese (ja), Javanese (jv), Kabuverdianu (kea), Kamba (kam), Kannada (kn), Kazakh (kk), Khmer (km), Korean (ko), Kyrgyz (ky), Lao (lo), Latvian (lv), Lingala (ln), Lithuanian (lt), Luo (luo), Luxembourgish (lb), Macedonian (mk), Malay (ms), Malayalam (ml), Maltese (mt), Maori (mi), Marathi (mr), Mongolian (mn), Nepali (ne), Northern Sotho (ns), Norwegian (no), Nyanja (ny), Occitan (oc), Oriya (or), Oromo (om), Pashto (ps), Persian (fa), Polish (pl), Portuguese (pt), Punjabi (pa), Romanian (ro), Russian (ru), Serbian (sr), Shona (sn), Sindhi (sd), Slovak (sk), Slovenian (sl), Somali (so), Sorani Kurdish (ku), Spanish (es), Swahili (sw), Swedish (sv), Tajik (tg), Tamil (ta), Telugu (te), Thai (th), Turkish (tr), Ukrainian (uk), Umbundu (umb), Urdu (ur), Uzbek (uz), Vietnamese (vi), Welsh (cy), Wolof (wo), Xhosa (xh), Yoruba (yo), Zulu (zu)

### Model Index
We implement multiple versions of the LLaMAX model, the model links are as follows:

| Model   | LLaMAX                                               | LLaMAX-Alpaca                                               |
|---------|----------------------------------------------------------|-----------------------------------------------------------------|
| Llama-2 | [Link](https://huggingface.co/LLaMAX/LLaMAX2-7B) | [Link](https://huggingface.co/LLaMAX/LLaMAX2-7B-Alpaca) |
| Llama-3 | [Link](https://huggingface.co/LLaMAX/LLaMAX3-8B) | [Link](https://huggingface.co/LLaMAX/LLaMAX3-8B-Alpaca) |

### Citation
If our model helps your work, please cite this paper:

```

@misc{lu2024llamaxscalinglinguistichorizons,

      title={LLaMAX: Scaling Linguistic Horizons of LLM by Enhancing Translation Capabilities Beyond 100 Languages}, 

      author={Yinquan Lu and Wenhao Zhu and Lei Li and Yu Qiao and Fei Yuan},

      year={2024},

      eprint={2407.05975},

      archivePrefix={arXiv},

      primaryClass={cs.CL},

      url={https://arxiv.org/abs/2407.05975}, 

}

```