Instructions to use hannah-khallaf/e2r-strategy-gemma-3-12b-pairwise-qlora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use hannah-khallaf/e2r-strategy-gemma-3-12b-pairwise-qlora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-3-12b-it") model = PeftModel.from_pretrained(base_model, "hannah-khallaf/e2r-strategy-gemma-3-12b-pairwise-qlora") - Notebooks
- Google Colab
- Kaggle
E2R Strategy Gemma 3 12B Pairwise QLoRA
This repository contains the PEFT/QLoRA adapter for a Gemma 3 12B pairwise multilabel classifier for identifying Easy-to-Read (E2R) simplification strategies.
Base model
google/gemma-3-12b-it
Task
Given a standard sentence and its Easy-to-Read rewrite, the model scores each candidate strategy independently.
The six strategy labels, in benchmark order, are:
- Synonymy
- Modulation
- Compression
- Explanation
- Syntactic Change
- Omission
The model therefore performs six binary candidate-label evaluations for each sentence pair.
Model formulation
The checkpoint uses:
- pair input: standard sentence + Easy-to-Read sentence;
- pairwise binary-relevance formulation;
- QLoRA;
- all negative candidate labels during training;
- token-probability decisions based on the next-token probabilities of
trueandfalse; - Gemma 3 12B Instruct as the base model.
Development-selected thresholds
The thresholds were selected using the development set only:
| Strategy | Threshold |
|---|---|
| Synonymy | 0.54 |
| Modulation | 0.87 |
| Compression | 0.11 |
| Explanation | 0.16 |
| Syntactic Change | 0.32 |
| Omission | 0.11 |
The thresholds are also provided in thresholds.json.
Recovered checkpoint
This repository contains seed 13 from a reproducibility rerun of the six-label benchmark.
This is not claimed to be the byte-identical historical checkpoint from the earlier experiment, because that checkpoint was no longer available. The model was retrained from the preserved experiment configuration.
Development performance
- Macro-F1: 0.713499
- Micro-F1: 0.773989
- Exact-set accuracy: 0.335878
- Hamming loss: 0.181298
Test performance
- Macro-F1: 0.640985
- Micro-F1: 0.703438
- Exact-set accuracy: 0.163701
- Hamming loss: 0.245552
Files
adapter_model.safetensorsβ QLoRA adapter weightsadapter_config.jsonβ PEFT adapter configurationtokenizer/β tokenizer and Gemma chat template saved with the runresolved_config.yamlβ full experiment configurationthresholds.jsonβ development-selected strategy thresholdsdev_summary.jsonβ development-set resultstest_summary.jsonβ test-set resultsdev_per_label.csvβ development per-label resultstest_per_label.csvβ test per-label resultstraining_history.csvβ training historyruntime.jsonβ recorded runtime informationhf_reload_full_test_comparison.csvβ Hugging Face reload validationinference.pyβ benchmark-compatible model loading/scoring utilities
Important usage note
This repository contains a PEFT adapter rather than a merged copy of the
Gemma 3 12B base model. Access to and use of the base model remain subject
to the terms applicable to google/gemma-3-12b-it.
The classifier requires the candidate-label prompting formulation used by the E2R benchmark. Loading the adapter alone as a generic text classification pipeline does not reproduce the task.
Quick start
The classifier takes a standard sentence and its Easy-to-Read rewrite and predicts all six transformation strategies independently.
Installation
pip install torch transformers peft bitsandbytes accelerate huggingface_hub
Gemma 3 access must be available for the Hugging Face account used to run the model.
Classify one sentence pair
from inference import E2RStrategyClassifier
classifier = E2RStrategyClassifier.from_pretrained(
"hannah-khallaf/e2r-strategy-gemma-3-12b-pairwise-qlora"
)
result = classifier.predict(
standard=(
"Before moving to Spain, Kate had worked "
"as a barrister in the UK."
),
easy_to_read=(
"Kate was a lawyer in the United Kingdom. "
"Then she moved to Spain."
),
)
print(result["labels"])
for label, probability in result["probabilities"].items():
print(
f"{label:20s} "
f"{probability:.4f} "
f"(threshold={result['thresholds'][label]:.2f})"
)
The result has the form:
{
"labels": [
# strategies predicted for this pair
],
"probabilities": {
"Synonymy": ...,
"Modulation": ...,
"Compression": ...,
"Explanation": ...,
"Syntactic Change": ...,
"Omission": ...
},
"thresholds": {
"Synonymy": 0.54,
"Modulation": 0.87,
"Compression": 0.11,
"Explanation": 0.16,
"Syntactic Change": 0.32,
"Omission": 0.11
}
}
The values above are deliberately left unspecified here. Use the model output itself for the probabilities; the classifier applies the development-selected threshold for each strategy automatically.
Batch prediction
examples = [
{
"standard":
"Before moving to Spain, Kate had worked "
"as a barrister in the UK.",
"easy_to_read":
"Kate was a lawyer in the United Kingdom. "
"Then she moved to Spain.",
},
{
"standard":
"Well, uh, I am hungry.",
"easy_to_read":
"I am hungry.",
},
]
results = classifier.predict_batch(examples)
for result in results:
print(result["labels"])
Output interpretation
A probability should not be interpreted using a universal threshold of 0.5. Each strategy uses the threshold selected on the development set.
For example, a Compression probability of 0.20 is classified as
present because the Compression threshold is 0.11, while a Modulation
probability of 0.80 is classified as absent because its threshold is
0.87.
The model performs six candidate-label evaluations for every sentence pair, so several strategies may be returned simultaneously.
- Downloads last month
- 3