This project has been reorganized into a modular structure for better maintainability and readability.
This project is a simple script that downloads a dataset, loads a model, and trains it on the dataset using the Apple MLX Python API. It is designed to be a starting point for your own projects.
It enables fine-tuning a model on a dataset and evaluating its performance. Using LoRA or QLoRA automatically for 4bit quantized models.
It enables conversion of large language models to smaller models for faster inference using built-in quantization script i.e. part of the Apple MLX Python package.
git clone https://github.com/M37Labs/apple-mlx-starter.gitpython3 -m venv venvsource venv/bin/activatepip install -r requirements.txtpython main.pyFollow the instructions in terminal output to train a model and run inference. Example output (DO NOT COPY THIS):
- All existing functionality is preserved
- The original
apple_mlx_script.pyis now deprecated - No breaking changes to the user interface
- All imports and dependencies remain the same
apple-mlx/
├── main.py # Main entry point
├── config.py # Configuration constants
├── utils.py # Utility functions and color formatting
├── data_processor.py # Data processing functions
├── instructions.py # Training instructions and command generation
├── apple_mlx_script.py # Backward compatibility wrapper
├── requirements.txt # Dependencies
└── train_data/ # Generated training data
├── train.jsonl
├── valid.jsonl
└── test.jsonl
- Purpose: Main entry point that orchestrates the entire workflow
- Function: Imports and calls the data processing and instruction modules
- Usage: Run with
python main.py
- Purpose: Centralized configuration management
- Contains: All constants, URLs, model names, and directory paths
- Benefits: Easy to modify settings without touching other files
- Purpose: Utility functions and formatting helpers
- Contains: Color formatting functions, divider functions, and style constants
- Benefits: Consistent styling across the application
- Purpose: Core data processing functionality
- Contains:
- SQuAD data download
- Data extraction and formatting
- Data splitting (train/validation/test)
- JSONL file saving
- Main data processing workflow
- Benefits: Isolated data processing logic
- Purpose: Training instruction generation
- Contains: Formatted command generation for model preparation, training, and testing
- Benefits: Clean separation of instruction logic
- Modularity: Each file has a single responsibility
- Maintainability: Easier to modify specific functionality
- Readability: Clear separation of concerns
- Reusability: Individual modules can be imported and used separately
- Testing: Easier to write unit tests for individual components
- Backward Compatibility: Existing scripts continue to work
