This repository provides a framework for fine-tuning large language models (LLMs) such as GPT-2, LLAMA, and Mistral. The framework is designed to be flexible and easy to use, allowing users to specify the pretrained model, dataset, and optimization options via command-line arguments.
- Support for popular LLMs: GPT-2, LLAMA, Mistral
- Command-line interface for easy configuration
- Support for optimization methods: LoRA, QLORA
Clone this repository and install the required dependencies:
git clone https://github.com/yourusername/finetune-llm-framework.git
cd finetune-llm-framework
pip install -r requirements.txt
Fine-tune a pretrained model with a specified dataset:
python src/main.py --model_name gpt2 --dataset_name wikitext --output_dir ./results --epochs 3 --batch_size 8 --learning_rate 5e-5 --optimization lora
Run inference on the fine-tuned model:
python src/inference.py --model_dir ./results --input_text "Once upon a time"
- model_name: Pretrained model name (e.g., gpt2, llama, mistral)
- dataset_name: Dataset name (e.g., wikitext, glue)
- output_dir: Directory to save the results
- epochs: Number of training epochs
- batch_size: Batch size for training
- learning_rate: Learning rate
- optimization: Optimization method (lora, qlora, none)
- model_dir: Directory of the fine-tuned model
- input_text: Input text for inference
To fine-tune the GPT-2 model on the Wikitext dataset using LoRA optimization:
python src/main.py --model_name gpt2 --dataset_name wikitext --output_dir ./results --epochs 3 --batch_size 8 --learning_rate 5e-5 --optimization lora
To run inference on the fine-tuned model:
python src/inference.py --model_dir ./results --input_text "Once upon a time"
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.