agentlans commited on
Commit
16d8865
1 Parent(s): ae1f638

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -0
README.md CHANGED
@@ -32,6 +32,29 @@ The model was trained on [agentlans/tatoeba-english-translations](https://huggin
32
 
33
  ## Usage
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ## Results
36
 
37
  In this study, 10 English text samples of varying quality were generated and translated into Arabic, Chinese, French, Russian, and Spanish using Google Translate. This resulted in a total of 50 translated samples, which were subsequently analyzed by a trained classifier to predict their quality scores.
 
32
 
33
  ## Usage
34
 
35
+ ```python
36
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
37
+ import torch
38
+
39
+ model_name="agentlans/mdeberta-v3-base-quality"
40
+
41
+ # Put model on GPU or else CPU
42
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
43
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
44
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
45
+ model = model.to(device)
46
+
47
+ def quality(text):
48
+ """Processes the text using the model and returns its logits.
49
+ In this case, it's interpreted as the the combined quality score for that text."""
50
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(device)
51
+ with torch.no_grad():
52
+ logits = model(**inputs).logits.squeeze().cpu()
53
+ return logits.tolist()
54
+
55
+ quality("Your text here.")
56
+ ```
57
+
58
  ## Results
59
 
60
  In this study, 10 English text samples of varying quality were generated and translated into Arabic, Chinese, French, Russian, and Spanish using Google Translate. This resulted in a total of 50 translated samples, which were subsequently analyzed by a trained classifier to predict their quality scores.