Spaces:
Sleeping
Sleeping
Add training data display to debug tab
Browse files
app.py
CHANGED
|
@@ -6,82 +6,87 @@ import gradio as gr
|
|
| 6 |
import sys
|
| 7 |
import traceback
|
| 8 |
|
|
|
|
| 9 |
def test_model_loading():
|
| 10 |
"""Test if model can be loaded"""
|
| 11 |
try:
|
| 12 |
print("๐ Testing model loading...")
|
| 13 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 14 |
-
|
| 15 |
model_name = "humy65/hebrew-intent-classifier"
|
| 16 |
print(f"๐ก Attempting to load: {model_name}")
|
| 17 |
-
|
| 18 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 19 |
print("โ
Tokenizer loaded")
|
| 20 |
-
|
| 21 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 22 |
print("โ
Model loaded")
|
| 23 |
-
|
| 24 |
print(f"๐ Labels: {model.config.id2label}")
|
| 25 |
return True, "Model loaded successfully!", model, tokenizer
|
| 26 |
-
|
| 27 |
except Exception as e:
|
| 28 |
error_msg = f"โ Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 29 |
print(error_msg)
|
| 30 |
return False, error_msg, None, None
|
| 31 |
|
|
|
|
| 32 |
def classify_text(text):
|
| 33 |
"""Classification function with lazy loading"""
|
| 34 |
if not text or not text.strip():
|
| 35 |
return "โ ๏ธ Please enter Hebrew text", {}
|
| 36 |
-
|
| 37 |
try:
|
| 38 |
# Try to load model on demand
|
| 39 |
success, message, model, tokenizer = test_model_loading()
|
| 40 |
-
|
| 41 |
if not success:
|
| 42 |
return f"Model Loading Failed:\n{message}", {}
|
| 43 |
-
|
| 44 |
# Perform classification
|
| 45 |
import torch
|
| 46 |
-
|
| 47 |
-
inputs = tokenizer(text, return_tensors="pt",
|
| 48 |
-
|
|
|
|
| 49 |
with torch.no_grad():
|
| 50 |
outputs = model(**inputs)
|
| 51 |
logits = outputs.logits
|
| 52 |
probabilities = torch.softmax(logits, dim=-1)
|
| 53 |
-
|
| 54 |
# Get results
|
| 55 |
predicted_id = torch.argmax(logits, dim=-1).item()
|
| 56 |
predicted_label = model.config.id2label[predicted_id]
|
| 57 |
confidence = probabilities[0][predicted_id].item()
|
| 58 |
-
|
| 59 |
# Create confidence scores for all labels
|
| 60 |
all_scores = {}
|
| 61 |
for i, prob in enumerate(probabilities[0]):
|
| 62 |
intent_name = model.config.id2label[i]
|
| 63 |
all_scores[intent_name] = float(prob)
|
| 64 |
-
|
| 65 |
result = f"""
|
| 66 |
๐ฏ Predicted Intent: {predicted_label}
|
| 67 |
๐ฒ Confidence: {confidence:.1%}
|
| 68 |
|
| 69 |
๐ All Predictions:
|
| 70 |
"""
|
| 71 |
-
|
| 72 |
# Sort and display
|
| 73 |
-
sorted_scores = sorted(
|
|
|
|
| 74 |
for intent, score in sorted_scores:
|
| 75 |
bar = "โ" * max(1, int(score * 20))
|
| 76 |
result += f"\n{intent}: {score:.1%} {bar}"
|
| 77 |
-
|
| 78 |
return result, all_scores
|
| 79 |
-
|
| 80 |
except Exception as e:
|
| 81 |
error_msg = f"Classification Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 82 |
print(error_msg)
|
| 83 |
return error_msg, {}
|
| 84 |
|
|
|
|
| 85 |
def test_connection():
|
| 86 |
"""Test Hugging Face connection"""
|
| 87 |
try:
|
|
@@ -92,11 +97,138 @@ def test_connection():
|
|
| 92 |
except Exception as e:
|
| 93 |
return f"โ Repository access failed: {str(e)}"
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
# Create interface
|
| 96 |
with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo:
|
| 97 |
-
|
| 98 |
gr.Markdown("# ๐ฎ๐ฑ Hebrew Intent Classification - Debug Version")
|
| 99 |
-
|
| 100 |
with gr.Tab("Classification"):
|
| 101 |
with gr.Row():
|
| 102 |
with gr.Column():
|
|
@@ -106,67 +238,82 @@ with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo:
|
|
| 106 |
lines=3
|
| 107 |
)
|
| 108 |
classify_btn = gr.Button("Classify", variant="primary")
|
| 109 |
-
|
| 110 |
# Quick examples
|
| 111 |
gr.Markdown("### Examples:")
|
| 112 |
examples = [
|
| 113 |
"ืฉ๏ฟฝ๏ฟฝืืชื ืืช ืืกืืกืื ืฉืื",
|
| 114 |
-
"ืจืืฆื ืืืื ืืช ืืื ืื",
|
| 115 |
"ืืื ืขืืื ืืืืืื",
|
| 116 |
"ืืืชืจ ืื ืขืืื"
|
| 117 |
]
|
| 118 |
-
|
| 119 |
for example in examples:
|
| 120 |
gr.Button(example, size="sm").click(
|
| 121 |
lambda x=example: x, outputs=text_input
|
| 122 |
)
|
| 123 |
-
|
| 124 |
with gr.Column():
|
| 125 |
result_output = gr.Textbox(
|
| 126 |
label="Result:",
|
| 127 |
lines=12,
|
| 128 |
interactive=False
|
| 129 |
)
|
| 130 |
-
|
| 131 |
confidence_output = gr.Label(
|
| 132 |
label="Confidence Scores",
|
| 133 |
num_top_classes=4
|
| 134 |
)
|
| 135 |
-
|
| 136 |
with gr.Tab("Debug"):
|
| 137 |
gr.Markdown("### Debug Information")
|
| 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 |
# Connect classification
|
| 164 |
classify_btn.click(
|
| 165 |
classify_text,
|
| 166 |
inputs=[text_input],
|
| 167 |
outputs=[result_output, confidence_output]
|
| 168 |
)
|
| 169 |
-
|
| 170 |
text_input.submit(
|
| 171 |
classify_text,
|
| 172 |
inputs=[text_input],
|
|
|
|
| 6 |
import sys
|
| 7 |
import traceback
|
| 8 |
|
| 9 |
+
|
| 10 |
def test_model_loading():
|
| 11 |
"""Test if model can be loaded"""
|
| 12 |
try:
|
| 13 |
print("๐ Testing model loading...")
|
| 14 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 15 |
+
|
| 16 |
model_name = "humy65/hebrew-intent-classifier"
|
| 17 |
print(f"๐ก Attempting to load: {model_name}")
|
| 18 |
+
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 20 |
print("โ
Tokenizer loaded")
|
| 21 |
+
|
| 22 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 23 |
print("โ
Model loaded")
|
| 24 |
+
|
| 25 |
print(f"๐ Labels: {model.config.id2label}")
|
| 26 |
return True, "Model loaded successfully!", model, tokenizer
|
| 27 |
+
|
| 28 |
except Exception as e:
|
| 29 |
error_msg = f"โ Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 30 |
print(error_msg)
|
| 31 |
return False, error_msg, None, None
|
| 32 |
|
| 33 |
+
|
| 34 |
def classify_text(text):
|
| 35 |
"""Classification function with lazy loading"""
|
| 36 |
if not text or not text.strip():
|
| 37 |
return "โ ๏ธ Please enter Hebrew text", {}
|
| 38 |
+
|
| 39 |
try:
|
| 40 |
# Try to load model on demand
|
| 41 |
success, message, model, tokenizer = test_model_loading()
|
| 42 |
+
|
| 43 |
if not success:
|
| 44 |
return f"Model Loading Failed:\n{message}", {}
|
| 45 |
+
|
| 46 |
# Perform classification
|
| 47 |
import torch
|
| 48 |
+
|
| 49 |
+
inputs = tokenizer(text, return_tensors="pt",
|
| 50 |
+
padding=True, truncation=True, max_length=128)
|
| 51 |
+
|
| 52 |
with torch.no_grad():
|
| 53 |
outputs = model(**inputs)
|
| 54 |
logits = outputs.logits
|
| 55 |
probabilities = torch.softmax(logits, dim=-1)
|
| 56 |
+
|
| 57 |
# Get results
|
| 58 |
predicted_id = torch.argmax(logits, dim=-1).item()
|
| 59 |
predicted_label = model.config.id2label[predicted_id]
|
| 60 |
confidence = probabilities[0][predicted_id].item()
|
| 61 |
+
|
| 62 |
# Create confidence scores for all labels
|
| 63 |
all_scores = {}
|
| 64 |
for i, prob in enumerate(probabilities[0]):
|
| 65 |
intent_name = model.config.id2label[i]
|
| 66 |
all_scores[intent_name] = float(prob)
|
| 67 |
+
|
| 68 |
result = f"""
|
| 69 |
๐ฏ Predicted Intent: {predicted_label}
|
| 70 |
๐ฒ Confidence: {confidence:.1%}
|
| 71 |
|
| 72 |
๐ All Predictions:
|
| 73 |
"""
|
| 74 |
+
|
| 75 |
# Sort and display
|
| 76 |
+
sorted_scores = sorted(
|
| 77 |
+
all_scores.items(), key=lambda x: x[1], reverse=True)
|
| 78 |
for intent, score in sorted_scores:
|
| 79 |
bar = "โ" * max(1, int(score * 20))
|
| 80 |
result += f"\n{intent}: {score:.1%} {bar}"
|
| 81 |
+
|
| 82 |
return result, all_scores
|
| 83 |
+
|
| 84 |
except Exception as e:
|
| 85 |
error_msg = f"Classification Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 86 |
print(error_msg)
|
| 87 |
return error_msg, {}
|
| 88 |
|
| 89 |
+
|
| 90 |
def test_connection():
|
| 91 |
"""Test Hugging Face connection"""
|
| 92 |
try:
|
|
|
|
| 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"""
|
| 103 |
+
training_data = [
|
| 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 |
+
|
| 167 |
+
# Count examples per category
|
| 168 |
+
category_counts = {}
|
| 169 |
+
for _, label in training_data:
|
| 170 |
+
category_counts[label] = category_counts.get(label, 0) + 1
|
| 171 |
+
|
| 172 |
+
result = f"""
|
| 173 |
+
๐ **Training Data Summary**
|
| 174 |
+
Total Examples: {len(training_data)}
|
| 175 |
+
|
| 176 |
+
๐ **Examples per Category:**
|
| 177 |
+
"""
|
| 178 |
+
|
| 179 |
+
# Add category statistics
|
| 180 |
+
for category, count in sorted(category_counts.items()):
|
| 181 |
+
percentage = (count / len(training_data)) * 100
|
| 182 |
+
result += f"\nโข {category}: {count} examples ({percentage:.1f}%)"
|
| 183 |
+
|
| 184 |
+
result += f"""
|
| 185 |
+
|
| 186 |
+
๐ **Sample Training Examples:**
|
| 187 |
+
|
| 188 |
+
๐ **ืฉืืืช ืกืืกืื (Password Reset):**
|
| 189 |
+
โข ืฉืืืชื ืืช ืืกืืกืื ืฉืื
|
| 190 |
+
โข ืื ืืืืจ ืืช ืืกืืกืื
|
| 191 |
+
โข ืืกืืกืื ืื ืขืืืืช
|
| 192 |
+
โข ืฆืจืื ืืืคืก ืืช ืืกืืกืื
|
| 193 |
+
โข ืืื ืื ื ืืฉืืืจ ืืช ืืกืืกืื
|
| 194 |
+
|
| 195 |
+
โ **ืืืืื ืื ืื (Cancel Subscription):**
|
| 196 |
+
โข ืืื ืื ื ืืืื ืืช ืืื ืื?
|
| 197 |
+
โข ืจืืฆื ืืืคืกืืง ืืช ืืชืฉืืื
|
| 198 |
+
โข ืื ืจืืฆื ืืืชืจ ืืช ืืฉืืจืืช
|
| 199 |
+
โข ืืื ืืืืืื ืืช ืืืฉืืื
|
| 200 |
+
โข ืืงืฉื ืืืืืื ืื ืื
|
| 201 |
+
|
| 202 |
+
โ **ืฉืืื ืืืืืช (General Question):**
|
| 203 |
+
โข ืื ืืืืืจ ืฉื ืืชืืื ืืช?
|
| 204 |
+
โข ืืื ืขืืื ืืืืืื
|
| 205 |
+
โข ืืืื ืชืืื ืืืช ืืฉ ืืื
|
| 206 |
+
โข ืืื ืื ื ืืฉื ื ืืช ืืคืจืืื ืฉืื
|
| 207 |
+
โข ืื ืืืื ืืฉืืจืืช
|
| 208 |
+
|
| 209 |
+
๐ง **ืชืืืื ืืื ืืช (Technical Support):**
|
| 210 |
+
โข ืืืชืจ ืื ืขืืื ืื
|
| 211 |
+
โข ืืืคืืืงืฆืื ืงืืจืกืช
|
| 212 |
+
โข ืืฉ ืืื ืืืชืจ
|
| 213 |
+
โข ืืืฃ ืื ื ืืขื
|
| 214 |
+
โข ืฉืืืื ืืืขืจืืช
|
| 215 |
+
|
| 216 |
+
---
|
| 217 |
+
๐ก **Model was trained with data augmentation techniques:**
|
| 218 |
+
โข Synonym replacement
|
| 219 |
+
โข Paraphrasing
|
| 220 |
+
โข Context variation
|
| 221 |
+
โข Original 12 examples โ Enhanced to {len(training_data)} examples
|
| 222 |
+
"""
|
| 223 |
+
|
| 224 |
+
return result
|
| 225 |
+
|
| 226 |
+
|
| 227 |
# Create interface
|
| 228 |
with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo:
|
| 229 |
+
|
| 230 |
gr.Markdown("# ๐ฎ๐ฑ Hebrew Intent Classification - Debug Version")
|
| 231 |
+
|
| 232 |
with gr.Tab("Classification"):
|
| 233 |
with gr.Row():
|
| 234 |
with gr.Column():
|
|
|
|
| 238 |
lines=3
|
| 239 |
)
|
| 240 |
classify_btn = gr.Button("Classify", variant="primary")
|
| 241 |
+
|
| 242 |
# Quick examples
|
| 243 |
gr.Markdown("### Examples:")
|
| 244 |
examples = [
|
| 245 |
"ืฉ๏ฟฝ๏ฟฝืืชื ืืช ืืกืืกืื ืฉืื",
|
| 246 |
+
"ืจืืฆื ืืืื ืืช ืืื ืื",
|
| 247 |
"ืืื ืขืืื ืืืืืื",
|
| 248 |
"ืืืชืจ ืื ืขืืื"
|
| 249 |
]
|
| 250 |
+
|
| 251 |
for example in examples:
|
| 252 |
gr.Button(example, size="sm").click(
|
| 253 |
lambda x=example: x, outputs=text_input
|
| 254 |
)
|
| 255 |
+
|
| 256 |
with gr.Column():
|
| 257 |
result_output = gr.Textbox(
|
| 258 |
label="Result:",
|
| 259 |
lines=12,
|
| 260 |
interactive=False
|
| 261 |
)
|
| 262 |
+
|
| 263 |
confidence_output = gr.Label(
|
| 264 |
label="Confidence Scores",
|
| 265 |
num_top_classes=4
|
| 266 |
)
|
| 267 |
+
|
| 268 |
with gr.Tab("Debug"):
|
| 269 |
gr.Markdown("### Debug Information")
|
| 270 |
+
|
| 271 |
+
with gr.Row():
|
| 272 |
+
with gr.Column():
|
| 273 |
+
test_btn = gr.Button("Test Model Loading")
|
| 274 |
+
debug_output = gr.Textbox(
|
| 275 |
+
label="Debug Output:",
|
| 276 |
+
lines=15,
|
| 277 |
+
interactive=False
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
test_btn.click(
|
| 281 |
+
lambda: test_model_loading()[1],
|
| 282 |
+
outputs=debug_output
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
conn_btn = gr.Button("Test Repository Connection")
|
| 286 |
+
conn_output = gr.Textbox(
|
| 287 |
+
label="Connection Test:",
|
| 288 |
+
lines=5,
|
| 289 |
+
interactive=False
|
| 290 |
+
)
|
| 291 |
+
|
| 292 |
+
conn_btn.click(
|
| 293 |
+
test_connection,
|
| 294 |
+
outputs=conn_output
|
| 295 |
+
)
|
| 296 |
+
|
| 297 |
+
with gr.Column():
|
| 298 |
+
data_btn = gr.Button("Show Training Data")
|
| 299 |
+
training_output = gr.Textbox(
|
| 300 |
+
label="Training Data:",
|
| 301 |
+
lines=20,
|
| 302 |
+
interactive=False
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
data_btn.click(
|
| 306 |
+
get_training_data,
|
| 307 |
+
outputs=training_output
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
# Connect classification
|
| 311 |
classify_btn.click(
|
| 312 |
classify_text,
|
| 313 |
inputs=[text_input],
|
| 314 |
outputs=[result_output, confidence_output]
|
| 315 |
)
|
| 316 |
+
|
| 317 |
text_input.submit(
|
| 318 |
classify_text,
|
| 319 |
inputs=[text_input],
|