Implemented a hyperparameter optimization training script for local hardware #45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a module in
minions/utils/minion_autotrain.pythat automatically identifies local hardware capabilities, selects a suitable finetuning strategy, and finetunes an SLM from huggingface on minion_logs/ which should contain all conversations between a local SLM and a remote LLM. I encode constraints on model selection and finetuning strategy selection so as to select the most powerful model and finetuning strategy to fit in device memory. This script makes general optimizations based on hardware constraints; a user could identify a performance metric for a downstream task and make minor adjustments to hyperparameters likelora_r,lora_alpha, andlora_dropout,num_epochs,learning_rateetc. if they feel this is necessary (although empirically dramatic differences from the default values in the script generally do not yield worthwhile gains).minions/utils/minion_autotrain.py:-Automatically detects hardware capabilities (GPU, CPU, MPS/Apple Silicon)
-Selects the optimal open-source LLM based on hardware specs. Right now we hardcode "TinyLlama/TinyLlama-1.1B-Chat-v1.0", "meta-llama/Llama-3.2-1B", "meta-llama/Llama-3.2-3B", and "microsoft/phi-4" (14.7B) as available models and select the largest model that will fit in system memory
-Chooses the best training protocol (QLoRA, LoRA, or Full-Finetuning) based on the intuition that full-finetuning (in BF16) is the most performant on downstream task performance, followed by LoRA (8 bit), then QLoRA (4 bit)
-Optimizes some hyperparameters such as batch size for the selected model and hardware. Others such as
lora_r,lora_alpha, andlora_dropoutare fixed following current practices for optimizing downstream task accuracy but can be changed inclass HyperparameterOptimizer-Processes minion logs to extract training pairs where we only use the "assistant" outputs from the minion logs for training
-Implements a training pipeline using Hugging Face Transformers and PEFT
Updated minions/utils/init.py to expose the auto_train_minion function.
To test this utility, run
python -m minions.utils.minion_autotrain --model-name defaultwhich will make use ofTinyLlama-1.1B-Chat-v1.0, one of the smallest models that does not require the appropriate Huggingface permissions.To have the utility automatically select the largest model that will fit into system memory, simply run
python -m minions.utils.minion_autotrainwhich will first detect your hardware capabilities, then select the optimal model and training approach, process your minion logs to create a training dataset, train the model with the best hyperparameters for your setup, save the trained model to the specified output directory. We useargparseto provide defaults for log directory and saved model directory.