Upload train_aviation.py with huggingface_hub
Browse files- 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 |
-
|
| 46 |
-
from transformers import MistralConfig, MistralModel, AutoModel, AutoConfig
|
| 47 |
-
class Ministral3CompatConfig(MistralConfig):
|
| 48 |
-
model_type = "ministral3"
|
| 49 |
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
print("
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
|
| 58 |
except Exception as e:
|
| 59 |
-
print(f" ❌ Failed to register ministral3 config
|
| 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
|