YosefAyele commited on
Commit
a10ba15
Β·
1 Parent(s): 8f83228

Fix tokenizer compatibility issues

Browse files
Files changed (2) hide show
  1. app.py +39 -16
  2. requirements.txt +3 -3
app.py CHANGED
@@ -9,22 +9,45 @@ def load_model():
9
  """Load the intent classification model"""
10
  global _classifier
11
  if _classifier is None:
12
- try:
13
- # Try loading with trust_remote_code for better compatibility
14
- _classifier = pipeline(
15
- "text-classification",
16
- model="YosefA/adfluence-intent-model",
17
- return_all_scores=True,
18
- trust_remote_code=True
19
- )
20
- print("Model loaded successfully!")
21
- except Exception as e:
22
- print(f"Error loading model YosefA/adfluence-intent-model: {e}")
23
- print("Please verify that:")
24
- print("1. The model name is correct")
25
- print("2. The model exists and is public")
26
- print("3. You have internet connection")
27
- return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  return _classifier
29
 
30
  def classify_intent(comment):
 
9
  """Load the intent classification model"""
10
  global _classifier
11
  if _classifier is None:
12
+ model_name = "YosefA/adfluence-intent-model"
13
+
14
+ # Try multiple approaches to load the model
15
+ loading_strategies = [
16
+ {
17
+ "name": "Standard loading with trust_remote_code",
18
+ "kwargs": {"trust_remote_code": True, "return_all_scores": True}
19
+ },
20
+ {
21
+ "name": "Loading with revision='main'",
22
+ "kwargs": {"revision": "main", "return_all_scores": True}
23
+ },
24
+ {
25
+ "name": "Loading with use_fast=False",
26
+ "kwargs": {"use_fast": False, "return_all_scores": True}
27
+ },
28
+ {
29
+ "name": "Loading with legacy tokenizer",
30
+ "kwargs": {"use_fast": False, "trust_remote_code": True, "return_all_scores": True}
31
+ }
32
+ ]
33
+
34
+ for strategy in loading_strategies:
35
+ try:
36
+ print(f"Trying: {strategy['name']}")
37
+ _classifier = pipeline(
38
+ "text-classification",
39
+ model=model_name,
40
+ **strategy['kwargs']
41
+ )
42
+ print(f"βœ… Model loaded successfully using: {strategy['name']}")
43
+ return _classifier
44
+
45
+ except Exception as e:
46
+ print(f"❌ Failed with {strategy['name']}: {e}")
47
+ continue
48
+
49
+ print("❌ All loading strategies failed")
50
+ return None
51
  return _classifier
52
 
53
  def classify_intent(comment):
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  gradio==4.44.0
2
- transformers==4.36.0
3
  torch==2.1.0
4
- tokenizers==0.15.0
5
- huggingface_hub==0.19.4
6
  numpy<2.0.0
7
  requests==2.31.0
 
1
  gradio==4.44.0
2
+ transformers==4.45.0
3
  torch==2.1.0
4
+ tokenizers==0.20.0
5
+ huggingface_hub==0.25.0
6
  numpy<2.0.0
7
  requests==2.31.0