ChrisMcCormick commited on
Commit
7bca257
·
verified ·
1 Parent(s): b345064

Register Auto classes

Browse files
Files changed (1) hide show
  1. __init__.py +30 -0
__init__.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ Hugging Face Model Repository Init File
5
+
6
+ This file should be renamed to __init__.py and placed at the root of your
7
+ Hugging Face model repository. It ensures that the model registration code
8
+ is executed when the model is loaded from the Hub.
9
+ """
10
+
11
+ # Import the registration code from models/__init__.py
12
+ # This will execute the AutoConfig and AutoModel registration
13
+ try:
14
+ from models import *
15
+ except ImportError as e:
16
+ # If there are import issues, try importing the specific registration code
17
+ from transformers import AutoConfig, AutoModel, AutoModelForCausalLM
18
+ from models.shared_space_config import SharedSpaceDecoderConfig
19
+ from models.shared_space_decoder import (
20
+ SharedSpaceDecoderPreTrainedModel,
21
+ SharedSpaceDecoderModel,
22
+ )
23
+ from layers.task_heads import SharedSpaceDecoderForCausalLM
24
+
25
+ # Register the configuration class with AutoConfig
26
+ AutoConfig.register("shared_space_decoder", SharedSpaceDecoderConfig)
27
+
28
+ # Register the model classes with AutoModel
29
+ AutoModel.register(SharedSpaceDecoderConfig, SharedSpaceDecoderModel)
30
+ AutoModelForCausalLM.register(SharedSpaceDecoderConfig, SharedSpaceDecoderForCausalLM)