RehanKingggg commited on
Commit
93d5461
·
verified ·
1 Parent(s): 79f464f

Upload test_brello_ei_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. test_brello_ei_0.py +162 -0
test_brello_ei_0.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test Brello EI 0 - Emotional Intelligence Model
4
+ Created by Epic Systems | Engineered by Rehan Temkar
5
+
6
+ Test script to verify Brello EI 0 functionality and emotional intelligence capabilities.
7
+ """
8
+
9
+ import torch
10
+ from brello_ei_0 import BrelloEI0
11
+ import time
12
+
13
+ def test_model_loading():
14
+ """Test model loading functionality"""
15
+ print("🧪 Testing Model Loading...")
16
+
17
+ try:
18
+ model = BrelloEI0(
19
+ model_path="microsoft/DialoGPT-medium",
20
+ load_in_4bit=False
21
+ )
22
+ print("✅ Model loaded successfully!")
23
+ return model
24
+ except Exception as e:
25
+ print(f"❌ Model loading failed: {e}")
26
+ return None
27
+
28
+ def test_emotional_intelligence_responses(model):
29
+ """Test emotional intelligence response generation"""
30
+ print("\n🧪 Testing Emotional Intelligence Responses...")
31
+
32
+ test_cases = [
33
+ {
34
+ "input": "I'm feeling really anxious about my job interview tomorrow.",
35
+ "expected_keywords": ["understand", "anxious", "natural", "stress", "nervous"]
36
+ },
37
+ {
38
+ "input": "I just got promoted at work and I'm so excited!",
39
+ "expected_keywords": ["wonderful", "excited", "congratulations", "proud", "achievement"]
40
+ },
41
+ {
42
+ "input": "I'm feeling overwhelmed with all my responsibilities.",
43
+ "expected_keywords": ["understand", "overwhelmed", "responsibilities", "help", "manage"]
44
+ },
45
+ {
46
+ "input": "I'm really grateful for my friends and family.",
47
+ "expected_keywords": ["grateful", "beautiful", "appreciate", "wonderful", "support"]
48
+ },
49
+ {
50
+ "input": "I'm not sure what I want to do with my life.",
51
+ "expected_keywords": ["common", "natural", "uncertain", "figure", "challenge"]
52
+ }
53
+ ]
54
+
55
+ for i, test_case in enumerate(test_cases, 1):
56
+ print(f"\n{i}. Testing: '{test_case['input']}'")
57
+
58
+ try:
59
+ start_time = time.time()
60
+ response = model.generate_response(test_case['input'])
61
+ generation_time = time.time() - start_time
62
+
63
+ print(f"Response: {response}")
64
+ print(f"Generation time: {generation_time:.2f}s")
65
+
66
+ # Check for emotional intelligence indicators
67
+ response_lower = response.lower()
68
+ found_keywords = [keyword for keyword in test_case['expected_keywords']
69
+ if keyword in response_lower]
70
+
71
+ if found_keywords:
72
+ print(f"✅ Found emotional intelligence keywords: {found_keywords}")
73
+ else:
74
+ print(f"⚠️ Expected keywords not found: {test_case['expected_keywords']}")
75
+
76
+ except Exception as e:
77
+ print(f"❌ Response generation failed: {e}")
78
+
79
+ def test_chat_interface(model):
80
+ """Test chat interface functionality"""
81
+ print("\n🧪 Testing Chat Interface...")
82
+
83
+ try:
84
+ response = model.chat("Hello! How are you today?")
85
+ print(f"Chat response: {response}")
86
+ print("✅ Chat interface working!")
87
+ except Exception as e:
88
+ print(f"❌ Chat interface failed: {e}")
89
+
90
+ def test_generation_parameters(model):
91
+ """Test custom generation parameters"""
92
+ print("\n🧪 Testing Generation Parameters...")
93
+
94
+ try:
95
+ # Test with different parameters
96
+ response1 = model.generate_response(
97
+ "I'm feeling stressed.",
98
+ temperature=0.5,
99
+ max_new_tokens=100
100
+ )
101
+ print(f"Conservative response: {response1}")
102
+
103
+ response2 = model.generate_response(
104
+ "I'm feeling stressed.",
105
+ temperature=0.9,
106
+ max_new_tokens=200
107
+ )
108
+ print(f"Creative response: {response2}")
109
+
110
+ print("✅ Generation parameters working!")
111
+ except Exception as e:
112
+ print(f"❌ Generation parameters failed: {e}")
113
+
114
+ def test_memory_efficiency():
115
+ """Test memory efficiency"""
116
+ print("\n🧪 Testing Memory Efficiency...")
117
+
118
+ try:
119
+ # Test with standard loading
120
+ model_standard = BrelloEI0(
121
+ model_path="microsoft/DialoGPT-medium",
122
+ load_in_4bit=False
123
+ )
124
+
125
+ # Get model size info
126
+ if hasattr(model_4bit.model, 'get_memory_footprint'):
127
+ memory_footprint = model_4bit.model.get_memory_footprint()
128
+ print(f"Model memory footprint: {memory_footprint / 1024**3:.2f} GB")
129
+
130
+ print("✅ Memory efficiency test passed!")
131
+ return model_4bit
132
+ except Exception as e:
133
+ print(f"❌ Memory efficiency test failed: {e}")
134
+ return None
135
+
136
+ def main():
137
+ """Run all tests"""
138
+ print("🤖 Brello EI 0 - Test Suite")
139
+ print("Created by Epic Systems | Engineered by Rehan Temkar")
140
+ print("=" * 50)
141
+
142
+ # Test model loading
143
+ model = test_model_loading()
144
+
145
+ if model is None:
146
+ print("\n❌ Cannot proceed with tests - model loading failed")
147
+ return
148
+
149
+ # Run all tests
150
+ test_emotional_intelligence_responses(model)
151
+ test_chat_interface(model)
152
+ test_generation_parameters(model)
153
+ test_memory_efficiency()
154
+
155
+ print("\n🎉 All tests completed!")
156
+ print("\n💡 If you encounter any issues:")
157
+ print("1. Make sure you have accepted the model license on Hugging Face")
158
+ print("2. Check that all dependencies are installed: pip install -r requirements.txt")
159
+ print("3. Ensure you have sufficient GPU memory (at least 4GB recommended)")
160
+
161
+ if __name__ == "__main__":
162
+ main()