ehab215/egyptian_sentiment_analysis_dataset
Viewer • Updated • 5.82k • 12
How to use ehab215/egyptian_sentiment_analysis with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="ehab215/egyptian_sentiment_analysis") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("ehab215/egyptian_sentiment_analysis")
model = AutoModelForSequenceClassification.from_pretrained("ehab215/egyptian_sentiment_analysis")This model is a fine-tuned version of CAMeL-Lab/bert-base-arabic-camelbert-da-sentiment on an unknown dataset. It achieves the following results on the evaluation set:
More information needed
More information needed
More information needed
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss | Accuracy | F1 |
|---|---|---|---|---|---|
| No log | 1.0 | 291 | 0.1533 | 0.9467 | 0.9466 |
| 0.2224 | 2.0 | 582 | 0.2004 | 0.9467 | 0.9469 |
| 0.2224 | 3.0 | 873 | 0.2178 | 0.9553 | 0.9553 |
| 0.0393 | 4.0 | 1164 | 0.2400 | 0.9553 | 0.9552 |
| 0.0393 | 5.0 | 1455 | 0.2481 | 0.9519 | 0.9520 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_path = "ehab215/egyptian_sentiment_analysis"
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 = [
add any examples you would
]
# 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)