Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "agentlans/GIST-all-MiniLM-L6-v2-quality-v3"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name).to("cuda" if torch.cuda.is_available() else "cpu")
7
8# Higher scores indicate higher text quality.
9# The sign of the score has no particular meaning.
10# For example, a negative score doesn't necessarily mean that the text is low quality.
11def quality(text):
12 inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(model.device)
13 with torch.no_grad():
14 score = model(**inputs).logits.squeeze().cpu().item()
15 return score
16
17print(quality("Your text here."))| Training Loss | Epoch | Step | Validation Loss | Mse | Combined Score | Input Tokens Seen |
|---|---|---|---|---|---|---|
| 0.1777 | 1.0 | 10000 | 0.2354 | 0.2354 | 0.2354 | 10239872 |
| 0.1389 | 2.0 | 20000 | 0.1572 | 0.1572 | 0.1572 | 20479744 |
| 0.1 | 3.0 | 30000 | 0.1961 | 0.1961 | 0.1961 | 30719616 |
| 0.0687 | 4.0 | 40000 | 0.1596 | 0.1596 | 0.1596 | 40959488 |
| 0.0559 | 5.0 | 50000 | 0.1757 | 0.1757 | 0.1757 | 51199360 |
| 0.0409 | 6.0 | 60000 | 0.1677 | 0.1677 | 0.1677 | 61439232 |
| 0.0319 | 7.0 | 70000 | 0.1852 | 0.1852 | 0.1852 | 71679104 |
| 0.0266 | 8.0 | 80000 | 0.1840 | 0.1840 | 0.1840 | 81918976 |
| 0.0202 | 9.0 | 90000 | 0.1724 | 0.1724 | 0.1724 | 92158848 |
| 0.0172 | 10.0 | 100000 | 0.1731 | 0.1731 | 0.1731 | 102398720 |