Edwin Jose Palathinkal commited on
Commit
4b0dbc8
·
1 Parent(s): dfb0344

Fix HuggingFace API compatibility

Browse files

- Add auto_map to config.json for proper model loading
- Update max_output_len from 20 to 35 to match trained model
- Export NamerPipeline and load_namer_pipeline from namer package
- Verify API works with local testing

Files changed (2) hide show
  1. config.json +4 -1
  2. namer/__init__.py +22 -0
config.json CHANGED
@@ -2,12 +2,15 @@
2
  "architectures": [
3
  "NamerModel"
4
  ],
 
 
 
5
  "d_model": 128,
6
  "dim_feedforward": 512,
7
  "dropout": 0.0,
8
  "dtype": "float32",
9
  "eos_token_id": 40,
10
- "max_output_len": 20,
11
  "model_type": "custom",
12
  "nhead": 4,
13
  "num_encoder_layers": 4,
 
2
  "architectures": [
3
  "NamerModel"
4
  ],
5
+ "auto_map": {
6
+ "AutoModel": "modeling_namer.NamerModel"
7
+ },
8
  "d_model": 128,
9
  "dim_feedforward": 512,
10
  "dropout": 0.0,
11
  "dtype": "float32",
12
  "eos_token_id": 40,
13
+ "max_output_len": 35,
14
  "model_type": "custom",
15
  "nhead": 4,
16
  "num_encoder_layers": 4,
namer/__init__.py CHANGED
@@ -15,6 +15,24 @@ from namer.utils import (
15
  read_double,
16
  )
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  __all__ = [
19
  "NamerTransformer",
20
  "load_namer_model",
@@ -28,3 +46,7 @@ __all__ = [
28
  "read_triplet",
29
  "read_double",
30
  ]
 
 
 
 
 
15
  read_double,
16
  )
17
 
18
+ # Import NamerPipeline from HuggingFace integration module
19
+ # This is available when the package is used with HuggingFace
20
+ import sys
21
+ from pathlib import Path
22
+
23
+ # Add parent directory to path to find modeling_namer.py
24
+ _parent_dir = Path(__file__).parent.parent
25
+ if str(_parent_dir) not in sys.path:
26
+ sys.path.insert(0, str(_parent_dir))
27
+
28
+ try:
29
+ from modeling_namer import NamerPipeline, load_namer_pipeline
30
+ _has_hf_integration = True
31
+ except ImportError:
32
+ _has_hf_integration = False
33
+ NamerPipeline = None # type: ignore
34
+ load_namer_pipeline = None # type: ignore
35
+
36
  __all__ = [
37
  "NamerTransformer",
38
  "load_namer_model",
 
46
  "read_triplet",
47
  "read_double",
48
  ]
49
+
50
+ # Add HF integration to exports if available
51
+ if _has_hf_integration:
52
+ __all__.extend(["NamerPipeline", "load_namer_pipeline"])