sunkencity commited on
Commit
fdda1e0
·
verified ·
1 Parent(s): 105152c

Upload train_aviation.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. train_aviation.py +13 -13
train_aviation.py CHANGED
@@ -40,28 +40,28 @@ from trl import SFTTrainer, SFTConfig
40
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, AutoConfig
41
 
42
  # Register 'ministral3' config to handle nested text_config
43
- print("🔧 Registering ministral3 config...")
44
  try:
45
- # Use standard MistralConfig (not MinistralConfig) as base
46
- from transformers import MistralConfig, MistralModel, AutoModel, AutoConfig
47
- class Ministral3CompatConfig(MistralConfig):
48
- model_type = "ministral3"
49
 
50
- # 1. Register Config
51
- AutoConfig.register("ministral3", Ministral3CompatConfig)
52
- print(" Registered ministral3 -> Ministral3CompatConfig (subclass of MistralConfig)")
53
-
54
- # 2. Register Model for this config
55
- AutoModel.register(Ministral3CompatConfig, MistralModel)
56
- print(" Registered Ministral3CompatConfig -> MistralModel")
 
 
57
 
58
  except Exception as e:
59
- print(f" ❌ Failed to register ministral3 config/model: {e}")
60
 
61
  # Register Mistral3Config to a model class
62
  # ... (rest of registration kept as is)
63
  # ... (rest of registration kept as is)
64
  # ... (rest of registration kept as is)
 
65
  print("🔧 Registering Mistral3 model class...")
66
  try:
67
  from transformers.models.mistral3.configuration_mistral3 import Mistral3Config
 
40
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, AutoConfig
41
 
42
  # Register 'ministral3' config to handle nested text_config
43
+ print("🔧 Registering ministral3 config (Monkey Patch Strategy)...")
44
  try:
45
+ from transformers import MinistralConfig, AutoConfig
 
 
 
46
 
47
+ # Monkey patch the model_type to match what the config.json has
48
+ # This allows us to use the native class which is already registered with AutoModel
49
+ print(f" Original MinistralConfig.model_type: {MinistralConfig.model_type}")
50
+ MinistralConfig.model_type = "ministral3"
51
+ print(f" Patched MinistralConfig.model_type: {MinistralConfig.model_type}")
52
+
53
+ # Register the patched class for the "ministral3" key
54
+ AutoConfig.register("ministral3", MinistralConfig)
55
+ print(" Registered ministral3 -> MinistralConfig (native, patched)")
56
 
57
  except Exception as e:
58
+ print(f" ❌ Failed to patch/register ministral3 config: {e}")
59
 
60
  # Register Mistral3Config to a model class
61
  # ... (rest of registration kept as is)
62
  # ... (rest of registration kept as is)
63
  # ... (rest of registration kept as is)
64
+ # ... (rest of registration kept as is)
65
  print("🔧 Registering Mistral3 model class...")
66
  try:
67
  from transformers.models.mistral3.configuration_mistral3 import Mistral3Config