Downloads · 30 days
12
2% of all-time downloads
agentlans/deberta-v3-xsmall-readability
deberta-v3-xsmall-readability is a text classification model from agentlans. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
This is a fine-tuned DeBERTa-v3-xsmall model for predicting the readability level of English texts.
Downloads · 30 days
12
2% of all-time downloads
All-time downloads
582
Public
Parameters
70.8M
286 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors283 MB · 96%
From the Hugging Face model README
This is a fine-tuned DeBERTa-v3-xsmall model for predicting the readability level of English texts.
Suitable for:
The model was fine-tuned on the agentlans/readability dataset containing paragraphs from four sources.
Each paragraph was annotated with 6 readability metrics that estimate U.S. grade level reading comprehension.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name="agentlans/deberta-v3-xsmall-readability"
# 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)
def readability(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
text = ["One day, Tim's teddy bear was sad. Tim did not know why his teddy bear was sad.",
"A few years back, I decided it was time for me to take a break from my mundane routine and embark on an adventure.",
"We also experimentally verify that simply scaling the pulse energy by 3/2 between linearly and circularly polarized pumping closely reproduces the soliton and dispersive wave dynamics."]
result = readability(text)
[round(x, 1) for x in result] # Estimated reading grades [2.9, 9.8, 21.9]
<details>
<summary>Performance metrics and training details</summary>
On the evaluation set: