CLI tool for finetuning LLaMa3 for non-English chat
Top 87.8% on sourcepulse
This repository provides scripts to fine-tune LLaMa3 and other foundation models for non-English languages. It addresses the limitation of base models performing poorly in languages other than English by translating datasets and fine-tuning using QLoRA and PEFT. The target audience includes researchers and developers aiming to create multilingual LLMs.
How It Works
The process involves translating a base dataset (like OASST1) to a target language using various translation models (OPUS M2M, MADLAD, NLLB, etc.). These translated conversations are then structured into prompt threads. Finally, QLoRA and PEFT are used to fine-tune a foundation model on this translated data, with optional Direct Preference Optimization (DPO) or Ordinal Preference Optimization (ORPO) for further refinement. This approach leverages efficient fine-tuning techniques to adapt powerful base models to specific languages.
Quick Start & Requirements
pip install -r requirements.txt
python translate.py m2m nl ./output_nl --quant4 --batch_size 20
python combine_checkpoints.py ./output_nl ./hf_dataset_nl
python finetune.py tuned_model_nl hf_dataset_nl "You are a generic chatbot that always answers in Dutch."
python run_inference.py tuned_model_nl "You are a generic chatbot that always answers in Dutch." "Wat is de hoofdstad van Nederland?"
Highlighted Details
benchmark.py
) available to compare translation model performance.Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
1 year ago
1 day