Downloads · 30 days
4
8% of all-time downloads
hannah-khallaf/e2r-strategy-multilingual-e5-large-bce
e2r-strategy-multilingual-e5-large-bce is a text classification model from hannah-khallaf. 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 model identifies the simplification strategies realised between a standard-language sentence and its Easy-to-Read rewrite.
Downloads · 30 days
4
8% of all-time downloads
All-time downloads
49
Public
Parameters
560M
2.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.2 GB · 99%
From the Hugging Face model README
This model identifies the simplification strategies realised between a standard-language sentence and its Easy-to-Read rewrite.
It is a multilingual sentence-pair multi-label classifier covering Arabic, Catalan, English, French, Italian and Spanish.
The model predicts any combination of the following six strategies:
The label order is fixed and must not be changed.
The model uses:
intfloat/multilingual-e5-large as the multilingual encoder;query: on both input sequences;0.1;0.23;The classification architecture is:
Multilingual-E5 Large
→ first-token/CLS representation
→ dropout
→ linear layer with six outputs
→ sigmoid probabilities
→ threshold at 0.23
The model was trained using binary cross-entropy without positive-label weighting.
This repository contains seed 87, selected using development Macro-F1.
| Result | Value |
|---|---|
| Selected seed | 87 |
| Best epoch | 4 |
| Development Macro-F1 | 69.68 |
| Three-seed test Macro-F1, mean ± SD | 61.35 ± 1.09 |
| Global decision threshold | 0.23 |
The development result refers to the released seed. The test result is the mean and standard deviation across seeds 13, 42 and 87.
pip install torch transformers
The prefix query: must be added to both sequences:
query: <standard sentence>
query: <Easy-to-Read rewrite>
The standard sentence must be supplied first and the Easy-to-Read rewrite second.
This repository contains the exact custom classification architecture, so load it with trust_remote_code=True.
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_id = "hannah-khallaf/e2r-strategy-multilingual-e5-large-bce"
tokenizer = AutoTokenizer.from_pretrained(
model_id,
trust_remote_code=True,
)
model = AutoModelForSequenceClassification.from_pretrained(
model_id,
trust_remote_code=True,
)
standard_sentence = (
"The committee postponed the implementation of the measure."
)
easy_to_read_rewrite = (
"The committee decided to use the measure later."
)
inputs = tokenizer(
"query: " + standard_sentence,
"query: " + easy_to_read_rewrite,
return_tensors="pt",
truncation=True,
max_length=512,
)
model.eval()
with torch.inference_mode():
logits = model(**inputs).logits
probabilities = torch.sigmoid(logits)[0]
labels = [
model.config.id2label[index]
for index in range(model.config.num_labels)
]
thresholds = model.config.e2r_classifier["thresholds"]
scores = {
label: float(probability)
for label, probability in zip(labels, probabilities)
}
predicted_labels = [
label
for label in labels
if scores[label] >= float(thresholds[label])
]
print("Predicted strategies:", predicted_labels)
print("Scores:", scores)
from __future__ import annotations
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
MODEL_ID = "hannah-khallaf/e2r-strategy-multilingual-e5-large-bce"
tokenizer = AutoTokenizer.from_pretrained(
MODEL_ID,
trust_remote_code=True,
)
model = AutoModelForSequenceClassification.from_pretrained(
MODEL_ID,
trust_remote_code=True,
)
model.eval()
def classify_rewrite(
standard_sentence: str,
easy_to_read_rewrite: str,
) -> dict:
inputs = tokenizer(
"query: " + standard_sentence,
"query: " + easy_to_read_rewrite,
return_tensors="pt",
truncation=True,
max_length=512,
)
with torch.inference_mode():
logits = model(**inputs).logits
probabilities = torch.sigmoid(logits)[0]
labels = [
model.config.id2label[index]
for index in range(model.config.num_labels)
]
thresholds = model.config.e2r_classifier["thresholds"]
scores = {
label: float(probability)
for label, probability in zip(labels, probabilities)
}
predicted_labels = [
label
for label in labels
if scores[label] >= float(thresholds[label])
]
return {
"predicted_labels": predicted_labels,
"scores": scores,
"thresholds": thresholds,
}
The model was trained using the following exact input contract:
inputs = tokenizer(
"query: " + standard_sentence,
"query: " + easy_to_read_rewrite,
return_tensors="pt",
truncation=True,
max_length=512,
)
Do not omit the prefixes or reverse the sentence order.
The model returns six logits in the following exact order:
Synonymy
Modulation
Compression
Explanation
Syntactic Change
Omission
Apply torch.sigmoid() to obtain probabilities. A strategy is predicted when its probability is at least 0.23.
The thresholds are also available from:
model.config.e2r_classifier["thresholds"]
The model is intended for:
Its predictions should be reviewed by a qualified annotator when used in research or data creation.
The model should not be used as evidence that a text is accessible to a particular person or reader group.
It should not be used to make medical, legal, educational or administrative decisions about individuals.
The model assigns labels at sentence level. It does not:
Performance differences between languages may reflect differences in corpus, domain, simplification practice, annotation procedure and label harmonisation. They should not be interpreted as inherent differences between languages.
The repository includes:
The exported Transformers model was checked against the original PairClassifier using the same prefixed sentence-pair input. The original and exported implementations produced identical logits, probabilities and thresholded predictions.
Please cite the accompanying paper when using this model. The complete bibliographic entry will be added after publication.