Downloads · 30 days
27
4% of all-time downloads
oguzhandurmaz/deberta-v3-small-cefr-lora-merged
deberta-v3-small-cefr-lora-merged is a text classification model from oguzhandurmaz. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
[](https://github.com/oguzhandurmaz/cefr-predictor-onnx-api) [](https://medium.com/p/e4eb2220165f)
Downloads · 30 days
27
4% of all-time downloads
All-time downloads
749
Public
Parameters
142M
742 MB on disk
Likes
5
Public
Click a slice to open those files.
.safetensors568 MB · 74%
From the Hugging Face model README
This model is a fine-tuned version of microsoft/deberta-v3-small designed to predict English language proficiency levels according to the Common European Framework of Reference for Languages (CEFR). It classifies input text into one of six levels: A1, A2, B1, B2, C1, and C2.
The model was trained using LoRA (Low-Rank Adaptation) and subsequently merged into the base model to ensure easy deployment and optimized inference performance.
The training process utilized a diverse collection of high-quality CEFR-labeled datasets to ensure robustness across various writing styles and complexities:
You can easily integrate this model using the transformers library:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import torch.nn.functional as F
tokenizer = AutoTokenizer.from_pretrained("oguzhandurmaz/deberta-v3-small-cefr-lora-merged")
model = AutoModelForSequenceClassification.from_pretrained("oguzhandurmaz/deberta-v3-small-cefr-lora-merged")
text = "The economic infrastructure is undergoing a significant transformation."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
logits = model(**inputs).logits
probs = F.softmax(logits, dim=-1)
predicted_class = torch.argmax(probs, dim=-1).item()
labels = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2']
print(f"Predicted CEFR Level: {labels[predicted_class]}")
query_proj, value_projThis model has been converted to the ONNX Runtime format and quantized to INT8 precision. This optimization allows for significantly faster inference speeds and reduced memory footprint, making it ideal for production environments and CPU-only servers.
The optimized files are located in the onnx/ directory:
model_quantized.onnx: The core model weights in INT8 format.tokenizer.json & tokenizer_config.json: Vocabulary and tokenizer settings.config.json: Model architecture details and CEFR label mapping.spm.model: SentencePiece model for DeBERTa-based tokenization.To run the optimized version, you need the onnxruntime and transformers libraries:
import onnxruntime as ort
from transformers import AutoTokenizer
import numpy as np
# Load Model and Tokenizer
model_id = "oguzhandurmaz/deberta-v3-small-cefr-lora-merged"
onnx_path = "onnx/model_quantized.onnx"
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Initialize ONNX Runtime Session
session = ort.InferenceSession(onnx_path, providers=['CPUExecutionProvider'])
def predict(text):
# Tokenize input
inputs = tokenizer(text, return_tensors="np")
# Convert inputs to int64 (required by ONNX)
onnx_inputs = {k: v.astype(np.int64) for k, v in inputs.items()}
# Run Inference
logits = session.run(None, onnx_inputs)[0]
# Softmax to get probabilities
probs = np.exp(logits) / np.sum(np.exp(logits), axis=-1)
# CEFR Label Map
labels = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2']
return {
"label": labels[np.argmax(probs)],
"confidence": float(np.max(probs))
}
# Example Usage
result = predict("The economic ramifications of the policy were far-reaching and complex.")
print(f"Predicted Level: {result['label']} (Confidence: {result['confidence']:.2f})")