humy65's picture
Version 2.1 - Add version number and fix debug tab structure
6669042
"""
Hebrew Intent Classification Demo - Debug Version
"""
import gradio as gr
import sys
import traceback
def test_model_loading():
"""Test if model can be loaded"""
try:
print("๐Ÿ”„ Testing model loading...")
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_name = "humy65/hebrew-intent-classifier"
print(f"๐Ÿ“ก Attempting to load: {model_name}")
tokenizer = AutoTokenizer.from_pretrained(model_name)
print("โœ… Tokenizer loaded")
model = AutoModelForSequenceClassification.from_pretrained(model_name)
print("โœ… Model loaded")
print(f"๐Ÿ“‹ Labels: {model.config.id2label}")
return True, "Model loaded successfully!", model, tokenizer
except Exception as e:
error_msg = f"โŒ Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
print(error_msg)
return False, error_msg, None, None
def classify_text(text):
"""Classification function with lazy loading"""
if not text or not text.strip():
return "โš ๏ธ Please enter Hebrew text", {}
try:
# Try to load model on demand
success, message, model, tokenizer = test_model_loading()
if not success:
return f"Model Loading Failed:\n{message}", {}
# Perform classification
import torch
inputs = tokenizer(text, return_tensors="pt",
padding=True, truncation=True, max_length=128)
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probabilities = torch.softmax(logits, dim=-1)
# Get results
predicted_id = torch.argmax(logits, dim=-1).item()
predicted_label = model.config.id2label[predicted_id]
confidence = probabilities[0][predicted_id].item()
# Create confidence scores for all labels
all_scores = {}
for i, prob in enumerate(probabilities[0]):
intent_name = model.config.id2label[i]
all_scores[intent_name] = float(prob)
result = f"""
๐ŸŽฏ Predicted Intent: {predicted_label}
๐ŸŽฒ Confidence: {confidence:.1%}
๐Ÿ“Š All Predictions:
"""
# Sort and display
sorted_scores = sorted(
all_scores.items(), key=lambda x: x[1], reverse=True)
for intent, score in sorted_scores:
bar = "โ–ˆ" * max(1, int(score * 20))
result += f"\n{intent}: {score:.1%} {bar}"
return result, all_scores
except Exception as e:
error_msg = f"Classification Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
print(error_msg)
return error_msg, {}
def test_connection():
"""Test Hugging Face connection"""
try:
from huggingface_hub import HfApi
api = HfApi()
info = api.model_info("humy65/hebrew-intent-classifier")
return f"โœ… Model repository accessible\nModel ID: {info.modelId}\nLast Modified: {info.lastModified}"
except Exception as e:
return f"โŒ Repository access failed: {str(e)}"
def get_training_data():
"""Display the training data used for the model"""
training_data = [
("ืฉื›ื—ืชื™ ืืช ื”ืกื™ืกืžื” ืฉืœื™", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืื™ืš ืื ื™ ืžื‘ื˜ืœ ืืช ื”ืžื ื•ื™?", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืžื” ื”ืžื—ื™ืจ ืฉืœ ื”ืชื•ื›ื ื™ืช?", "ืฉืืœื” ื›ืœืœื™ืช"),
("ื”ืืชืจ ืœื ืขื•ื‘ื“ ืœื™", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื ื™ ืœื ืžืฆืœื™ื— ืœื”ืชื—ื‘ืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื›ืชื•ื‘ืช ื”ืื™ืžื™ื™ืœ?", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื ื™ ืจื•ืฆื” ืœืฉื“ืจื’ ืืช ื”ืชื•ื›ื ื™ืช ืฉืœื™", "ืฉืืœื” ื›ืœืœื™ืช"),
("ื”ื—ืฉื‘ื•ืŸ ืฉืœื™ ื ื ืขืœ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื ื™ ืœื ืžืงื‘ืœ ืžื™ื™ืœื™ื", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื™ืš ืื ื™ ืจื•ืื” ืืช ื”ื—ืฉื‘ื•ื ื™ืช ืฉืœื™?", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื ื™ ืจื•ืฆื” ืœื‘ื˜ืœ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืฉื›ื—ืชื™ ืืช ืคืจื˜ื™ ื”ื”ืชื—ื‘ืจื•ืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืื™ื‘ื“ืชื™ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืœื ื–ื•ื›ืจ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื”ืกื™ืกืžื” ืœื ืขื•ื‘ื“ืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืœื ืžืฆืœื™ื— ืœื”ื™ื›ื ืก ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืฆืจื™ืš ืœืืคืก ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื‘ืขื™ื” ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื”ืกื™ืกืžื” ืฉืœื™ ืœื ื ื›ื•ื ื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืฉื›ื—ืชื™ ืžื” ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืื™ืš ืื ื™ ืžืฉื—ื–ืจ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืจื•ืฆื” ืœืฉื ื•ืช ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื”ืกื™ืกืžื” ืœื ืžืชืงื‘ืœืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื‘ืขื™ื™ืช ื”ืชื—ื‘ืจื•ืช - ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืฆืจื™ืš ืขื–ืจื” ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืœื ื™ื•ื“ืข ืžื” ื”ืกื™ืกืžื” ืฉืœื™", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืจื•ืฆื” ืœื‘ื˜ืœ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืื™ืš ืžืคืกื™ืงื™ื ืืช ื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ืชืฉืœื•ื", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืื™ืš ื™ื•ืฆืื™ื ืžื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ื‘ืงืฉื” ืœื‘ื™ื˜ื•ืœ ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืœื ืจื•ืฆื” ื™ื•ืชืจ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืื™ืš ืžื‘ื˜ืœื™ื ืืช ื”ื—ืฉื‘ื•ืŸ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืจื•ืฆื” ืœืกื’ื•ืจ ืืช ื”ื—ืฉื‘ื•ืŸ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืขื–ืจื” ื‘ื‘ื™ื˜ื•ืœ ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ื”ืœื™ืš ื‘ื™ื˜ื•ืœ ื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืžืขื•ื ื™ื™ืŸ ืœื‘ื˜ืœ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืื™ืš ืžืคืกื™ืงื™ื ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ื”ืจืฉืžื”", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ื‘ืงืฉื” ืœื”ืคืกืงืช ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืžื” ื›ื•ืœืœ ื”ืฉื™ืจื•ืช", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื™ืœื• ืชื•ื›ื ื™ื•ืช ื™ืฉ ืœื›ื", "ืฉืืœื” ื›ืœืœื™ืช"),
("ื›ืžื” ืขื•ืœื” ื”ื—ื‘ื™ืœื”", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืžื” ื”ื”ื‘ื“ืœ ื‘ื™ืŸ ื”ืชื•ื›ื ื™ื•ืช", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื”ืคืจื˜ื™ื ืฉืœื™", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื™ืš ืืคืฉืจ ืœืฉื“ืจื’", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืžื” ื”ืืคืฉืจื•ื™ื•ืช ืฉืœื›ื", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื ื™ ืจื•ืฆื” ืœืขื“ื›ืŸ ืคืจื˜ื™ื", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื™ืš ืจื•ืื™ื ืืช ื”ื”ื™ืกื˜ื•ืจื™ื”", "ืฉืืœื” ื›ืœืœื™ืช"),
("ื”ืืคืœื™ืงืฆื™ื” ืงื•ืจืกืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื™ืฉ ื‘ืื’ ื‘ืืชืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ื“ืฃ ืœื ื ื˜ืขืŸ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืฉื’ื™ืื” ื‘ืžืขืจื›ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ื˜ื•ืขืŸ ืœื ืขื•ื‘ื“", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื‘ืขื™ื” ื˜ื›ื ื™ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ืžืขืจื›ืช ืœื ืžื’ื™ื‘ื”", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืฉื’ื™ืืช ื—ื™ื‘ื•ืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ื›ืคืชื•ืจ ืœื ืขื•ื‘ื“", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ืชืžื•ื ื•ืช ืœื ื ื˜ืขื ื•ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ื•ื•ื™ื“ืื• ืœื ืžืชื ื’ืŸ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื™ื˜ื™ื•ืช ื‘ืืชืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช")
]
# Count examples per category
category_counts = {}
for _, label in training_data:
category_counts[label] = category_counts.get(label, 0) + 1
result = f"""
๐Ÿ“Š **Training Data Summary**
Total Examples: {len(training_data)}
๐Ÿ“ˆ **Examples per Category:**
"""
# Add category statistics
for category, count in sorted(category_counts.items()):
percentage = (count / len(training_data)) * 100
result += f"\nโ€ข {category}: {count} examples ({percentage:.1f}%)"
result += f"""
๐Ÿ“ **Sample Training Examples:**
๐Ÿ” **ืฉื›ื—ืช ืกื™ืกืžื” (Password Reset):**
โ€ข ืฉื›ื—ืชื™ ืืช ื”ืกื™ืกืžื” ืฉืœื™
โ€ข ืœื ื–ื•ื›ืจ ืืช ื”ืกื™ืกืžื”
โ€ข ื”ืกื™ืกืžื” ืœื ืขื•ื‘ื“ืช
โ€ข ืฆืจื™ืš ืœืืคืก ืืช ื”ืกื™ืกืžื”
โ€ข ืื™ืš ืื ื™ ืžืฉื—ื–ืจ ืืช ื”ืกื™ืกืžื”
โŒ **ื‘ื™ื˜ื•ืœ ืžื ื•ื™ (Cancel Subscription):**
โ€ข ืื™ืš ืื ื™ ืžื‘ื˜ืœ ืืช ื”ืžื ื•ื™?
โ€ข ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ืชืฉืœื•ื
โ€ข ืœื ืจื•ืฆื” ื™ื•ืชืจ ืืช ื”ืฉื™ืจื•ืช
โ€ข ืื™ืš ืžื‘ื˜ืœื™ื ืืช ื”ื—ืฉื‘ื•ืŸ
โ€ข ื‘ืงืฉื” ืœื‘ื™ื˜ื•ืœ ืžื ื•ื™
โ“ **ืฉืืœื” ื›ืœืœื™ืช (General Question):**
โ€ข ืžื” ื”ืžื—ื™ืจ ืฉืœ ื”ืชื•ื›ื ื™ืช?
โ€ข ื›ืžื” ืขื•ืœื” ื”ื—ื‘ื™ืœื”
โ€ข ืื™ืœื• ืชื•ื›ื ื™ื•ืช ื™ืฉ ืœื›ื
โ€ข ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื”ืคืจื˜ื™ื ืฉืœื™
โ€ข ืžื” ื›ื•ืœืœ ื”ืฉื™ืจื•ืช
๐Ÿ”ง **ืชืžื™ื›ื” ื˜ื›ื ื™ืช (Technical Support):**
โ€ข ื”ืืชืจ ืœื ืขื•ื‘ื“ ืœื™
โ€ข ื”ืืคืœื™ืงืฆื™ื” ืงื•ืจืกืช
โ€ข ื™ืฉ ื‘ืื’ ื‘ืืชืจ
โ€ข ื”ื“ืฃ ืœื ื ื˜ืขืŸ
โ€ข ืฉื’ื™ืื” ื‘ืžืขืจื›ืช
---
๐Ÿ’ก **Model was trained with data augmentation techniques:**
โ€ข Synonym replacement
โ€ข Paraphrasing
โ€ข Context variation
โ€ข Original 12 examples โ†’ Enhanced to {len(training_data)} examples
"""
return result
def get_training_data():
"""Display the training data used for the model"""
training_data = [
("ืฉื›ื—ืชื™ ืืช ื”ืกื™ืกืžื” ืฉืœื™", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืื™ืš ืื ื™ ืžื‘ื˜ืœ ืืช ื”ืžื ื•ื™?", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืžื” ื”ืžื—ื™ืจ ืฉืœ ื”ืชื•ื›ื ื™ืช?", "ืฉืืœื” ื›ืœืœื™ืช"),
("ื”ืืชืจ ืœื ืขื•ื‘ื“ ืœื™", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื ื™ ืœื ืžืฆืœื™ื— ืœื”ืชื—ื‘ืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื›ืชื•ื‘ืช ื”ืื™ืžื™ื™ืœ?", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื ื™ ืจื•ืฆื” ืœืฉื“ืจื’ ืืช ื”ืชื•ื›ื ื™ืช ืฉืœื™", "ืฉืืœื” ื›ืœืœื™ืช"),
("ื”ื—ืฉื‘ื•ืŸ ืฉืœื™ ื ื ืขืœ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื ื™ ืœื ืžืงื‘ืœ ืžื™ื™ืœื™ื", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื™ืš ืื ื™ ืจื•ืื” ืืช ื”ื—ืฉื‘ื•ื ื™ืช ืฉืœื™?", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื ื™ ืจื•ืฆื” ืœื‘ื˜ืœ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืฉื›ื—ืชื™ ืืช ืคืจื˜ื™ ื”ื”ืชื—ื‘ืจื•ืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืื™ื‘ื“ืชื™ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืœื ื–ื•ื›ืจ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื”ืกื™ืกืžื” ืœื ืขื•ื‘ื“ืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืœื ืžืฆืœื™ื— ืœื”ื™ื›ื ืก ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืฆืจื™ืš ืœืืคืก ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื‘ืขื™ื” ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื”ืกื™ืกืžื” ืฉืœื™ ืœื ื ื›ื•ื ื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืฉื›ื—ืชื™ ืžื” ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืื™ืš ืื ื™ ืžืฉื—ื–ืจ ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืจื•ืฆื” ืœืฉื ื•ืช ืืช ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื”ืกื™ืกืžื” ืœื ืžืชืงื‘ืœืช", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ื‘ืขื™ื™ืช ื”ืชื—ื‘ืจื•ืช - ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืฆืจื™ืš ืขื–ืจื” ืขื ื”ืกื™ืกืžื”", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืœื ื™ื•ื“ืข ืžื” ื”ืกื™ืกืžื” ืฉืœื™", "ืฉื›ื—ืช ืกื™ืกืžื”"),
("ืจื•ืฆื” ืœื‘ื˜ืœ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืื™ืš ืžืคืกื™ืงื™ื ืืช ื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ืชืฉืœื•ื", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืื™ืš ื™ื•ืฆืื™ื ืžื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ื‘ืงืฉื” ืœื‘ื™ื˜ื•ืœ ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืœื ืจื•ืฆื” ื™ื•ืชืจ ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืื™ืš ืžื‘ื˜ืœื™ื ืืช ื”ื—ืฉื‘ื•ืŸ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืจื•ืฆื” ืœืกื’ื•ืจ ืืช ื”ื—ืฉื‘ื•ืŸ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืขื–ืจื” ื‘ื‘ื™ื˜ื•ืœ ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ื”ืœื™ืš ื‘ื™ื˜ื•ืœ ื”ืžื ื•ื™", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืžืขื•ื ื™ื™ืŸ ืœื‘ื˜ืœ", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืื™ืš ืžืคืกื™ืงื™ื ืืช ื”ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ื”ืจืฉืžื”", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ื‘ืงืฉื” ืœื”ืคืกืงืช ืฉื™ืจื•ืช", "ื‘ื™ื˜ื•ืœ ืžื ื•ื™"),
("ืžื” ื›ื•ืœืœ ื”ืฉื™ืจื•ืช", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื™ืœื• ืชื•ื›ื ื™ื•ืช ื™ืฉ ืœื›ื", "ืฉืืœื” ื›ืœืœื™ืช"),
("ื›ืžื” ืขื•ืœื” ื”ื—ื‘ื™ืœื”", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืžื” ื”ื”ื‘ื“ืœ ื‘ื™ืŸ ื”ืชื•ื›ื ื™ื•ืช", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื”ืคืจื˜ื™ื ืฉืœื™", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื™ืš ืืคืฉืจ ืœืฉื“ืจื’", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืžื” ื”ืืคืฉืจื•ื™ื•ืช ืฉืœื›ื", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื ื™ ืจื•ืฆื” ืœืขื“ื›ืŸ ืคืจื˜ื™ื", "ืฉืืœื” ื›ืœืœื™ืช"),
("ืื™ืš ืจื•ืื™ื ืืช ื”ื”ื™ืกื˜ื•ืจื™ื”", "ืฉืืœื” ื›ืœืœื™ืช"),
("ื”ืืคืœื™ืงืฆื™ื” ืงื•ืจืกืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื™ืฉ ื‘ืื’ ื‘ืืชืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ื“ืฃ ืœื ื ื˜ืขืŸ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืฉื’ื™ืื” ื‘ืžืขืจื›ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ื˜ื•ืขืŸ ืœื ืขื•ื‘ื“", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื‘ืขื™ื” ื˜ื›ื ื™ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ืžืขืจื›ืช ืœื ืžื’ื™ื‘ื”", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืฉื’ื™ืืช ื—ื™ื‘ื•ืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ื›ืคืชื•ืจ ืœื ืขื•ื‘ื“", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ืชืžื•ื ื•ืช ืœื ื ื˜ืขื ื•ืช", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ื”ื•ื•ื™ื“ืื• ืœื ืžืชื ื’ืŸ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช"),
("ืื™ื˜ื™ื•ืช ื‘ืืชืจ", "ืชืžื™ื›ื” ื˜ื›ื ื™ืช")
]
# Count examples per category
category_counts = {}
for _, label in training_data:
category_counts[label] = category_counts.get(label, 0) + 1
result = f"""
๐Ÿ“Š **Training Data Summary**
Total Examples: {len(training_data)}
๐Ÿ“ˆ **Examples per Category:**
"""
# Add category statistics
for category, count in sorted(category_counts.items()):
percentage = (count / len(training_data)) * 100
result += f"\nโ€ข {category}: {count} examples ({percentage:.1f}%)"
result += f"""
๐Ÿ“ **Sample Training Examples:**
๐Ÿ” **ืฉื›ื—ืช ืกื™ืกืžื” (Password Reset):**
โ€ข ืฉื›ื—ืชื™ ืืช ื”ืกื™ืกืžื” ืฉืœื™
โ€ข ืœื ื–ื•ื›ืจ ืืช ื”ืกื™ืกืžื”
โ€ข ื”ืกื™ืกืžื” ืœื ืขื•ื‘ื“ืช
โ€ข ืฆืจื™ืš ืœืืคืก ืืช ื”ืกื™ืกืžื”
โ€ข ืื™ืš ืื ื™ ืžืฉื—ื–ืจ ืืช ื”ืกื™ืกืžื”
โŒ **ื‘ื™ื˜ื•ืœ ืžื ื•ื™ (Cancel Subscription):**
โ€ข ืื™ืš ืื ื™ ืžื‘ื˜ืœ ืืช ื”ืžื ื•ื™?
โ€ข ืจื•ืฆื” ืœื”ืคืกื™ืง ืืช ื”ืชืฉืœื•ื
โ€ข ืœื ืจื•ืฆื” ื™ื•ืชืจ ืืช ื”ืฉื™ืจื•ืช
โ€ข ืื™ืš ืžื‘ื˜ืœื™ื ืืช ื”ื—ืฉื‘ื•ืŸ
โ€ข ื‘ืงืฉื” ืœื‘ื™ื˜ื•ืœ ืžื ื•ื™
โ“ **ืฉืืœื” ื›ืœืœื™ืช (General Question):**
โ€ข ืžื” ื”ืžื—ื™ืจ ืฉืœ ื”ืชื•ื›ื ื™ืช?
โ€ข ื›ืžื” ืขื•ืœื” ื”ื—ื‘ื™ืœื”
โ€ข ืื™ืœื• ืชื•ื›ื ื™ื•ืช ื™ืฉ ืœื›ื
โ€ข ืื™ืš ืื ื™ ืžืฉื ื” ืืช ื”ืคืจื˜ื™ื ืฉืœื™
โ€ข ืžื” ื›ื•ืœืœ ื”ืฉื™ืจื•ืช
๐Ÿ”ง **ืชืžื™ื›ื” ื˜ื›ื ื™ืช (Technical Support):**
โ€ข ื”ืืชืจ ืœื ืขื•ื‘ื“ ืœื™
โ€ข ื”ืืคืœื™ืงืฆื™ื” ืงื•ืจืกืช
โ€ข ื™ืฉ ื‘ืื’ ื‘ืืชืจ
โ€ข ื”ื“ืฃ ืœื ื ื˜ืขืŸ
โ€ข ืฉื’ื™ืื” ื‘ืžืขืจื›ืช
---
๐Ÿ’ก **Model was trained with data augmentation techniques:**
โ€ข Synonym replacement
โ€ข Paraphrasing
โ€ข Context variation
โ€ข Original 12 examples โ†’ Enhanced to {len(training_data)} examples
"""
return result
# Create interface
with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo:
gr.Markdown("# ๐Ÿ‡ฎ๐Ÿ‡ฑ Hebrew Intent Classification - Debug Version 2.1 ๐Ÿ“Š")
gr.Markdown("### ๐Ÿ”ข Version 2.1 - Training Data Display Added (Aug 12, 2025) โœ…")
with gr.Tab("Classification"):
with gr.Row():
with gr.Column():
text_input = gr.Textbox(
label="Hebrew Text:",
placeholder="ืฉื›ื—ืชื™ ืืช ื”ืกื™ืกืžื” ืฉืœื™",
lines=3
)
classify_btn = gr.Button("Classify", variant="primary")
# Quick examples
gr.Markdown("### Examples:")
examples = [
"ืฉื›ื—ืชื™ ืืช ื”ืกื™ืกืžื” ืฉืœื™",
"ืจื•ืฆื” ืœื‘ื˜ืœ ืืช ื”ืžื ื•ื™",
"ื›ืžื” ืขื•ืœื” ื”ื—ื‘ื™ืœื”",
"ื”ืืชืจ ืœื ืขื•ื‘ื“"
]
for example in examples:
gr.Button(example, size="sm").click(
lambda x=example: x, outputs=text_input
)
with gr.Column():
result_output = gr.Textbox(
label="Result:",
lines=12,
interactive=False
)
confidence_output = gr.Label(
label="Confidence Scores",
num_top_classes=4
)
with gr.Tab("Debug"):
gr.Markdown("### Debug Information")
with gr.Row():
with gr.Column():
test_btn = gr.Button("Test Model Loading")
debug_output = gr.Textbox(
label="Debug Output:",
lines=15,
interactive=False
)
test_btn.click(
lambda: test_model_loading()[1],
outputs=debug_output
)
conn_btn = gr.Button("Test Repository Connection")
conn_output = gr.Textbox(
label="Connection Test:",
lines=5,
interactive=False
)
conn_btn.click(
test_connection,
outputs=conn_output
)
with gr.Column():
data_btn = gr.Button("Show Training Data")
training_output = gr.Textbox(
label="Training Data:",
lines=20,
interactive=False
)
data_btn.click(
get_training_data,
outputs=training_output
)
# Connect classification
classify_btn.click(
classify_text,
inputs=[text_input],
outputs=[result_output, confidence_output]
)
text_input.submit(
classify_text,
inputs=[text_input],
outputs=[result_output, confidence_output]
)
if __name__ == "__main__":
demo.launch(
share=True,
server_name="0.0.0.0",
server_port=7860
)
# Connect classification
classify_btn.click(
classify_text,
inputs=[text_input],
outputs=[result_output, confidence_output]
)
text_input.submit(
classify_text,
inputs=[text_input],
outputs=[result_output, confidence_output]
)
if __name__ == "__main__":
demo.launch(
share=True,
server_name="0.0.0.0",
server_port=7860
)