| import sys |
| import os |
| from safetensors.torch import save_file |
| import json |
| import torch |
|
|
| |
| model_dir = "/Users/Goekdeniz.Guelmez@computacenter.com/Library/CloudStorage/OneDrive-COMPUTACENTER/Desktop/MiniMax01Text-Dev" |
| sys.path.append(model_dir) |
|
|
| |
| from modeling_minimax import MiniMaxForCausalLM |
| from configuration_minimax import MiniMaxConfig |
|
|
| |
| config_path = os.path.join(model_dir, "config.json") |
| with open(config_path, 'r') as f: |
| config_dict = json.load(f) |
|
|
| |
| config = MiniMaxConfig(**config_dict) |
|
|
| |
| if getattr(config, "linear_attention", False): |
| print("Using linear attention layout from config.") |
| else: |
| print("Using full attention layout from config.") |
|
|
| |
| torch.manual_seed(42) |
|
|
| |
| small_model = MiniMaxForCausalLM(config) |
|
|
| |
| small_model.eval() |
|
|
| |
| param_count = sum(p.numel() for p in small_model.parameters()) |
| print(f"Model has {param_count:,} parameters") |
|
|
| |
| model_state_dict = small_model.state_dict() |
|
|
| |
| used_config_path = os.path.join(model_dir, "config.used.json") |
| with open(used_config_path, 'w') as f: |
| json.dump(config_dict, f, indent=2) |
|
|
| |
| save_file(model_state_dict, os.path.join(model_dir, "model.safetensors")) |
|
|
| print("Model saved in safetensors format") |
|
|
| print(small_model) |