simple-score 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. simple_score-0.1.0/LICENSE +21 -0
  2. simple_score-0.1.0/MANIFEST.in +2 -0
  3. simple_score-0.1.0/PKG-INFO +240 -0
  4. simple_score-0.1.0/README.md +202 -0
  5. simple_score-0.1.0/pyproject.toml +60 -0
  6. simple_score-0.1.0/setup.cfg +4 -0
  7. simple_score-0.1.0/src/simple_score/__init__.py +34 -0
  8. simple_score-0.1.0/src/simple_score/_version.py +1 -0
  9. simple_score-0.1.0/src/simple_score/cli.py +155 -0
  10. simple_score-0.1.0/src/simple_score/data/__init__.py +35 -0
  11. simple_score-0.1.0/src/simple_score/data/augment.py +82 -0
  12. simple_score-0.1.0/src/simple_score/data/builders.py +391 -0
  13. simple_score-0.1.0/src/simple_score/data/io.py +204 -0
  14. simple_score-0.1.0/src/simple_score/hub.py +23 -0
  15. simple_score-0.1.0/src/simple_score/losses.py +88 -0
  16. simple_score-0.1.0/src/simple_score/modeling.py +237 -0
  17. simple_score-0.1.0/src/simple_score/scorer.py +173 -0
  18. simple_score-0.1.0/src/simple_score/training/__init__.py +15 -0
  19. simple_score-0.1.0/src/simple_score/training/config.py +138 -0
  20. simple_score-0.1.0/src/simple_score/training/datasets.py +84 -0
  21. simple_score-0.1.0/src/simple_score/training/trainer.py +451 -0
  22. simple_score-0.1.0/src/simple_score.egg-info/PKG-INFO +240 -0
  23. simple_score-0.1.0/src/simple_score.egg-info/SOURCES.txt +30 -0
  24. simple_score-0.1.0/src/simple_score.egg-info/dependency_links.txt +1 -0
  25. simple_score-0.1.0/src/simple_score.egg-info/entry_points.txt +2 -0
  26. simple_score-0.1.0/src/simple_score.egg-info/requires.txt +23 -0
  27. simple_score-0.1.0/src/simple_score.egg-info/top_level.txt +1 -0
  28. simple_score-0.1.0/tests/conftest.py +67 -0
  29. simple_score-0.1.0/tests/test_data.py +119 -0
  30. simple_score-0.1.0/tests/test_losses.py +51 -0
  31. simple_score-0.1.0/tests/test_model_and_scorer.py +41 -0
  32. simple_score-0.1.0/tests/test_training.py +85 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michele Papucci
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ recursive-include tests *.py
2
+ include LICENSE README.md
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.4
2
+ Name: simple-score
3
+ Version: 0.1.0
4
+ Summary: SIMPLE Score: a reference-free learned metric for text simplification that also reports its own uncertainty.
5
+ Author: Michele Papucci
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/michelepapucci/simple-score
8
+ Project-URL: Models, https://huggingface.co/mpapucci
9
+ Keywords: text simplification,evaluation,metric,nlp,preference learning
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Classifier: Topic :: Text Processing :: Linguistic
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: torch>=1.13
18
+ Requires-Dist: transformers>=4.38
19
+ Requires-Dist: huggingface_hub>=0.20
20
+ Requires-Dist: safetensors>=0.4
21
+ Requires-Dist: numpy
22
+ Requires-Dist: tqdm
23
+ Provides-Extra: train
24
+ Requires-Dist: pyyaml>=6.0; extra == "train"
25
+ Requires-Dist: sentencepiece; extra == "train"
26
+ Requires-Dist: protobuf; extra == "train"
27
+ Provides-Extra: data
28
+ Requires-Dist: pyarrow; extra == "data"
29
+ Requires-Dist: datasets; extra == "data"
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: ruff; extra == "dev"
33
+ Requires-Dist: build; extra == "dev"
34
+ Requires-Dist: pyyaml>=6.0; extra == "dev"
35
+ Requires-Dist: sentencepiece; extra == "dev"
36
+ Requires-Dist: protobuf; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # SIMPLE Score: SImplicity Metric via Preference LEarning
40
+
41
+ SIMPLE Score is a **reference-free** learned metric for sentence simplification. For each
42
+ source sentence and candidate simplification it returns:
43
+
44
+ - **`mu`**, a quality score in (-1, 1):
45
+ - **+1**: a highly successful simplification
46
+ - **0**: a verbatim copy of the source
47
+ - **-1**: unrelated or degenerate text
48
+
49
+ Negative scores flag unsuccessful simplifications, including complexifications.
50
+ - **`sigma`**, the model's uncertainty about that score (> 0.05). Low-sigma scores agree
51
+ with human judgements more often, so sigma tells you which scores to double-check.
52
+
53
+ SIMPLE is a DeBERTa-v3 cross-encoder trained on preferences between simplifications
54
+ (Thurstone's model) and calibrated on human quality ratings. This repository has:
55
+
56
+ - the `simple-score` Python package and command line tool;
57
+ - the full training code, which reads plain data files (no dataset-specific code needed);
58
+ - the recipe and configs used to train the paper's models;
59
+ - scripts to reproduce the paper's results.
60
+
61
+ | Model | Hub | SimpEval 2022 pairwise acc. | Pearson | Spearman |
62
+ |---|---|---|---|---|
63
+ | SIMPLE-small | `mpapucci/simple-score-small` | 0.738 | 0.414 | 0.407 |
64
+ | SIMPLE-base | `mpapucci/simple-score-base` | 0.781 | 0.427 | 0.448 |
65
+ | SIMPLE-large | `mpapucci/simple-score-large` | 0.814 | 0.391 | 0.454 |
66
+
67
+ **Try it without installing anything:** the [SIMPLE Score Space](https://huggingface.co/spaces/mpapucci/simple-score)
68
+ runs SIMPLE-small in your browser. The model is downloaded only when you start the demo.
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ pip install simple-score # scoring
74
+ pip install "simple-score[train]" # + training
75
+ ```
76
+
77
+ Python ≥ 3.10 is required, and the package works with transformers 4.x and 5.x.
78
+
79
+ ## Scoring
80
+
81
+ ```python
82
+ from simple_score import SIMPLE
83
+
84
+ metric = SIMPLE.from_pretrained("large") # "small", "base", "large", a Hub id or a local dir
85
+ out = metric.score(
86
+ sources=["The feline perched upon the mat in a state of repose."],
87
+ candidates=["The cat sat on the mat."],
88
+ )
89
+ out.mu # [0.82...] quality score per example
90
+ out.sigma # [0.05...] uncertainty per example
91
+ out.mean # corpus-level score
92
+
93
+ # Probability that candidate A is a better simplification than candidate B (Thurstone)
94
+ metric.preference_prob(source, candidate_a, candidate_b)
95
+ ```
96
+
97
+ The model downloads on first use and runs on GPU when one is available
98
+ (`device="cpu"` forces CPU).
99
+
100
+ From the command line:
101
+
102
+ ```bash
103
+ simple-score score --model large --sources src.txt --candidates system.txt --output scores.jsonl
104
+ simple-score score --model base --input outputs.csv # any file with source + candidate columns
105
+ ```
106
+
107
+ With [🤗 Evaluate](https://huggingface.co/docs/evaluate):
108
+
109
+ ```python
110
+ import evaluate
111
+ simple_score = evaluate.load("mpapucci/simple-score", "large")
112
+ simple_score.compute(sources=sources, predictions=predictions) # {"simple_score", "scores", "sigmas"}
113
+ ```
114
+
115
+ ### Reading the scores
116
+
117
+ - **Comparing systems:** compare mean `mu`. Inspect the examples with negative `mu`; they
118
+ are copies, complexifications or broken outputs.
119
+ - **`sigma` is model confidence**, not a measure of human disagreement. Most predictions
120
+ sit near the 0.05 floor. Examples in the high-`sigma` tail deserve a human look.
121
+ - **Scope:** SIMPLE is trained on English, sentence-level news and Wikipedia
122
+ simplification. It is less reliable on rewrites that mostly add or elaborate content.
123
+
124
+ ## Training on your own data
125
+
126
+ The data can't be redistributed, so the training code makes no assumptions about where it
127
+ came from. You list your files by **what kind of data they hold**, and SIMPLE derives the
128
+ training signal described in the paper:
129
+
130
+ | kind | columns | what SIMPLE derives |
131
+ |---|---|---|
132
+ | `parallel` | `source`, `simplification` | simplification ≻ source; a mirror pair (copying the simple sentence ≻ complexifying it); simplification ≻ unrelated sentence |
133
+ | `graded` | `source`, `simplification`, `level` (higher = simpler), optional `group` | as `parallel`, plus more-simplified ≻ less-simplified for the same source |
134
+ | `ratings` | `source`, `candidate`, `rating` (+ the rating scale) | regression targets on (-1, 1); human-preference pairs with rating margins; copy, flipped and unrelated anchors |
135
+ | `preferences` | `source`, `chosen`, `rejected`, optional `margin`, `weight`, `type` | used as given |
136
+
137
+ **Supported files**
138
+ - Formats: `.jsonl`, `.json`, `.csv`, `.tsv` (quotes allowed in sentences), `.parquet`, gzipped
139
+ versions of these, line-aligned `.txt` files, or a Hugging Face Hub dataset.
140
+ - Column names: common aliases are recognised (`original`, `complex`, `simple`, `score`,
141
+ `positive`/`negative`, …). Anything else can be mapped explicitly.
142
+
143
+ In addition, synthetic regression anchors teach the bottom half of the scale. They come
144
+ from your training sentences: copies score 0, shuffled/truncated/word-dropped sentences
145
+ score between −0.8 and −0.4, and unrelated sentences score −1.
146
+
147
+ **Which kinds do you need?** Any one is enough to start.
148
+ - A parallel corpus alone gives a metric that knows the direction of simplification and
149
+ rejects degenerate outputs.
150
+ - Human ratings calibrate the scale and give the best agreement with human judgements.
151
+
152
+ ### Quick start, no config file
153
+
154
+ ```bash
155
+ simple-score train \
156
+ --parallel my_corpus.tsv \
157
+ --ratings my_ratings.csv --rating-scale 1 5 \
158
+ --backbone microsoft/deberta-v3-base \
159
+ --output-dir runs/my-simple
160
+ ```
161
+
162
+ ### With a config file
163
+
164
+ ```yaml
165
+ # my_config.yaml
166
+ model:
167
+ backbone: microsoft/deberta-v3-base
168
+ training:
169
+ epochs: 5
170
+ batch_size: 16
171
+ lr: 1.0e-5
172
+ data:
173
+ parallel:
174
+ - {path: data/wiki_pairs.tsv, columns: {source: complex, simplification: simple}}
175
+ - files: {source: data/train.src, simplification: data/train.tgt} # line-aligned text
176
+ graded:
177
+ - {path: data/levels.csv, min_level_gap: 2}
178
+ ratings:
179
+ - {path: data/human_scores.jsonl, scale: [0, 100]}
180
+ preferences:
181
+ - {hf: some-user/simplification-preferences, split: train}
182
+ validation: {fraction: 0.1} # held out by source sentence; or {path: my_val.tsv}
183
+ monitor: # extra held-out sets reported every epoch
184
+ - {path: data/test_pairs.tsv, kind: pairwise, name: test}
185
+ output_dir: runs/my-simple
186
+ ```
187
+
188
+ ```bash
189
+ simple-score build-data --config my_config.yaml --dry-run # counts of every derived pair type
190
+ simple-score train --config my_config.yaml
191
+ simple-score train --config my_config.yaml --set training.lr=2e-5 # override any value
192
+ torchrun --nproc_per_node=4 -m simple_score.cli train --config my_config.yaml # multi-GPU
193
+ ```
194
+
195
+ `build-data` without `--dry-run` writes the derived pairs as JSONL, so you can check exactly
196
+ what the model will see. A run's output directory holds:
197
+ - `best/`, the checkpoint selected on validation accuracy between simplifications. It
198
+ loads with `SIMPLE.from_pretrained("runs/my-simple/best")`.
199
+ - `final/` and `epoch_N/`.
200
+ - `metrics.jsonl`, `data_stats.json` and the resolved `config.json`.
201
+
202
+ `examples/` holds a runnable toy configuration. All options, with defaults, are in
203
+ [`src/simple_score/training/config.py`](https://github.com/michelepapucci/simple-score/blob/master/src/simple_score/training/config.py) and
204
+ [`src/simple_score/data/builders.py`](https://github.com/michelepapucci/simple-score/blob/master/src/simple_score/data/builders.py).
205
+
206
+ The same steps from Python:
207
+
208
+ ```python
209
+ from simple_score.training import config_from_dict, train
210
+ cfg = config_from_dict({"model": {"backbone": "microsoft/deberta-v3-base"},
211
+ "data": {"parallel": ["pairs.tsv"]}, "output_dir": "runs/x"})
212
+ train(cfg)
213
+ ```
214
+
215
+ ## Reproducing the paper
216
+
217
+ ```bash
218
+ # 1. Rebuild the training data from the original sources (Newsela needs your own license)
219
+ python recipes/paper/build_paper_data.py --newsela-dir /path/to/newsela_data_share-20150302
220
+
221
+ # 2. Train (see the notes in each config)
222
+ simple-score train --config configs/paper/simple-base.yaml
223
+ simple-score train --config configs/ablations/bt-mse.yaml # Appendix A ablations
224
+
225
+ # 3. Evaluate: SIMPLE rows of Table 2 (and Table 5)
226
+ python reproduce/table2.py --model large
227
+ ```
228
+
229
+ The recipe rebuilds the paper's training pairs; the counts match the original build. See
230
+ [`recipes/paper/README.md`](https://github.com/michelepapucci/simple-score/blob/master/recipes/paper/README.md) for the details and for how the
231
+ paper's runs map to the configs.
232
+
233
+ ## Citation
234
+
235
+ Citation will be added upon publication.
236
+
237
+ ## License
238
+
239
+ The code and models are released under the MIT license. The training data is not
240
+ distributed here; each source dataset keeps its own license.
@@ -0,0 +1,202 @@
1
+ # SIMPLE Score: SImplicity Metric via Preference LEarning
2
+
3
+ SIMPLE Score is a **reference-free** learned metric for sentence simplification. For each
4
+ source sentence and candidate simplification it returns:
5
+
6
+ - **`mu`**, a quality score in (-1, 1):
7
+ - **+1**: a highly successful simplification
8
+ - **0**: a verbatim copy of the source
9
+ - **-1**: unrelated or degenerate text
10
+
11
+ Negative scores flag unsuccessful simplifications, including complexifications.
12
+ - **`sigma`**, the model's uncertainty about that score (> 0.05). Low-sigma scores agree
13
+ with human judgements more often, so sigma tells you which scores to double-check.
14
+
15
+ SIMPLE is a DeBERTa-v3 cross-encoder trained on preferences between simplifications
16
+ (Thurstone's model) and calibrated on human quality ratings. This repository has:
17
+
18
+ - the `simple-score` Python package and command line tool;
19
+ - the full training code, which reads plain data files (no dataset-specific code needed);
20
+ - the recipe and configs used to train the paper's models;
21
+ - scripts to reproduce the paper's results.
22
+
23
+ | Model | Hub | SimpEval 2022 pairwise acc. | Pearson | Spearman |
24
+ |---|---|---|---|---|
25
+ | SIMPLE-small | `mpapucci/simple-score-small` | 0.738 | 0.414 | 0.407 |
26
+ | SIMPLE-base | `mpapucci/simple-score-base` | 0.781 | 0.427 | 0.448 |
27
+ | SIMPLE-large | `mpapucci/simple-score-large` | 0.814 | 0.391 | 0.454 |
28
+
29
+ **Try it without installing anything:** the [SIMPLE Score Space](https://huggingface.co/spaces/mpapucci/simple-score)
30
+ runs SIMPLE-small in your browser. The model is downloaded only when you start the demo.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install simple-score # scoring
36
+ pip install "simple-score[train]" # + training
37
+ ```
38
+
39
+ Python ≥ 3.10 is required, and the package works with transformers 4.x and 5.x.
40
+
41
+ ## Scoring
42
+
43
+ ```python
44
+ from simple_score import SIMPLE
45
+
46
+ metric = SIMPLE.from_pretrained("large") # "small", "base", "large", a Hub id or a local dir
47
+ out = metric.score(
48
+ sources=["The feline perched upon the mat in a state of repose."],
49
+ candidates=["The cat sat on the mat."],
50
+ )
51
+ out.mu # [0.82...] quality score per example
52
+ out.sigma # [0.05...] uncertainty per example
53
+ out.mean # corpus-level score
54
+
55
+ # Probability that candidate A is a better simplification than candidate B (Thurstone)
56
+ metric.preference_prob(source, candidate_a, candidate_b)
57
+ ```
58
+
59
+ The model downloads on first use and runs on GPU when one is available
60
+ (`device="cpu"` forces CPU).
61
+
62
+ From the command line:
63
+
64
+ ```bash
65
+ simple-score score --model large --sources src.txt --candidates system.txt --output scores.jsonl
66
+ simple-score score --model base --input outputs.csv # any file with source + candidate columns
67
+ ```
68
+
69
+ With [🤗 Evaluate](https://huggingface.co/docs/evaluate):
70
+
71
+ ```python
72
+ import evaluate
73
+ simple_score = evaluate.load("mpapucci/simple-score", "large")
74
+ simple_score.compute(sources=sources, predictions=predictions) # {"simple_score", "scores", "sigmas"}
75
+ ```
76
+
77
+ ### Reading the scores
78
+
79
+ - **Comparing systems:** compare mean `mu`. Inspect the examples with negative `mu`; they
80
+ are copies, complexifications or broken outputs.
81
+ - **`sigma` is model confidence**, not a measure of human disagreement. Most predictions
82
+ sit near the 0.05 floor. Examples in the high-`sigma` tail deserve a human look.
83
+ - **Scope:** SIMPLE is trained on English, sentence-level news and Wikipedia
84
+ simplification. It is less reliable on rewrites that mostly add or elaborate content.
85
+
86
+ ## Training on your own data
87
+
88
+ The data can't be redistributed, so the training code makes no assumptions about where it
89
+ came from. You list your files by **what kind of data they hold**, and SIMPLE derives the
90
+ training signal described in the paper:
91
+
92
+ | kind | columns | what SIMPLE derives |
93
+ |---|---|---|
94
+ | `parallel` | `source`, `simplification` | simplification ≻ source; a mirror pair (copying the simple sentence ≻ complexifying it); simplification ≻ unrelated sentence |
95
+ | `graded` | `source`, `simplification`, `level` (higher = simpler), optional `group` | as `parallel`, plus more-simplified ≻ less-simplified for the same source |
96
+ | `ratings` | `source`, `candidate`, `rating` (+ the rating scale) | regression targets on (-1, 1); human-preference pairs with rating margins; copy, flipped and unrelated anchors |
97
+ | `preferences` | `source`, `chosen`, `rejected`, optional `margin`, `weight`, `type` | used as given |
98
+
99
+ **Supported files**
100
+ - Formats: `.jsonl`, `.json`, `.csv`, `.tsv` (quotes allowed in sentences), `.parquet`, gzipped
101
+ versions of these, line-aligned `.txt` files, or a Hugging Face Hub dataset.
102
+ - Column names: common aliases are recognised (`original`, `complex`, `simple`, `score`,
103
+ `positive`/`negative`, …). Anything else can be mapped explicitly.
104
+
105
+ In addition, synthetic regression anchors teach the bottom half of the scale. They come
106
+ from your training sentences: copies score 0, shuffled/truncated/word-dropped sentences
107
+ score between −0.8 and −0.4, and unrelated sentences score −1.
108
+
109
+ **Which kinds do you need?** Any one is enough to start.
110
+ - A parallel corpus alone gives a metric that knows the direction of simplification and
111
+ rejects degenerate outputs.
112
+ - Human ratings calibrate the scale and give the best agreement with human judgements.
113
+
114
+ ### Quick start, no config file
115
+
116
+ ```bash
117
+ simple-score train \
118
+ --parallel my_corpus.tsv \
119
+ --ratings my_ratings.csv --rating-scale 1 5 \
120
+ --backbone microsoft/deberta-v3-base \
121
+ --output-dir runs/my-simple
122
+ ```
123
+
124
+ ### With a config file
125
+
126
+ ```yaml
127
+ # my_config.yaml
128
+ model:
129
+ backbone: microsoft/deberta-v3-base
130
+ training:
131
+ epochs: 5
132
+ batch_size: 16
133
+ lr: 1.0e-5
134
+ data:
135
+ parallel:
136
+ - {path: data/wiki_pairs.tsv, columns: {source: complex, simplification: simple}}
137
+ - files: {source: data/train.src, simplification: data/train.tgt} # line-aligned text
138
+ graded:
139
+ - {path: data/levels.csv, min_level_gap: 2}
140
+ ratings:
141
+ - {path: data/human_scores.jsonl, scale: [0, 100]}
142
+ preferences:
143
+ - {hf: some-user/simplification-preferences, split: train}
144
+ validation: {fraction: 0.1} # held out by source sentence; or {path: my_val.tsv}
145
+ monitor: # extra held-out sets reported every epoch
146
+ - {path: data/test_pairs.tsv, kind: pairwise, name: test}
147
+ output_dir: runs/my-simple
148
+ ```
149
+
150
+ ```bash
151
+ simple-score build-data --config my_config.yaml --dry-run # counts of every derived pair type
152
+ simple-score train --config my_config.yaml
153
+ simple-score train --config my_config.yaml --set training.lr=2e-5 # override any value
154
+ torchrun --nproc_per_node=4 -m simple_score.cli train --config my_config.yaml # multi-GPU
155
+ ```
156
+
157
+ `build-data` without `--dry-run` writes the derived pairs as JSONL, so you can check exactly
158
+ what the model will see. A run's output directory holds:
159
+ - `best/`, the checkpoint selected on validation accuracy between simplifications. It
160
+ loads with `SIMPLE.from_pretrained("runs/my-simple/best")`.
161
+ - `final/` and `epoch_N/`.
162
+ - `metrics.jsonl`, `data_stats.json` and the resolved `config.json`.
163
+
164
+ `examples/` holds a runnable toy configuration. All options, with defaults, are in
165
+ [`src/simple_score/training/config.py`](https://github.com/michelepapucci/simple-score/blob/master/src/simple_score/training/config.py) and
166
+ [`src/simple_score/data/builders.py`](https://github.com/michelepapucci/simple-score/blob/master/src/simple_score/data/builders.py).
167
+
168
+ The same steps from Python:
169
+
170
+ ```python
171
+ from simple_score.training import config_from_dict, train
172
+ cfg = config_from_dict({"model": {"backbone": "microsoft/deberta-v3-base"},
173
+ "data": {"parallel": ["pairs.tsv"]}, "output_dir": "runs/x"})
174
+ train(cfg)
175
+ ```
176
+
177
+ ## Reproducing the paper
178
+
179
+ ```bash
180
+ # 1. Rebuild the training data from the original sources (Newsela needs your own license)
181
+ python recipes/paper/build_paper_data.py --newsela-dir /path/to/newsela_data_share-20150302
182
+
183
+ # 2. Train (see the notes in each config)
184
+ simple-score train --config configs/paper/simple-base.yaml
185
+ simple-score train --config configs/ablations/bt-mse.yaml # Appendix A ablations
186
+
187
+ # 3. Evaluate: SIMPLE rows of Table 2 (and Table 5)
188
+ python reproduce/table2.py --model large
189
+ ```
190
+
191
+ The recipe rebuilds the paper's training pairs; the counts match the original build. See
192
+ [`recipes/paper/README.md`](https://github.com/michelepapucci/simple-score/blob/master/recipes/paper/README.md) for the details and for how the
193
+ paper's runs map to the configs.
194
+
195
+ ## Citation
196
+
197
+ Citation will be added upon publication.
198
+
199
+ ## License
200
+
201
+ The code and models are released under the MIT license. The training data is not
202
+ distributed here; each source dataset keeps its own license.
@@ -0,0 +1,60 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "simple-score"
7
+ dynamic = ["version"]
8
+ description = "SIMPLE Score: a reference-free learned metric for text simplification that also reports its own uncertainty."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Michele Papucci" }]
14
+ keywords = ["text simplification", "evaluation", "metric", "nlp", "preference learning"]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Intended Audience :: Science/Research",
18
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
19
+ "Topic :: Text Processing :: Linguistic",
20
+ ]
21
+ dependencies = [
22
+ "torch>=1.13",
23
+ "transformers>=4.38",
24
+ "huggingface_hub>=0.20",
25
+ "safetensors>=0.4",
26
+ "numpy",
27
+ "tqdm",
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ # Training needs YAML configs, and the slow->fast tokenizer conversion of the
32
+ # Hub DeBERTa-v3 backbones needs sentencepiece + protobuf.
33
+ train = ["pyyaml>=6.0", "sentencepiece", "protobuf"]
34
+ # Optional readers: Parquet files and Hugging Face Hub datasets.
35
+ data = ["pyarrow", "datasets"]
36
+ dev = ["pytest", "ruff", "build", "pyyaml>=6.0", "sentencepiece", "protobuf"]
37
+
38
+ [project.scripts]
39
+ simple-score = "simple_score.cli:main"
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/michelepapucci/simple-score"
43
+ Models = "https://huggingface.co/mpapucci"
44
+
45
+ [tool.setuptools.dynamic]
46
+ version = { attr = "simple_score._version.__version__" }
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["src"]
50
+
51
+ [tool.ruff]
52
+ line-length = 100
53
+ target-version = "py310"
54
+
55
+ [tool.ruff.lint]
56
+ select = ["E", "F", "W", "I", "B", "UP"]
57
+ ignore = ["E501", "B905"]
58
+
59
+ [tool.pytest.ini_options]
60
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,34 @@
1
+ """SIMPLE Score: SImplicity Metric via Preference LEarning.
2
+
3
+ A reference-free learned metric for text simplification. For each (source, candidate)
4
+ pair it returns a quality score ``mu`` in (-1, 1) and the model's uncertainty ``sigma``.
5
+
6
+ >>> from simple_score import SIMPLE
7
+ >>> metric = SIMPLE.from_pretrained("large")
8
+ >>> metric.score(["The feline perched upon the mat."], ["The cat sat on the mat."])
9
+ """
10
+
11
+ from ._version import __version__
12
+ from .losses import (
13
+ bradley_terry_loss,
14
+ gaussian_nll_loss,
15
+ mse_loss,
16
+ preference_probability,
17
+ thurstone_loss,
18
+ )
19
+ from .modeling import SimpleConfig, SimpleModel
20
+ from .scorer import SIMPLE, ScoreOutput, load
21
+
22
+ __all__ = [
23
+ "SIMPLE",
24
+ "ScoreOutput",
25
+ "SimpleConfig",
26
+ "SimpleModel",
27
+ "__version__",
28
+ "bradley_terry_loss",
29
+ "gaussian_nll_loss",
30
+ "load",
31
+ "mse_loss",
32
+ "preference_probability",
33
+ "thurstone_loss",
34
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"