Downloads · 30 days
12
24% of all-time downloads
WhiteAngelss/bert-base-turkish-cased
bert-base-turkish-cased is a text classification model from WhiteAngelss. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
Bu proje, Türkçe dilindeki metinleri sınıflandırmak için fine-tune edilmiş bir BERT modelini kullanır. Model, metinleri aşağıdaki sınıflara ayırabilir:
Downloads · 30 days
12
24% of all-time downloads
All-time downloads
51
Public
Parameters
184M
737 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors737 MB · 100%
From the Hugging Face model README
Bu proje, Türkçe dilindeki metinleri sınıflandırmak için fine-tune edilmiş bir BERT modelini kullanır. Model, metinleri aşağıdaki sınıflara ayırabilir:
Gerekli paketleri yükleyin:
pip install transformers torch matplotlib
Model ve tokenizer'ı indirin:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("WhiteAngelss/bert-base-turkish-cased")
model = AutoModelForSequenceClassification.from_pretrained("WhiteAngelss/bert-base-turkish-cased")
Test cümleleri ile modeli test edin:
sentences = [
"Sen gerçekten aptalsın ve her şeyin en kötüsünü hak ediyorsun.", # INSULT
"Bugün hava çok güzel.", # OTHER
"Bu dilimizdeki küfürlerden biri olabilir.", # PROFANITY
"Tüm kadınlar sadece mutfak işlerini yapar, bu doğaldır.", # SEXIST
"Siyahlar toplumda geri kalmış, bu kabul edilemez." # RACIST
]
inputs = tokenizer(sentences, return_tensors="pt", padding=True, truncation=True)
outputs = model(**inputs)
probs = torch.nn.functional.softmax(outputs.logits, dim=-1)
Sonuçları yazdırın ve görselleştirin:
import matplotlib.pyplot as plt
user_probs_np = probs.detach().numpy()
fig, ax = plt.subplots()
bars = ax.bar(id2label.values(), user_probs_np[0], color='skyblue')
ax.set_xlabel('Sınıflar')
ax.set_ylabel('Olasılıklar')
ax.set_title('Tahmin Edilen Sınıfların Olasılıkları')
for bar in bars:
height = bar.get_height()
ax.text(bar.get_x() + bar.get_width() / 2, height, f'{height * 100:.2f}%', ha='center', va='bottom')
plt.xticks(rotation=45)
plt.show()
Bu projeyi WhiteAngels Team hazırlamıştır.
import matplotlib.pyplot as plt import numpy as np
id2label = { "0": "Nötr", "1": "Positive", "2": "Negative"
}
sentences = [
"Sen gerçekten aptalsın ve her şeyin en kötüsünü hak ediyorsun.",
"Bugün hava çok güzel.",
"Bu dilimizdeki küfürlerden biri olabilir.",
"Tüm kadınlar sadece mutfak işlerini yapar, bu doğaldır.",
"Siyahlar toplumda geri kalmış, bu kabul edilemez."
]
user_probs_np = np.array([0.65, 0.05, 0.15, 0.10, 0.05])
fig, ax = plt.subplots() bars = ax.bar(id2label.values(), user_probs_np, color='skyblue') ax.set_xlabel('Sınıflar') ax.set_ylabel('Olasılıklar') ax.set_title('Tahmin Edilen Sınıfların Olasılıkları')
for bar in bars: height = bar.get_height() ax.text(bar.get_x() + bar.get_width() / 2, height, f'{height * 100:.2f}%', ha='center', va='bottom')
plt.xticks(rotation=45) plt.show()