Sengil/Turkish-ABSA-Wsynthetic
Viewer β’ Updated β’ 22.1k β’ 6 β’ 3
How to use Sengil/Turkish-ABSA-BiLSTM-Word2Vec with Keras:
# Available backend options are: "jax", "torch", "tensorflow".
import os
os.environ["KERAS_BACKEND"] = "jax"
import keras
model = keras.saving.load_model("hf://Sengil/Turkish-ABSA-BiLSTM-Word2Vec")
This model performs aspect-based sentiment analysis (ABSA) on Turkish sentences. Given a sentence and a specific aspect, it predicts the sentiment polarity (Negative, Neutral, Positive) associated with that aspect.
"Sentence [ASP] Aspect"The model achieved the following performance on the test set:
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Negative | 0.89 | 0.91 | 0.90 | 896 |
| Neutral | 0.70 | 0.64 | 0.67 | 140 |
| Positive | 0.92 | 0.92 | 0.92 | 1178 |
| Overall | 0.90 | 2214 |
Download model from HF
from huggingface_hub import hf_hub_download
import pickle
from tensorflow.keras.models import load_model
model_path = hf_hub_download(repo_id="Sengil/Turkish-ABSA-BiLSTM-Word2Vec", filename="absa_bilstm_model.keras")
tokenizer_path = hf_hub_download(repo_id="Sengil/Turkish-ABSA-BiLSTM-Word2Vec", filename="tokenizer.pkl")
# load model
model = load_model(model_path)
# load tokenizer
with open(tokenizer_path, "rb") as f:
tokenizer = pickle.load(f)
Input preprocessing
import re
import nltk
nltk.download('punkt')
def preprocess_turkish(text):
text = text.lower()
text = re.sub(r"http\S+|www\S+|https\S+", "<url>", text)
text = re.sub(r"@\w+", "<user>", text)
text = re.sub(r"[^a-zA-Z0-9Γ§ΔΔ±ΓΆΕΓΌΓΔΔ°ΓΕΓ\s]", " ", text)
text = re.sub(r"(.)\1{2,}", r"\1\1", text)
text = re.sub(r"\s+", " ", text).strip()
return text
Predict the input
import numpy as np
from tensorflow.keras.preprocessing.sequence import pad_sequences
def predict_sentiment(sentence, aspect, max_len=84):
input_text = sentence + " [ASP] " + aspect
cleaned = preprocess_turkish(input_text)
tokenized = tokenizer.texts_to_sequences([cleaned])
padded = pad_sequences(tokenized, maxlen=max_len, padding='post')
pred = model.predict(padded)
label = np.argmax(pred)
labels = {0: "Negatif", 1: "NΓΆtr", 2: "Pozitif"}
return labels[label]
run
sentence = "Manzara sahane evet ama servis rezalet."
aspect = "manzara"
predict = predict_sentiment(sentence, aspect)
print("predict:", predict)
Embedding: Word2Vec (dimension: 100)
Model Architecture:
Training Parameters:
sparse_categorical_crossentropyThe model was trained on the Sengil/Turkish-ABSA-Wsynthetic dataset, which comprises semi-synthetic Turkish sentences annotated for aspect-based sentiment analysis, particularly in the restaurant domain.
@misc{turkish_absa_bilstm_word2vec,
title = {Turkish Aspect-Based Sentiment Analysis using BiLSTM + Word2Vec},
author = {Sengil},
year = {2025},
url = {https://huggingface.co/Sengil/Turkish-ABSA-BiLSTM-Word2Vec}
}
For questions or feedback, please reach out via Hugging Face profile.