LLaMa2Lang Introduction
LLaMa2Lang is a powerful tool designed to finetune LLaMa3 and other foundation models for chat in any language. Developed by AI-Commandos, this repository contains scripts that facilitate the process of training models to perform better in non-English languages. LLaMa3, although trained on primarily English data, can be adapted to other languages using LLaMa2Lang, resulting in improved performance and more natural language generation.
LLaMa2Lang Features
Translation
One of the key features of LLaMa2Lang is its ability to translate datasets into the target language. This is achieved using various translation models, such as OPUS, M2M, MADLAD, mBART, and NLLB. The choice of translation model depends on the target language and the user's preference. LLaMa2Lang provides a benchmark.py script to help users determine the best translation model for their specific needs.
Dataset Conversion
LLaMa2Lang includes a script to combine the translated checkpoint files into a Huggingface Dataset. This dataset can then be used for finetuning the foundation model. The script can write the dataset to disk or publish it to the Huggingface Hub, providing flexibility and convenience for users.
Finetuning
The core functionality of LLaMa2Lang is finetuning foundation models using (Q)LoRA and PEFT. This process involves loading a dataset containing Q&A/instruction pairs, translating it to the target language, and extracting threads by selecting prompts with their respective answers. The threads are then turned into prompts following a customizable template.
DPO and ORPO
LLaMa2Lang also offers the option to finetune models using DPO (RLHF) or ORPO. These techniques can further extend the model's capabilities and teach it preferred answers over rejected ones. This is particularly useful when the base dataset includes such information.
Inference
Once the model is finetuned, LLaMa2Lang provides a script to run inference using the newly trained model. This allows users to test the model's performance and generate responses in the target language.
LLaMa2Lang Usage
To use LLaMa2Lang, users need to clone the repository and install the required dependencies. The usage instructions are provided in the README.md file, which includes detailed explanations of each script and its parameters.
LLaMa2Lang Supported Paradigms
LLaMa2Lang supports various translation models and base datasets, making it a versatile tool for finetuning foundation models for different languages. The supported paradigms include:
- Translation Models: OPUS, M2M, MADLAD, mBART, NLLB, Seamless (Large only), Tower Instruct
- Base Datasets: OASST1, OASST2
- Foundation Models: LLaMa3, LLaMa2, Mistral, Mixtral 8x7B
LLaMa2Lang Roadmap
The LLaMa2Lang repository has an active roadmap for future development, including:
- Investigating interoperability with other libraries (Axolotl, llamacpp, unsloth)
- Allowing for different quantizations next to QLoRA (GGUF, GPTQ, AWQ)
- Supporting extending the tokenizer and vocabulary
LLaMa2Lang Cost and Runtime
LLaMa2Lang can be run on a free Google Colab T4 GPU, making it accessible to a wide range of users. The runtime for the translation step can be substantial, taking around 36 hours for a single language, but it can be run in multiple steps to manage the workload.
LLaMa2Lang FAQ
Can I use other frameworks for fine-tuning?
Yes, LLaMa2Lang is compatible with other frameworks such as Axolotl for training on multi-GPU setups.
Can I mix different translation models?
Absolutely, mixing different translation models might even increase performance. Users can achieve this by early-stopping a translation and continuing from the checkpoints with a different translation model.
How well do the finetunes perform compared to vanilla LLaMa3?
While formal benchmarks are not available, LLaMa2Lang finetunes have shown to consistently perform better than vanilla LLaMa3 in non-English languages, producing more grammatically correct and natural language.
LLaMa2Lang Funding
AI-Commandos is actively seeking funding to democratize AI and advance its applications. Users interested in supporting this project can contact them at [email protected].