import sys import os from safetensors.torch import save_file import json # Add the directory containing your modeling.py and configuration.py to the Python path model_dir = "/Users/gokdenizgulmez/Desktop/mlx-lm/MiniMaxM1-Dev" sys.path.append(model_dir) # Import your custom model and configuration classes from modeling_minimax_m1 import MiniMaxM1ForCausalLM from configuration_minimax_m1 import MiniMaxM1Config # Load the configuration config_path = os.path.join(model_dir, "config.json") with open(config_path, 'r') as f: config_dict = json.load(f) # Create the configuration object config = MiniMaxM1Config(**config_dict) # Create the model small_model = MiniMaxM1ForCausalLM(config) # Print parameter count to verify param_count = sum(p.numel() for p in small_model.parameters()) print(f"Model has {param_count:,} parameters") # Convert model to state dict model_state_dict = small_model.state_dict() # Save as safetensors save_file(model_state_dict, os.path.join(model_dir, "model.safetensors")) print("Model saved in safetensors format")