Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	Update requirements and make necessary code changes
Browse files
    	
        .ipynb_checkpoints/model_loader-checkpoint.py
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
|  | |
|  | |
| 1 | 
             
            import torch
         | 
| 2 | 
             
            import torch.nn as nn
         | 
| 3 | 
             
            import torch.nn.functional as F
         | 
| @@ -628,14 +630,11 @@ def load_model(): | |
| 628 | 
             
                    model, tokenizer = load_T5_model_classification(checkpoint, num_labels, mixed, full, deepspeed)
         | 
| 629 |  | 
| 630 |  | 
| 631 | 
            -
                 | 
| 632 | 
            -
             | 
| 633 | 
            -
                print(checkpoint_dir)
         | 
| 634 | 
            -
                # Construct the path to the custom checkpoint file
         | 
| 635 | 
            -
                best_model_path = os.path.join(checkpoint_dir, 'cpt.pth')
         | 
| 636 |  | 
| 637 | 
             
                # Load the best model state
         | 
| 638 | 
            -
                state_dict = torch.load( | 
| 639 | 
             
                model.load_state_dict(state_dict)
         | 
| 640 |  | 
| 641 | 
             
                return model, tokenizer
         | 
|  | |
| 1 | 
            +
            from huggingface_hub import hf_hub_download
         | 
| 2 | 
            +
             | 
| 3 | 
             
            import torch
         | 
| 4 | 
             
            import torch.nn as nn
         | 
| 5 | 
             
            import torch.nn.functional as F
         | 
|  | |
| 630 | 
             
                    model, tokenizer = load_T5_model_classification(checkpoint, num_labels, mixed, full, deepspeed)
         | 
| 631 |  | 
| 632 |  | 
| 633 | 
            +
                # Download the file
         | 
| 634 | 
            +
                local_file = hf_hub_download(repo_id=checkpoint, filename="cpt.pth")
         | 
|  | |
|  | |
|  | |
| 635 |  | 
| 636 | 
             
                # Load the best model state
         | 
| 637 | 
            +
                state_dict = torch.load(local_file, weights_only=True)
         | 
| 638 | 
             
                model.load_state_dict(state_dict)
         | 
| 639 |  | 
| 640 | 
             
                return model, tokenizer
         | 
    	
        .ipynb_checkpoints/requirements-checkpoint.txt
    CHANGED
    
    | @@ -7,3 +7,4 @@ pandas>=1.1.0 | |
| 7 | 
             
            numpy>=1.19.0
         | 
| 8 | 
             
            scikit-learn>=0.24.0
         | 
| 9 | 
             
            sentencepiece
         | 
|  | 
|  | |
| 7 | 
             
            numpy>=1.19.0
         | 
| 8 | 
             
            scikit-learn>=0.24.0
         | 
| 9 | 
             
            sentencepiece
         | 
| 10 | 
            +
            huggingface_hub>=0.15.0
         | 
    	
        model_loader.py
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
|  | |
|  | |
| 1 | 
             
            import torch
         | 
| 2 | 
             
            import torch.nn as nn
         | 
| 3 | 
             
            import torch.nn.functional as F
         | 
| @@ -628,14 +630,11 @@ def load_model(): | |
| 628 | 
             
                    model, tokenizer = load_T5_model_classification(checkpoint, num_labels, mixed, full, deepspeed)
         | 
| 629 |  | 
| 630 |  | 
| 631 | 
            -
                 | 
| 632 | 
            -
             | 
| 633 | 
            -
                print(checkpoint_dir)
         | 
| 634 | 
            -
                # Construct the path to the custom checkpoint file
         | 
| 635 | 
            -
                best_model_path = os.path.join(checkpoint_dir, 'cpt.pth')
         | 
| 636 |  | 
| 637 | 
             
                # Load the best model state
         | 
| 638 | 
            -
                state_dict = torch.load( | 
| 639 | 
             
                model.load_state_dict(state_dict)
         | 
| 640 |  | 
| 641 | 
             
                return model, tokenizer
         | 
|  | |
| 1 | 
            +
            from huggingface_hub import hf_hub_download
         | 
| 2 | 
            +
             | 
| 3 | 
             
            import torch
         | 
| 4 | 
             
            import torch.nn as nn
         | 
| 5 | 
             
            import torch.nn.functional as F
         | 
|  | |
| 630 | 
             
                    model, tokenizer = load_T5_model_classification(checkpoint, num_labels, mixed, full, deepspeed)
         | 
| 631 |  | 
| 632 |  | 
| 633 | 
            +
                # Download the file
         | 
| 634 | 
            +
                local_file = hf_hub_download(repo_id=checkpoint, filename="cpt.pth")
         | 
|  | |
|  | |
|  | |
| 635 |  | 
| 636 | 
             
                # Load the best model state
         | 
| 637 | 
            +
                state_dict = torch.load(local_file, weights_only=True)
         | 
| 638 | 
             
                model.load_state_dict(state_dict)
         | 
| 639 |  | 
| 640 | 
             
                return model, tokenizer
         | 
    	
        requirements.txt
    CHANGED
    
    | @@ -7,3 +7,4 @@ pandas>=1.1.0 | |
| 7 | 
             
            numpy>=1.19.0
         | 
| 8 | 
             
            scikit-learn>=0.24.0
         | 
| 9 | 
             
            sentencepiece
         | 
|  | 
|  | |
| 7 | 
             
            numpy>=1.19.0
         | 
| 8 | 
             
            scikit-learn>=0.24.0
         | 
| 9 | 
             
            sentencepiece
         | 
| 10 | 
            +
            huggingface_hub>=0.15.0
         | 
