File size: 2,575 Bytes
8f83228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
"""
Test script to verify if the Hugging Face model exists and can be loaded.
Run this to debug model loading issues.
"""

from transformers import pipeline
import requests

def test_model_exists(model_name):
    """Test if model exists on Hugging Face"""
    url = f"https://huggingface.co/api/models/{model_name}"
    try:
        response = requests.get(url)
        if response.status_code == 200:
            print(f"βœ… Model {model_name} exists on Hugging Face")
            model_info = response.json()
            print(f"   Pipeline tag: {model_info.get('pipeline_tag', 'Unknown')}")
            print(f"   Downloads: {model_info.get('downloads', 'Unknown')}")
            return True
        elif response.status_code == 404:
            print(f"❌ Model {model_name} not found on Hugging Face")
            return False
        else:
            print(f"⚠️  Unexpected response: {response.status_code}")
            return False
    except Exception as e:
        print(f"❌ Error checking model: {e}")
        return False

def test_model_loading(model_name):
    """Test loading the model with transformers"""
    try:
        print(f"\nπŸ”„ Attempting to load model: {model_name}")
        classifier = pipeline(
            "text-classification",
            model=model_name,
            return_all_scores=True,
            trust_remote_code=True
        )
        print("βœ… Model loaded successfully!")
        
        # Test classification
        test_text = "This product looks amazing!"
        result = classifier(test_text)
        print(f"βœ… Test classification successful:")
        print(f"   Input: '{test_text}'")
        print(f"   Output: {result}")
        
        return True
        
    except Exception as e:
        print(f"❌ Error loading model: {e}")
        return False

def main():
    model_name = "YosefA/adfluence-intent-model"
    
    print(f"πŸ§ͺ Testing model: {model_name}")
    print("=" * 50)
    
    # Test 1: Check if model exists
    exists = test_model_exists(model_name)
    
    if exists:
        # Test 2: Try loading the model
        test_model_loading(model_name)
    else:
        print("\nπŸ’‘ Suggestions:")
        print("1. Check if the model name is spelled correctly")
        print("2. Verify the model is public (not private)")
        print("3. Check if you need to be logged in to access it")
        print("4. Try searching for similar models:")
        print("   https://huggingface.co/models?search=intent+classification")

if __name__ == "__main__":
    main()