File size: 2,428 Bytes
e12a2ef 292c2a8 e12a2ef 51c118d e12a2ef 51c118d e12a2ef 5d5c5d6 51c118d 5d5c5d6 e12a2ef 5d5c5d6 e12a2ef ac3407b 51c118d e12a2ef 51c118d e12a2ef 51c118d e12a2ef 51c118d e12a2ef 51c118d ac3407b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
---
library_name: transformers
tags:
- gpt2
- absa
- nlp
- turkish
license: mit
datasets:
- ebrukilic/ytu-araproje-absa-7400
language:
- tr
metrics:
- f1
- accuracy
- precision
- recall
base_model:
- openai-community/gpt2
pipeline_tag: text-classification
---
# Model Card for Model ID
<!-- Provide a quick summary of what the model is/does. -->
## Modelin Tanıtımı
Aspect-Based Sentiment Analysis (ABSA) için ince ayar yapılmış bir GPT-2 modelidir. Model, giyim ürünlerine ait "aspectler" hakkında yapılan yorumların duygu analizini gerçekleştirmek için eğitilmiştir.
- **Temel Alınan Model:** [[openai-community/gpt2](https://huggingface.co/openai-community/gpt2)]
- **Eğitildiği Veri Kümesi:** [[ebrukilic/ytu-araproje-absa-7400](ebrukilic/ytu-araproje-absa-7400)]
- **Duygu Sınıfları:** negatif: 0, nötr: 1, pozitif: 2
- **Dil:** Türkçe
- **Developed by:** [[ebru kılıç](https://huggingface.co/ebrukilic)]
- **Language(s) (NLP):** Turkish
- **Sentiment Classes:** negative: 0, neutral: 1, positive: 2
- **Finetuned from model [optional]:** [[openai-community/gpt2](https://huggingface.co/openai-community/gpt2)]
## Modeli Nasıl Kullanabiliriz?
```
from transformers import GPT2Tokenizer, GPT2ForSequenceClassification
import torch
model_name = "ebrukilic/absa-gpt-2"
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
tokenizer.pad_token = tokenizer.eos_token
model = GPT2ForSequenceClassification.from_pretrained(model_name)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
def predict_sentiment(text, aspect, model, tokenizer):
inputs = tokenizer.encode_plus(
text=f"{aspect} hakkında: {text}",
add_special_tokens=True,
max_length=128,
padding="max_length",
truncation=True,
return_attention_mask=True,
return_tensors="pt"
)
input_ids = inputs["input_ids"].to(device)
attention_mask = inputs["attention_mask"].to(device)
with torch.no_grad():
outputs = model(input_ids, attention_mask=attention_mask)
predicted_class = torch.argmax(outputs.logits, dim=1).item()
return predicted_class
new_text = "Ürünün kumaşı çok güzel, bayıldım!"
aspect = "kumaş"
predicted_sentiment = predict_sentiment(new_text, aspect, model, tokenizer)
print("Yorum:", new_text)
print("Aspect:", aspect)
print("Tahmin Edilen Duygu:", predicted_sentiment)
```
|