humy65 commited on
Commit
109bbda
ยท
1 Parent(s): f8fab2a

Add training data function to debug tab

Browse files
Files changed (1) hide show
  1. app.py +181 -0
app.py CHANGED
@@ -97,6 +97,131 @@ def test_connection():
97
  except Exception as e:
98
  return f"โŒ Repository access failed: {str(e)}"
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  def get_training_data():
102
  """Display the training data used for the model"""
@@ -320,6 +445,62 @@ with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo:
320
  outputs=[result_output, confidence_output]
321
  )
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  if __name__ == "__main__":
324
  demo.launch(
325
  share=True,
 
97
  except Exception as e:
98
  return f"โŒ Repository access failed: {str(e)}"
99
 
100
+ def get_training_data():
101
+ """Display the training data used for the model"""
102
+ training_data = [
103
+ ("ืฉื›ื—ืชื™ ืืช ื”ืกื™ืกืžื” ืฉืœื™", "ืฉื›ื—ืช ืกื™ืกืžื”"),
104
+ ("ืื™ืš ืื ื™ ืžื‘ื˜ืœ ืืช ื”ืžื ื•ื™?", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
105
+ ("ืžื” ื”ืžื—ื™ืจ ืฉืœ ื”ืชื•ื›ื ื™ืช?", "ืฉืืœื” ื›ืœืœื™ืช"),
106
+ ("ื”ืืชืจ ืœื ืขื•ื‘ื“ ืœื™", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
107
+ ("ืื ื™ ืœื ืžืฆืœื™ื— ืœื”ืชื—ื‘ืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
108
+ ("ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื›ืชื•ื‘ืช ื”ืื™ืžื™ื™ืœ?", "ืฉืืœื” ื›ืœืœื™ืช"),
109
+ ("ืื ื™ ืจื•ืฆื” ืœืฉื“ืจื’ ืืช ื”ืชื•ื›ื ื™ืช ืฉืœื™", "ืฉืืœื” ื›ืœืœื™ืช"),
110
+ ("ื”ื—ืฉื‘ื•ืŸ ืฉืœื™ ื ื ืขืœ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
111
+ ("ืื ื™ ืœื ืžืงื‘ืœ ืžื™ื™ืœื™ื", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
112
+ ("ืื™ืš ืื ื™ ืจื•ืื” ืืช ื”ื—ืฉื‘ื•ื ื™ืช ืฉืœื™?", "ืฉืืœื” ื›ืœืœื™ืช"),
113
+ ("ืื ื™ ืจื•ืฆื” ืœื‘ื˜ืœ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
114
+ ("ืฉื›ื—ืชื™ ืืช ืคืจื˜ื™ ื”ื”ืชื—ื‘ืจื•ืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
115
+ ("ืื™ื‘ื“ืชื™ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
116
+ ("ืœื ื–ื•ื›ืจ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
117
+ ("ื”ืกื™ืกืžื” ืœื ืขื•ื‘ื“ืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
118
+ ("ืœื ืžืฆืœื™ื— ืœื”ื™ื›ื ืก ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
119
+ ("ืฆืจื™ืš ืœืืคืก ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
120
+ ("ื‘ืขื™ื” ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
121
+ ("ื”ืกื™ืกืžื” ืฉืœื™ ืœื ื ื›ื•ื ื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
122
+ ("ืฉื›ื—ืชื™ ืžื” ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
123
+ ("ืื™ืš ืื ื™ ืžืฉื—ื–ืจ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
124
+ ("ืจื•ืฆื” ืœืฉื ื•ืช ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
125
+ ("ื”ืกื™ืกืžื” ืœื ืžืชืงื‘ืœืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
126
+ ("ื‘ืขื™ื™ืช ื”ืชื—ื‘ืจื•ืช - ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
127
+ ("ืฆืจื™ืš ืขื–ืจื” ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
128
+ ("ืœื ื™ื•ื“ืข ืžื” ื”ืกื™ืกืžื” ืฉืœื™", "ืฉื›ื—ืช ืกื™ืกืžื”"),
129
+ ("ืจื•ืฆื” ืœื‘ื˜ืœ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
130
+ ("ืื™ืš ืžืคืกื™ืงื™ื ืืช ื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
131
+ ("ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ืชืฉืœื•ื", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
132
+ ("ืื™ืš ื™ื•ืฆืื™ื ืžื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
133
+ ("ื‘ืงืฉื” ืœื‘ื™ื˜ื•ืœ ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
134
+ ("ืœื ืจื•ืฆื” ื™ื•ืชืจ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
135
+ ("ืื™ืš ืžื‘ื˜ืœื™ื ืืช ื”ื—ืฉื‘ื•ืŸ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
136
+ ("ืจื•ืฆื” ืœืกื’ื•ืจ ืืช ื”ื—ืฉื‘ื•ืŸ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
137
+ ("ืขื–ืจื” ื‘ื‘ื™ื˜ื•ืœ ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
138
+ ("ื”ืœื™ืš ื‘ื™ื˜ื•ืœ ื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
139
+ ("ืžืขื•ื ื™ื™ืŸ ืœื‘ื˜ืœ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
140
+ ("ืื™ืš ืžืคืกื™ืงื™ื ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
141
+ ("ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ื”ืจืฉืžื”", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
142
+ ("ื‘ืงืฉื” ืœื”ืคืกืงืช ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
143
+ ("ืžื” ื›ื•ืœืœ ื”ืฉื™ืจื•ืช", "ืฉืืœื” ื›ืœืœื™ืช"),
144
+ ("ืื™ืœื• ืชื•ื›ื ื™ื•ืช ื™ืฉ ืœื›ื", "ืฉืืœื” ื›ืœืœื™ืช"),
145
+ ("ื›ืžื” ืขื•ืœื” ื”ื—ื‘ื™ืœื”", "ืฉืืœื” ื›ืœืœื™ืช"),
146
+ ("ืžื” ื”ื”ื‘ื“ืœ ื‘ื™ืŸ ื”ืชื•ื›ื ื™ื•ืช", "ืฉืืœื” ื›ืœืœื™ืช"),
147
+ ("ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื”ืคืจื˜ื™ื ืฉืœื™", "ืฉืืœื” ื›ืœืœื™ืช"),
148
+ ("ืื™ืš ืืคืฉืจ ืœืฉื“ืจื’", "ืฉืืœื” ื›ืœืœื™ืช"),
149
+ ("ืžื” ื”ืืคืฉืจื•ื™ื•ืช ืฉืœื›ื", "ืฉืืœื” ื›ืœืœื™ืช"),
150
+ ("ืื ื™ ืจื•ืฆื” ืœืขื“ื›ืŸ ืคืจื˜ื™ื", "ืฉืืœื” ื›ืœืœื™ืช"),
151
+ ("ืื™ืš ืจื•ืื™ื ืืช ื”ื”ื™ืกื˜ื•ืจื™ื”", "ืฉืืœื” ื›ืœืœื™ืช"),
152
+ ("ื”ืืคืœื™ืงืฆื™ื” ืงื•ืจืกืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
153
+ ("ื™ืฉ ื‘ืื’ ื‘ืืชืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
154
+ ("ื”ื“ืฃ ืœื ื ื˜ืขืŸ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
155
+ ("ืฉื’ื™ืื” ื‘ืžืขืจื›ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
156
+ ("ื”ื˜ื•ืขืŸ ืœื ืขื•ื‘ื“", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
157
+ ("ื‘ืขื™ื” ื˜ื›ื ื™ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
158
+ ("ื”ืžืขืจื›ืช ืœื ืžื’ื™ื‘ื”", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
159
+ ("ืฉื’ื™ืืช ื—ื™ื‘ื•ืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
160
+ ("ื”ื›ืคืชื•ืจ ืœื ืขื•ื‘ื“", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
161
+ ("ื”ืชืžื•ื ื•ืช ืœื ื ื˜ืขื ื•ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
162
+ ("ื”ื•ื•ื™ื“ืื• ืœื ืžืชื ื’ืŸ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
163
+ ("ืื™ื˜ื™ื•ืช ื‘ืืชืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช")
164
+ ]
165
+
166
+ # Count examples per category
167
+ category_counts = {}
168
+ for _, label in training_data:
169
+ category_counts[label] = category_counts.get(label, 0) + 1
170
+
171
+ result = f"""
172
+ ๐Ÿ“Š **Training Data Summary**
173
+ Total Examples: {len(training_data)}
174
+
175
+ ๐Ÿ“ˆ **Examples per Category:**
176
+ """
177
+
178
+ # Add category statistics
179
+ for category, count in sorted(category_counts.items()):
180
+ percentage = (count / len(training_data)) * 100
181
+ result += f"\nโ€ข {category}: {count} examples ({percentage:.1f}%)"
182
+
183
+ result += f"""
184
+
185
+ ๐Ÿ“ **Sample Training Examples:**
186
+
187
+ ๐Ÿ” **ืฉื›ื—ืช ืกื™ืกืžื” (Password Reset):**
188
+ โ€ข ืฉื›ื—ืชื™ ืืช ื”ืกื™ืกืžื” ืฉืœื™
189
+ โ€ข ืœื ื–ื•ื›ืจ ืืช ื”ืกื™ืกืžื”
190
+ โ€ข ื”ืกื™ืกืžื” ืœื ืขื•ื‘ื“ืช
191
+ โ€ข ืฆืจื™ืš ืœืืคืก ืืช ื”ืกื™ืกืžื”
192
+ โ€ข ืื™ืš ืื ื™ ืžืฉื—ื–ืจ ืืช ื”ืกื™ืกืžื”
193
+
194
+ โŒ **ื‘ื™ื˜ื•ืœ ืžื ื•ื™ (Cancel Subscription):**
195
+ โ€ข ืื™ืš ืื ื™ ืžื‘ื˜ืœ ืืช ื”ืžื ื•ื™?
196
+ โ€ข ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ืชืฉืœื•ื
197
+ โ€ข ืœื ืจื•ืฆื” ื™ื•ืชืจ ืืช ื”ืฉื™ืจื•ืช
198
+ โ€ข ืื™ืš ืžื‘ื˜ืœื™ื ืืช ื”ื—ืฉื‘ื•ืŸ
199
+ โ€ข ื‘ืงืฉื” ืœื‘ื™ื˜ื•ืœ ืžื ื•ื™
200
+
201
+ โ“ **ืฉืืœื” ื›ืœืœื™ืช (General Question):**
202
+ โ€ข ืžื” ื”ืžื—ื™ืจ ืฉืœ ื”ืชื•ื›ื ื™ืช?
203
+ โ€ข ื›ืžื” ืขื•ืœื” ื”ื—ื‘ื™ืœื”
204
+ โ€ข ืื™ืœื• ืชื•ื›ื ื™ื•ืช ื™ืฉ ืœื›ื
205
+ โ€ข ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื”ืคืจื˜ื™ื ืฉืœื™
206
+ โ€ข ืžื” ื›ื•ืœืœ ื”ืฉื™ืจื•ืช
207
+
208
+ ๐Ÿ”ง **ืชืžื™ื›ื” ื˜ื›ื ื™ืช (Technical Support):**
209
+ โ€ข ื”ืืชืจ ืœื ืขื•ื‘ื“ ืœื™
210
+ โ€ข ื”ืืคืœื™ืงืฆื™ื” ืงื•ืจืกืช
211
+ โ€ข ื™ืฉ ื‘ืื’ ื‘ืืชืจ
212
+ โ€ข ื”ื“ืฃ ืœื ื ื˜ืขืŸ
213
+ โ€ข ืฉื’ื™ืื” ื‘ืžืขืจื›ืช
214
+
215
+ ---
216
+ ๐Ÿ’ก **Model was trained with data augmentation techniques:**
217
+ โ€ข Synonym replacement
218
+ โ€ข Paraphrasing
219
+ โ€ข Context variation
220
+ โ€ข Original 12 examples โ†’ Enhanced to {len(training_data)} examples
221
+ """
222
+
223
+ return result
224
+
225
 
226
  def get_training_data():
227
  """Display the training data used for the model"""
 
445
  outputs=[result_output, confidence_output]
446
  )
447
 
448
+ if __name__ == "__main__":
449
+ demo.launch(
450
+ share=True,
451
+ server_name="0.0.0.0",
452
+ server_port=7860
453
+ )
454
+ test_btn = gr.Button("Test Model Loading")
455
+ debug_output = gr.Textbox(
456
+ label="Debug Output:",
457
+ lines=15,
458
+ interactive=False
459
+ )
460
+
461
+ test_btn.click(
462
+ lambda: test_model_loading()[1],
463
+ outputs=debug_output
464
+ )
465
+
466
+ conn_btn = gr.Button("Test Repository Connection")
467
+ conn_output = gr.Textbox(
468
+ label="Connection Test:",
469
+ lines=5,
470
+ interactive=False
471
+ )
472
+
473
+ conn_btn.click(
474
+ test_connection,
475
+ outputs=conn_output
476
+ )
477
+
478
+ with gr.Column():
479
+ data_btn = gr.Button("Show Training Data")
480
+ training_output = gr.Textbox(
481
+ label="Training Data:",
482
+ lines=20,
483
+ interactive=False
484
+ )
485
+
486
+ data_btn.click(
487
+ get_training_data,
488
+ outputs=training_output
489
+ )
490
+
491
+ # Connect classification
492
+ classify_btn.click(
493
+ classify_text,
494
+ inputs=[text_input],
495
+ outputs=[result_output, confidence_output]
496
+ )
497
+
498
+ text_input.submit(
499
+ classify_text,
500
+ inputs=[text_input],
501
+ outputs=[result_output, confidence_output]
502
+ )
503
+
504
  if __name__ == "__main__":
505
  demo.launch(
506
  share=True,