from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name="agentlans/deberta-v3-base-readability-v2"# Put model on GPU or else CPU
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
device = torch.device("cuda"if torch.cuda.is_available() else"cpu")
model = model.to(device)
defreadability(text):
"""Processes the text using the model and returns its logits. In this case, it's reading grade level in years of education (the higher the number, the harder it is to read the text)."""
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(device)
with torch.no_grad():
logits = model(**inputs).logits.squeeze().cpu()
return logits.tolist()
# Example usage
texts = [x.strip() for x in"""The cat sat on the mat.I like to eat pizza and ice cream for dinner.The quick brown fox jumps over the lazy dog.Students must complete their homework before watching television.The intricate ecosystem of the rainforest supports a diverse array of flora and fauna.Quantum mechanics describes the behavior of matter and energy at the molecular, atomic, nuclear, and even smaller microscopic levels.The socioeconomic ramifications of globalization have led to unprecedented levels of interconnectedness and cultural homogenization.The ontological argument for the existence of God posits that the very concept of a maximally great being necessitates its existence in reality.""".strip().split("\n")]
result = readability(texts)
for x, s inzip(texts, result):
print(f"Text: {x}\nReadability grade: {round(s, 2)}\n")
Example output for
base
size model:
Text: The cat sat on the mat.
Readability grade: 2.34
Text: I like to eat pizza and ice cream for dinner.
Readability grade: 3.56
Text: The quick brown fox jumps over the lazy dog.
Readability grade: 3.72
Text: Students must complete their homework before watching television.
Readability grade: 10.79
Text: The intricate ecosystem of the rainforest supports a diverse array of flora and fauna.
Readability grade: 11.1
Text: Quantum mechanics describes the behavior of matter and energy at the molecular, atomic, nuclear, and even smaller microscopic levels.
Readability grade: 17.11
Text: The socioeconomic ramifications of globalization have led to unprecedented levels of interconnectedness and cultural homogenization.
Readability grade: 19.53
Text: The ontological argument for the existence of God posits that the very concept of a maximally great being necessitates its existence in reality.
Readability grade: 16.8
Limitations
English language only
Performance may vary for texts significantly different from the training data
Output is based on statistical patterns and may not always align with human judgment
Readability is assessed purely on textual features, not considering factors like subject familiarity or cultural context
Ethical Considerations
Should not be used as the sole determinant of text suitability for specific audiences
Results may reflect biases present in the training data sources
Care should be taken when using these models in educational or publishing contexts
Runs of agentlans deberta-v3-base-readability-v2 on huggingface.co
1.3K
Total runs
21
24-hour runs
-288
3-day runs
-1.1K
7-day runs
-3.4K
30-day runs
More Information About deberta-v3-base-readability-v2 huggingface.co Model
More deberta-v3-base-readability-v2 license Visit here:
deberta-v3-base-readability-v2 huggingface.co is an AI model on huggingface.co that provides deberta-v3-base-readability-v2's model effect (), which can be used instantly with this agentlans deberta-v3-base-readability-v2 model. huggingface.co supports a free trial of the deberta-v3-base-readability-v2 model, and also provides paid use of the deberta-v3-base-readability-v2. Support call deberta-v3-base-readability-v2 model through api, including Node.js, Python, http.
deberta-v3-base-readability-v2 huggingface.co is an online trial and call api platform, which integrates deberta-v3-base-readability-v2's modeling effects, including api services, and provides a free online trial of deberta-v3-base-readability-v2, you can try deberta-v3-base-readability-v2 online for free by clicking the link below.
agentlans deberta-v3-base-readability-v2 online free url in huggingface.co:
deberta-v3-base-readability-v2 is an open source model from GitHub that offers a free installation service, and any user can find deberta-v3-base-readability-v2 on GitHub to install. At the same time, huggingface.co provides the effect of deberta-v3-base-readability-v2 install, users can directly use deberta-v3-base-readability-v2 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
deberta-v3-base-readability-v2 install url in huggingface.co: