Update README.md
Browse files```python
model_path = "ehab215/egyptian_sentiment_analysis" # Replace with your saved model directory
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForSequenceClassification.from_pretrained(model_path)
# Ensure model is on GPU if available
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
# Step 2: Prepare test examples
examples = [
"والله الفرح امبارح كان تحفة، الناس كلها كانت مبسوطة والأكل كان جامد وكله تمام",
"مبروك يا معلم على الشغل الجديد! انت تستاهل كل خير والله، ربنا يوفقك",
"النهاردة الجو عادي، لا حر ولا برد، يعني معتدل",
"المحل اللي تحت البيت بيفتح من الصبح لحد بالليل، بيبيع كل حاجة",
"الزحمة في الشارع بقت مش طبيعية، مش عارف اروح شغلي في معاد، تعبت بجد",
"العربية خربانة من اسبوع والميكانيكي مش عارف يصلحها، ومصاريف كتير على الفاضي",
"الانترنت في البيت بطيء جداً وبيفصل كل شوية، اتصلت بالشركة مليون مرة ومفيش فايدة",
]
# Tokenize the examples
inputs = tokenizer(examples, truncation=True, padding=True, return_tensors="pt", max_length=256)
inputs = {key: val.to(device) for key, val in inputs.items()}
# Step 3: Make predictions
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
predictions = torch.argmax(logits, dim=-1).cpu().numpy()
# Step 4: Interpret results
label_map = {0: "negative", 1: "neutral", 2: "positive"}
predicted_labels = [label_map[p] for p in predictions]
# Display results
for text, label in zip(examples, predicted_labels):
print(f"Text: {text}")
print(f"Predicted Sentiment: {label}")
print("-" * 50)