Update README.md
Browse files
README.md
CHANGED
@@ -67,22 +67,27 @@ model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
67 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
68 |
model.to(device)
|
69 |
model.eval()
|
|
|
70 |
|
|
|
71 |
# Test örneği
|
72 |
-
text = "
|
73 |
-
|
74 |
-
|
|
|
|
|
75 |
|
76 |
-
# Model
|
77 |
with torch.no_grad():
|
78 |
outputs = model(**inputs)
|
79 |
|
80 |
logits = outputs.logits
|
81 |
predicted_class_id = torch.argmax(logits, dim=-1).item()
|
82 |
|
83 |
-
#
|
84 |
id_to_label = {0: "negatif", 1: "nötr", 2: "pozitif"}
|
85 |
-
|
|
|
86 |
```
|
87 |
|
88 |
## Training Details
|
|
|
67 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
68 |
model.to(device)
|
69 |
model.eval()
|
70 |
+
```
|
71 |
|
72 |
+
```python
|
73 |
# Test örneği
|
74 |
+
text = "Ürün çok güzel ama kolları kısa ve çok dar"
|
75 |
+
aspect = "Beden"
|
76 |
+
|
77 |
+
# Tokenize etme
|
78 |
+
inputs = tokenizer(aspect, text, truncation=True, padding='max_length', max_length=128, return_tensors="pt").to(device)
|
79 |
|
80 |
+
# Model ile tahmin yapma
|
81 |
with torch.no_grad():
|
82 |
outputs = model(**inputs)
|
83 |
|
84 |
logits = outputs.logits
|
85 |
predicted_class_id = torch.argmax(logits, dim=-1).item()
|
86 |
|
87 |
+
# Tahmin edilen etiketin açıklaması
|
88 |
id_to_label = {0: "negatif", 1: "nötr", 2: "pozitif"}
|
89 |
+
predicted_label = id_to_label[predicted_class_id]
|
90 |
+
print(f"Tahmin edilen etiket: {predicted_label}")
|
91 |
```
|
92 |
|
93 |
## Training Details
|