模型简介
模型特点
模型能力
使用案例
🚀 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.",
}



