Instructions to use llaydak/trialmodel1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use llaydak/trialmodel1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="llaydak/trialmodel1")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("llaydak/trialmodel1") model = AutoModelForSequenceClassification.from_pretrained("llaydak/trialmodel1") - Notebooks
- Google Colab
- Kaggle
| from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
| import torch | |
| # Model ve tokenizer yolları | |
| model_path = "./" # Eğitilmiş modelin bulunduğu klasör | |
| model = AutoModelForSequenceClassification.from_pretrained(model_path) | |
| tokenizer = AutoTokenizer.from_pretrained(model_path) | |
| print("Model ve tokenizer başarıyla yüklendi!") | |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| model.to(device) | |
| print(f"Model {device} üzerinde çalışıyor.") | |
| def predict(text): | |
| # Metni tokenize et | |
| inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512).to(device) | |
| # Modeli kullanarak tahmin yap | |
| outputs = model(**inputs) | |
| logits = outputs.logits | |
| # Logits'i sınıfa dönüştürme | |
| predicted_class = logits.argmax().item() | |
| # Türkçe sınıf etiketleri | |
| label_mapping = { | |
| 0: "HAKARET YOK", | |
| 1: "HAKARET", | |
| 2: "IRKÇILIK", | |
| 3: "CİNSİYETÇİLİK", | |
| 4: "DİĞER" | |
| } | |
| # Tahmin edilen sınıf | |
| return label_mapping[predicted_class] | |
| # Örnek tahminler | |
| texts = [ | |
| "Sen harikasın!", | |
| "Mutfak robotu seni", | |
| "Bunu nasıl söyleyebildin?", | |
| "AmınaKoyim ", | |
| "pis arap" | |
| ] | |
| print("\nTahminler:") | |
| for text in texts: | |
| prediction = predict(text) | |
| print(f"Metin: {text}") | |
| print(f"Tahmin edilen sınıf: {prediction}") | |
| print("-" * 50) | |