Views
No views yet
1from transformers import pipeline
2import torch
3
4device = 0 if torch.cuda.is_available() else -1
5classifier = pipeline(
6 "text-classification",
7 model="agentlans/snowflake-arctic-xs-grammar-classifier",
8 device=device,
9)
10
11text = "I absolutely loved this movie!"
12result = classifier(text)
13print(result) # [{'label': 'grammatical', 'score': 0.8963921666145325}]| Status | Text | Explanation |
|---|---|---|
| ✔️ | I absolutely loved this movie! | Grammatically correct, clear sentence structure |
| ❌ | How do I shot web? | Grammatically incorrect, improper verb usage |
| ✔️ | Beware the Jabberwock, my son! | Poetic language, grammatically sound |
| ✔️ | Colourless green ideas sleep furiously. | Grammatically correct, though semantically nonsensical |
| ❌ | Has anyone really been far even as decided to use even go want to do look more like? | Completely incoherent and grammatically incorrect |
| Training Loss | Epoch | Step | Validation Loss | Accuracy | Input Tokens Seen |
|---|---|---|---|---|---|
| 0.5192 | 1.0 | 3750 | 0.4722 | 0.7738 | 61 440 000 |
| 0.4875 | 2.0 | 7500 | 0.4521 | 0.7881 | 122 880 000 |
| 0.4590 | 3.0 | 11250 | 0.3895 | 0.8227 | 184 320 000 |
| 0.4351 | 4.0 | 15000 | 0.3981 | 0.8197 | 245 760 000 |
| 0.4157 | 5.0 | 18750 | 0.3690 | 0.8337 | 307 200 000 |
| 0.3955 | 6.0 | 22500 | 0.3260 | 0.8585 | 368 640 000 |
| 0.3788 | 7.0 | 26250 | 0.3267 | 0.8566 | 430 080 000 |
| 0.3616 | 8.0 | 30000 | 0.3192 | 0.8621 | 491 520 000 |
| 0.3459 | 9.0 | 33750 | 0.3017 | 0.8707 | 552 960 000 |
| 0.3382 | 10.0 | 37500 | 0.2971 | 0.8724 | 614 400 000 |