Backup-bdg commited on
Commit
fac1efa
·
verified ·
1 Parent(s): 61463d5

Update model weights after training (epoch 1, loss 12.7932)

Browse files
audio_decoder.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:33cd64538ab48c690ed0afbc044a236d26f6b7a731b56366e6cc3da4d2b1bb1a
3
  size 1458415836
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdd54c3025809382728dce3459184584a22eddee107472efc179a52b01e60409
3
  size 1458415836
audio_encoder.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cd06846915bf81f9619f0f235bc87432af972f108fabd5641c6fedf4bc211d5f
3
  size 466150140
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f38f6922edf7291ac97e6bd509830bd202978d1dac41f57e11f891753367de4d
3
  size 466150140
audio_projector.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0f14ee94b2dbc12d2bcb7122f1c007602419a4ef10b92b724ede52fdd2e488a0
3
  size 2099352
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27d2510596f713b85ddc3d6e172277b34c6ef824a5632058496d67093506863d
3
  size 2099352
cross_attention.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d81f0f0b7fae83ed9cc582826729c09c340665f8e5bfa11fa2a3a1b34fcc3b81
3
  size 174191400
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78710f2a29bf0a2d75cffef87817d3fe899330004d44861541e5d3b0381a3ed2
3
  size 174191400
generator.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d6abe298e9826a4652f91afa17a3393657eb6267d866bd8bde437cdf44186b9d
3
  size 629440508
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a194896fc7c1c35d6013adf3dc3bb1e18b01dfad74b1cedb2fe13670b65ccedd
3
  size 629440508
llm.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:64f0666b62452a957a9caa7b14ae17194cc7fe73f03ae7131b2cd1ba0448cc9f
3
  size 1506831304
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f099a9a521f89605c1c237f9ce03aa9d9b5a204cac5cffee72a39adbfe13fbd
3
  size 1506831304
modality_markers.safetensors CHANGED
Binary files a/modality_markers.safetensors and b/modality_markers.safetensors differ
 
modeling_xoron.py CHANGED
@@ -475,9 +475,8 @@ class XoronModel(XoronPreTrainedModel):
475
  """
476
  Save model to directory in HuggingFace format.
477
 
478
- This saves both the model weights and dynamically builds a self-contained
479
- modeling_xoron.py that can be loaded with trust_remote_code=True without
480
- requiring the full Xoron-Dev package.
481
  """
482
  os.makedirs(save_directory, exist_ok=True)
483
 
@@ -488,18 +487,21 @@ class XoronModel(XoronPreTrainedModel):
488
  if self._internal_model is not None:
489
  self._internal_model.save_pretrained(save_directory)
490
 
491
- # Copy configuration file
492
  import shutil
493
  current_dir = os.path.dirname(os.path.abspath(__file__))
494
 
495
- config_src = os.path.join(current_dir, 'configuration_xoron.py')
496
- config_dst = os.path.join(save_directory, 'configuration_xoron.py')
497
- if os.path.exists(config_src):
498
- shutil.copy2(config_src, config_dst)
 
499
 
500
- # Build self-contained modeling_xoron.py dynamically
501
- modeling_dst = os.path.join(save_directory, 'modeling_xoron.py')
502
- self._build_self_contained_modeling_file(current_dir, modeling_dst)
 
 
503
 
504
  # Update config.json with auto_map for trust_remote_code
505
  config_path = os.path.join(save_directory, 'config.json')
@@ -518,284 +520,6 @@ class XoronModel(XoronPreTrainedModel):
518
 
519
  if push_to_hub:
520
  self.push_to_hub(save_directory, **kwargs)
521
-
522
- def _build_self_contained_modeling_file(self, repo_root: str, output_path: str):
523
- """
524
- Build a self-contained modeling_xoron.py by combining all model components.
525
-
526
- This allows HuggingFace users to load the model with trust_remote_code=True
527
- without needing to install the full Xoron-Dev package.
528
- """
529
- import re
530
-
531
- # Component files to combine (in dependency order)
532
- component_files = [
533
- "models/components/lora.py",
534
- "models/components/attention.py",
535
- "models/components/projectors.py",
536
- "models/components/moe.py",
537
- "models/encoders/vision.py",
538
- "models/encoders/video.py",
539
- "models/encoders/audio.py",
540
- "models/generators/image.py",
541
- "models/generators/video.py",
542
- "models/llm/moe_llama.py",
543
- "models/xoron.py",
544
- ]
545
-
546
- # Internal imports to remove
547
- internal_import_patterns = [
548
- r"^from config import.*$",
549
- r"^from config\..*import.*$",
550
- r"^from models\..*import.*$",
551
- r"^from models import.*$",
552
- ]
553
-
554
- def is_internal_import(line):
555
- line = line.strip()
556
- for pattern in internal_import_patterns:
557
- if re.match(pattern, line):
558
- return True
559
- return False
560
-
561
- def is_external_import(line):
562
- line = line.strip()
563
- return (line.startswith("import ") or
564
- (line.startswith("from ") and not is_internal_import(line)))
565
-
566
- def extract_code_body(content):
567
- """Extract code body, removing module docstring and imports."""
568
- lines = content.split('\n')
569
- code_lines = []
570
- i = 0
571
-
572
- # Skip leading whitespace
573
- while i < len(lines) and not lines[i].strip():
574
- i += 1
575
-
576
- # Skip module docstring if present
577
- if i < len(lines):
578
- stripped = lines[i].strip()
579
- if stripped.startswith('"""') or stripped.startswith("'''"):
580
- docstring_char = stripped[:3]
581
- if stripped.count(docstring_char) >= 2:
582
- i += 1
583
- else:
584
- i += 1
585
- while i < len(lines):
586
- if docstring_char in lines[i]:
587
- i += 1
588
- break
589
- i += 1
590
-
591
- # Process remaining lines
592
- for line in lines[i:]:
593
- stripped = line.strip()
594
-
595
- # Skip empty lines at start
596
- if not code_lines and not stripped:
597
- continue
598
-
599
- # Skip internal imports
600
- if is_internal_import(line):
601
- continue
602
-
603
- # Skip external imports (we'll add our own)
604
- if is_external_import(line):
605
- continue
606
-
607
- # Skip logger setup lines
608
- if stripped.startswith("logger = logging.getLogger"):
609
- continue
610
-
611
- code_lines.append(line)
612
-
613
- # Remove trailing empty lines
614
- while code_lines and not code_lines[-1].strip():
615
- code_lines.pop()
616
-
617
- return '\n'.join(code_lines)
618
-
619
- # Build the file
620
- header = '''"""
621
- Xoron Model for HuggingFace Transformers - Self-Contained Implementation.
622
-
623
- AUTO-GENERATED FILE - Do not edit directly!
624
-
625
- This module provides a complete, self-contained HuggingFace-compatible model class
626
- for the Xoron multimodal model. All components are embedded directly in this file
627
- to enable loading via AutoModel with trust_remote_code=True WITHOUT requiring
628
- the full Xoron-Dev package to be installed.
629
-
630
- Usage:
631
- from transformers import AutoModel, AutoConfig
632
- config = AutoConfig.from_pretrained("your-repo/xoron-model", trust_remote_code=True)
633
- model = AutoModel.from_pretrained("your-repo/xoron-model", trust_remote_code=True)
634
- """
635
-
636
- import os
637
- import math
638
- import json
639
- import logging
640
- from dataclasses import dataclass, field
641
- from typing import Optional, Dict, List, Union, Tuple, Any
642
-
643
- import torch
644
- import torch.nn as nn
645
- import torch.nn.functional as F
646
-
647
- try:
648
- from safetensors.torch import save_model, load_model
649
- except ImportError:
650
- save_model, load_model = None, None
651
-
652
- from transformers import PreTrainedModel, LlamaConfig, LlamaModel, LlamaForCausalLM
653
- from transformers.modeling_outputs import CausalLMOutputWithPast, BaseModelOutputWithPast
654
-
655
- try:
656
- from transformers.models.llama.modeling_llama import (
657
- LlamaAttention, LlamaDecoderLayer, LlamaRMSNorm, LlamaMLP,
658
- LlamaRotaryEmbedding, apply_rotary_pos_emb, repeat_kv
659
- )
660
- except ImportError:
661
- LlamaAttention = LlamaDecoderLayer = LlamaRMSNorm = LlamaMLP = None
662
- LlamaRotaryEmbedding = apply_rotary_pos_emb = repeat_kv = None
663
-
664
- # Import configuration
665
- try:
666
- from .configuration_xoron import XoronConfig
667
- except ImportError:
668
- from configuration_xoron import XoronConfig
669
-
670
- logger = logging.getLogger(__name__)
671
-
672
- '''
673
-
674
- all_code = [header]
675
-
676
- # Process each component file
677
- for filepath in component_files:
678
- full_path = os.path.join(repo_root, filepath)
679
- if not os.path.exists(full_path):
680
- continue
681
-
682
- with open(full_path, 'r', encoding='utf-8') as f:
683
- content = f.read()
684
-
685
- code = extract_code_body(content)
686
- if code.strip():
687
- section_name = filepath.replace('/', '.').replace('.py', '').upper()
688
- section_header = f"\n\n# {'='*78}\n# {section_name}\n# {'='*78}\n\n"
689
- all_code.append(section_header + code)
690
-
691
- # Add HuggingFace wrapper classes
692
- hf_wrapper = '''
693
-
694
- # ==============================================================================
695
- # HUGGINGFACE WRAPPER CLASSES
696
- # ==============================================================================
697
-
698
- class XoronPreTrainedModel(PreTrainedModel):
699
- """Base class for Xoron models providing HuggingFace integration."""
700
-
701
- config_class = XoronConfig
702
- base_model_prefix = "xoron"
703
- supports_gradient_checkpointing = True
704
- _no_split_modules = ["XoronMultimodalModel"]
705
- _skip_keys_device_placement = "past_key_values"
706
-
707
- def _init_weights(self, module):
708
- std = 0.02
709
- if isinstance(module, nn.Linear):
710
- module.weight.data.normal_(mean=0.0, std=std)
711
- if module.bias is not None:
712
- module.bias.data.zero_()
713
- elif isinstance(module, nn.Embedding):
714
- module.weight.data.normal_(mean=0.0, std=std)
715
- if module.padding_idx is not None:
716
- module.weight.data[module.padding_idx].zero_()
717
- elif isinstance(module, nn.LayerNorm):
718
- module.bias.data.zero_()
719
- module.weight.data.fill_(1.0)
720
-
721
-
722
- class XoronModel(XoronPreTrainedModel):
723
- """Xoron Multimodal Model for HuggingFace."""
724
-
725
- def __init__(self, config: XoronConfig):
726
- super().__init__(config)
727
- self.config = config
728
- self._internal_model = XoronMultimodalModel(config)
729
- self.post_init()
730
-
731
- @property
732
- def internal_model(self):
733
- return self._internal_model
734
-
735
- def forward(
736
- self,
737
- input_ids: torch.Tensor,
738
- attention_mask: Optional[torch.Tensor] = None,
739
- pixel_values: Optional[torch.Tensor] = None,
740
- video_frames: Optional[torch.Tensor] = None,
741
- audio_features: Optional[torch.Tensor] = None,
742
- labels: Optional[torch.Tensor] = None,
743
- output_attentions: Optional[bool] = None,
744
- output_hidden_states: Optional[bool] = None,
745
- return_dict: Optional[bool] = None,
746
- **kwargs,
747
- ) -> Union[Tuple, CausalLMOutputWithPast]:
748
- return_dict = return_dict if return_dict is not None else self.config.use_return_dict
749
-
750
- outputs = self._internal_model(
751
- input_ids=input_ids,
752
- attention_mask=attention_mask,
753
- images=pixel_values,
754
- video=video_frames,
755
- audio=audio_features,
756
- labels=labels,
757
- )
758
-
759
- if return_dict:
760
- return CausalLMOutputWithPast(
761
- loss=outputs.get('loss'),
762
- logits=outputs.get('logits'),
763
- past_key_values=outputs.get('past_key_values'),
764
- hidden_states=outputs.get('hidden_states'),
765
- attentions=outputs.get('attentions'),
766
- )
767
-
768
- return (outputs.get('loss'), outputs.get('logits'))
769
-
770
- def generate_image(self, prompt_embeds: torch.Tensor, **kwargs):
771
- return self._internal_model.generate_image(prompt_embeds, **kwargs)
772
-
773
- def generate_video(self, prompt_embeds: torch.Tensor, **kwargs):
774
- return self._internal_model.generate_video(prompt_embeds, **kwargs)
775
-
776
- def generate_speech(self, text_embeds: torch.Tensor, **kwargs):
777
- return self._internal_model.generate_speech(text_embeds, **kwargs)
778
-
779
-
780
- class XoronForCausalLM(XoronModel):
781
- """Alias for XoronModel for compatibility."""
782
- pass
783
-
784
-
785
- # Register for AutoClass
786
- XoronConfig.register_for_auto_class()
787
- XoronModel.register_for_auto_class("AutoModel")
788
- XoronForCausalLM.register_for_auto_class("AutoModelForCausalLM")
789
- '''
790
- all_code.append(hf_wrapper)
791
-
792
- # Write output file
793
- final_content = '\n'.join(all_code)
794
- with open(output_path, 'w', encoding='utf-8') as f:
795
- f.write(final_content)
796
-
797
- line_count = final_content.count('\n')
798
- print(f" 📦 Built self-contained modeling_xoron.py ({line_count:,} lines)")
799
 
800
 
801
  class XoronForCausalLM(XoronModel):
 
475
  """
476
  Save model to directory in HuggingFace format.
477
 
478
+ This saves both the model weights and the custom code files
479
+ needed for trust_remote_code loading.
 
480
  """
481
  os.makedirs(save_directory, exist_ok=True)
482
 
 
487
  if self._internal_model is not None:
488
  self._internal_model.save_pretrained(save_directory)
489
 
490
+ # Copy custom code files for trust_remote_code
491
  import shutil
492
  current_dir = os.path.dirname(os.path.abspath(__file__))
493
 
494
+ # Files to copy
495
+ files_to_copy = [
496
+ 'configuration_xoron.py',
497
+ 'modeling_xoron.py',
498
+ ]
499
 
500
+ for filename in files_to_copy:
501
+ src = os.path.join(current_dir, filename)
502
+ dst = os.path.join(save_directory, filename)
503
+ if os.path.exists(src):
504
+ shutil.copy2(src, dst)
505
 
506
  # Update config.json with auto_map for trust_remote_code
507
  config_path = os.path.join(save_directory, 'config.json')
 
520
 
521
  if push_to_hub:
522
  self.push_to_hub(save_directory, **kwargs)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
 
524
 
525
  class XoronForCausalLM(XoronModel):
projector.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:29201dd7bea97c27d99d71cb06a71f1c8122ff185b7833957b49627709c1a2c8
3
  size 52880664
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7f70e42cfac214c75c189d74f0721c19a0db5d0da465ec8e79dc90a1a0be94bb
3
  size 52880664
streaming_state.json CHANGED
@@ -3,20 +3,20 @@
3
  "unique_samples": 1,
4
  "total_yields": 2,
5
  "dataset_positions": {
6
- "WebSight": 1
7
  },
8
  "modality_positions": {
9
  "text": {},
10
- "image": {
11
- "WebSight": 1
 
12
  },
13
- "video": {},
14
  "audio": {}
15
  },
16
  "modality_counts": {
17
  "text": 0,
18
- "image": 1,
19
- "video": 0,
20
  "audio": 0
21
  },
22
  "last_modality": null
 
3
  "unique_samples": 1,
4
  "total_yields": 2,
5
  "dataset_positions": {
6
+ "Sora-Style-Likert": 1
7
  },
8
  "modality_positions": {
9
  "text": {},
10
+ "image": {},
11
+ "video": {
12
+ "Sora-Style-Likert": 1
13
  },
 
14
  "audio": {}
15
  },
16
  "modality_counts": {
17
  "text": 0,
18
+ "image": 0,
19
+ "video": 1,
20
  "audio": 0
21
  },
22
  "last_modality": null
trainer_state.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "best_model_checkpoint": "/kaggle/working/xoron-final",
3
- "best_metric": 12.430816173553467,
4
  "epoch": 1,
5
  "epochs_completed": 1,
6
  "global_step": 0,
@@ -17,16 +17,16 @@
17
  "max_grad_norm": 1.0,
18
  "trainable_components": [
19
  "vision",
 
20
  "llm",
21
  "cross_attention",
22
- "image_generation",
23
  "modality_markers"
24
  ],
25
  "frozen_components": [
26
- "video",
27
  "audio",
28
  "speech",
29
- "video_generation"
30
  ],
31
  "trial_name": null,
32
  "trial_params": null
 
1
  {
2
  "best_model_checkpoint": "/kaggle/working/xoron-final",
3
+ "best_metric": 12.793164253234863,
4
  "epoch": 1,
5
  "epochs_completed": 1,
6
  "global_step": 0,
 
17
  "max_grad_norm": 1.0,
18
  "trainable_components": [
19
  "vision",
20
+ "video",
21
  "llm",
22
  "cross_attention",
23
+ "video_generation",
24
  "modality_markers"
25
  ],
26
  "frozen_components": [
 
27
  "audio",
28
  "speech",
29
+ "image_generation"
30
  ],
31
  "trial_name": null,
32
  "trial_params": null
training_state.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cabf5d817b134ab53a234f26371f536f37e818b23811dcd0c6142c335f71166f
3
- size 5143
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ed0a7799b91727f0ad203a1b686176319c5556cb441238bde744d765824dc67
3
+ size 6167
video_encoder.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:91a62a45d920fd3989d728c1cbb851cea12c081330aaaefb58a6d78d39aa4c63
3
  size 1923089112
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4ca3d1114993b0267e8f769779c8774b22a3f0bba781436311c292c745d7a4a6
3
  size 1923089112
video_generator.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:775996f8c250140d886f7c03673370969f829088c7796143d291796fdc2b16ac
3
  size 61574134
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0138141f5e37860df2a57152882d24962e042f0781249edd16b3b2934e62c178
3
  size 61574134
vision_encoder.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:49c149f367899d37da59699a65c41fd0a8c8aafd757c09491b565f751279318c
3
  size 1000535480
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db8657fa0918d538c717c153d0104d49d5cc7417d34c1fd36cf8d278e653f9df
3
  size 1000535480
waveform_decoder.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ec52685af5d97e3adf34b326c8ec2b821ee9b4ed084249953afae524f056019a
3
  size 34681076
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9778a8e34136fe9dd2603100b3a20da0b80423573f89068bac005e9eef239fcb
3
  size 34681076