This project provides a complete pipeline for fine-tuning language models and converting them to GGUF format for efficient inference.
The pipeline includes the following steps:
- Environment setup with Python virtual environment
- Dependency installation
- Dataset generation
- Model fine-tuning with LoRA adapters
- Merging LoRA adapters with the base model
- Converting the merged model to GGUF format
- Analyzing training arguments
- Python 3.8 or higher
- pip (Python package installer)
- Git
git clone <repository-url>
cd hyperlane-ai-trainingExecute the main script to run the complete pipeline:
./run.shThis will:
- Create and activate a Python virtual environment
- Install all required dependencies
- Generate the dataset
- Fine-tune the model
- Merge the LoRA adapter with the base model
- Convert the merged model to GGUF format
- Analyze training arguments
For faster iteration during development, you can run the pipeline in development mode which limits the number of training steps:
./run.sh devThe project can be configured using a .env file in the root directory. The following environment variables are available:
MERGED_MODEL_DIR: Directory for the merged model (default: "merged_model")OUTPUT_DIR: Directory for the output files (default: "output")
Example .env file:
MERGED_MODEL_DIR=my_merged_model
OUTPUT_DIR=my_output
run.sh: Main execution scriptgenerate_markdown.py: Script to generate training datasetfinetune.py: Model fine-tuning scriptmerge_model.py: Script to merge LoRA adapters with the base modelconvert_hf_to_gguf.py: Script to convert models to GGUF formatanalyze_training_args.py: Script to analyze and log training argumentsdataset/: Directory containing the training dataset
The project requires the following Python packages:
- torch (>=2.3.0)
- transformers
- datasets
- trl
- peft
- accelerate
- hf_xet
- gguf
- mistral_common
- dotenv
After successful execution, the final GGUF model will be located at: $OUTPUT_DIR/$OUTPUT_DIR.gguf
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request.
For any inquiries, please reach out to the author at root@ltpp.vip.