模型概述
模型特點
模型能力
使用案例
🚀 LLaMAX語言模型
LLaMAX是一款具備強大多語言能力的語言模型,在不損失指令遵循能力的前提下,支持超100種語言的翻譯。它通過收集102種語言的大量訓練集對Llama2進行持續預訓練,並利用英文指令微調數據集Alpaca來微調其指令遵循能力。
🚀 快速開始
模型來源
- 論文:LLaMAX: Scaling Linguistic Horizons of LLM by Enhancing Translation Capabilities Beyond 100 Languages
- 鏈接:https://arxiv.org/pdf/2407.05975
- 倉庫:https://github.com/CONE-MT/LLaMAX/
- 演示:https://huggingface.co/spaces/vilarin/LLaMAX3-Translator 感謝@AnnioDance的努力。
✨ 主要特性
輕鬆實現多語言翻譯
LLaMAX支持超100種語言之間的翻譯,性能超越了同等規模的大語言模型。
出色的翻譯性能
LLaMAX3 - 8B - Alpaca在Flores - 101數據集上,與LLaMA3 - 8B - Alpaca模型相比,平均spBLEU得分提高了超過5分。
📦 安裝指南
文檔未提及安裝步驟,故跳過此章節。
💻 使用示例
基礎用法
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
高級用法
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"
📚 詳細文檔
支持的語言
阿非利卡語 (af)、阿姆哈拉語 (am)、阿拉伯語 (ar)、亞美尼亞語 (hy)、阿薩姆語 (as)、阿斯圖里亞斯語 (ast)、阿塞拜疆語 (az)、白俄羅斯語 (be)、孟加拉語 (bn)、波斯尼亞語 (bs)、保加利亞語 (bg)、緬甸語 (my)、加泰羅尼亞語 (ca)、宿務語 (ceb)、簡體中文 (zho)、繁體中文 (zho)、克羅地亞語 (hr)、捷克語 (cs)、丹麥語 (da)、荷蘭語 (nl)、英語 (en)、愛沙尼亞語 (et)、菲律賓語 (tl)、芬蘭語 (fi)、法語 (fr)、富拉語 (ff)、加利西亞語 (gl)、幹達語 (lg)、格魯吉亞語 (ka)、德語 (de)、希臘語 (el)、古吉拉特語 (gu)、豪薩語 (ha)、希伯來語 (he)、印地語 (hi)、匈牙利語 (hu)、冰島語 (is)、伊博語 (ig)、印尼語 (id)、愛爾蘭語 (ga)、意大利語 (it)、日語 (ja)、爪哇語 (jv)、佛得角克里奧爾語 (kea)、坎巴語 (kam)、卡納達語 (kn)、哈薩克語 (kk)、高棉語 (km)、韓語 (ko)、吉爾吉斯語 (ky)、老撾語 (lo)、拉脫維亞語 (lv)、林加拉語 (ln)、立陶宛語 (lt)、盧奧語 (luo)、盧森堡語 (lb)、馬其頓語 (mk)、馬來語 (ms)、馬拉雅拉姆語 (ml)、馬耳他語 (mt)、毛利語 (mi)、馬拉地語 (mr)、蒙古語 (mn)、尼泊爾語 (ne)、北索托語 (ns)、挪威語 (no)、尼揚賈語 (ny)、奧克語 (oc)、奧里亞語 (or)、奧羅莫語 (om)、普什圖語 (ps)、波斯語 (fa)、波蘭語 (pl)、葡萄牙語 (pt)、旁遮普語 (pa)、羅馬尼亞語 (ro)、俄語 (ru)、塞爾維亞語 (sr)、紹納語 (sn)、信德語 (sd)、斯洛伐克語 (sk)、斯洛文尼亞語 (sl)、索馬里語 (so)、庫爾德語 (ku)、西班牙語 (es)、斯瓦希里語 (sw)、瑞典語 (sv)、塔吉克語 (tg)、泰米爾語 (ta)、泰盧固語 (te)、泰語 (th)、土耳其語 (tr)、烏克蘭語 (uk)、溫本杜語 (umb)、烏爾都語 (ur)、烏茲別克語 (uz)、越南語 (vi)、威爾士語 (cy)、沃洛夫語 (wo)、科薩語 (xh)、約魯巴語 (yo)、祖魯語 (zu)
模型索引
我們實現了多個版本的LLaMAX模型,模型鏈接如下:
模型 | LLaMAX | LLaMAX - Alpaca |
---|---|---|
Llama - 2 | [鏈接](https://huggingface.co/LLaMAX/LLaMAX2 - 7B) | [鏈接](https://huggingface.co/LLaMAX/LLaMAX2 - 7B - Alpaca) |
Llama - 3 | [鏈接](https://huggingface.co/LLaMAX/LLaMAX3 - 8B - 8B) | [鏈接](https://huggingface.co/LLaMAX/LLaMAX3 - 8B - 8B - Alpaca) |
翻譯性能對比
系統 | 規模 | 英語到其他語言 (COMET) | 英語到其他語言 (BLEU) | 中文到其他語言 (COMET) | 中文到其他語言 (BLEU) | 德語到其他語言 (COMET) | 德語到其他語言 (BLEU) | 尼泊爾語到其他語言 (COMET) | 尼泊爾語到其他語言 (BLEU) | 阿拉伯語到其他語言 (COMET) | 阿拉伯語到其他語言 (BLEU) | 阿塞拜疆語到其他語言 (COMET) | 阿塞拜疆語到其他語言 (BLEU) | 宿務語到其他語言 (COMET) | 宿務語到其他語言 (BLEU) |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
LLaMA3 - 8B - Alpaca | 8B | 67.97 | 17.23 | 64.65 | 10.14 | 64.67 | 13.62 | 62.95 | 7.96 | 63.45 | 11.27 | 60.61 | 6.98 | 55.26 | 8.52 |
LLaMAX3 - 8B - Alpaca | 8B | 75.52 | 22.77 | 73.16 | 14.43 | 73.47 | 18.95 | 75.13 | 15.32 | 72.29 | 16.42 | 72.06 | 12.41 | 68.88 | 15.85 |
系統 | 規模 | 其他語言到英語 (COMET) | 其他語言到英語 (BLEU) | 其他語言到中文 (COMET) | 其他語言到中文 (BLEU) | 其他語言到德語 (COMET) | 其他語言到德語 (BLEU) | 其他語言到尼泊爾語 (COMET) | 其他語言到尼泊爾語 (BLEU) | 其他語言到阿拉伯語 (COMET) | 其他語言到阿拉伯語 (BLEU) | 其他語言到阿塞拜疆語 (COMET) | 其他語言到阿塞拜疆語 (BLEU) | 其他語言到宿務語 (COMET) | 其他語言到宿務語 (BLEU) |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
LLaMA3 - 8B - Alpaca | 8B | 77.43 | 26.55 | 73.56 | 13.17 | 71.59 | 16.82 | 46.56 | 3.83 | 66.49 | 10.20 | 58.30 | 4.81 | 52.68 | 4.18 |
LLaMAX3 - 8B - Alpaca | 8B | 81.28 | 31.85 | 78.34 | 16.46 | 76.23 | 20.64 | 65.83 | 14.16 | 75.84 | 15.45 | 70.61 | 9.32 | 63.35 | 12.66 |
🔧 技術細節
文檔未提及技術實現細節,故跳過此章節。
📄 許可證
本模型使用MIT許可證。
📚 引用
如果我們的模型對您的工作有幫助,請引用以下論文:
@inproceedings{lu-etal-2024-llamax,
title = "{LL}a{MAX}: Scaling Linguistic Horizons of {LLM} by Enhancing Translation Capabilities Beyond 100 Languages",
author = "Lu, Yinquan and
Zhu, Wenhao and
Li, Lei and
Qiao, Yu and
Yuan, Fei",
editor = "Al-Onaizan, Yaser and
Bansal, Mohit and
Chen, Yun-Nung",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2024",
month = nov,
year = "2024",
address = "Miami, Florida, USA",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.findings-emnlp.631",
doi = "10.18653/v1/2024.findings-emnlp.631",
pages = "10748--10772",
abstract = "Large Language Models (LLMs) demonstrate remarkable translation capabilities in high-resource language tasks, yet their performance in low-resource languages is hindered by insufficient multilingual data during pre-training. To address this, we conduct extensive multilingual continual pre-training on the LLaMA series models, enabling translation support across more than 100 languages. Through a comprehensive analysis of training strategies, such as vocabulary expansion and data augmentation, we develop LLaMAX. Remarkably, without sacrificing its generalization ability, LLaMAX achieves significantly higher translation performance compared to existing open-source LLMs (by more than 10 spBLEU points) and performs on-par with specialized translation model (M2M-100-12B) on the Flores-101 benchmark. Extensive experiments indicate that LLaMAX can serve as a robust multilingual foundation model. The code and the models are publicly available.",
}



