LoveJesus commited on
Commit
95e2c58
·
verified ·
1 Parent(s): c6c13bb

Add model card

Browse files
Files changed (1) hide show
  1. README.md +336 -0
README.md ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ # For God so loved the world that he gave his only begotten Son,
3
+ # that whoever believes in him should not perish but have eternal life. - John 3:16
4
+ license: mit
5
+ language:
6
+ - en
7
+ tags:
8
+ - text2text-generation
9
+ - flan-t5
10
+ - bible
11
+ - simplification
12
+ - readability
13
+ - difficulty-scoring
14
+ - multi-task
15
+ - seq2seq
16
+ datasets:
17
+ - LoveJesus/passage-difficulty-simplifier-dataset-chirho
18
+ pipeline_tag: text2text-generation
19
+ base_model: google/flan-t5-small
20
+ model-index:
21
+ - name: passage-difficulty-simplifier-chirho
22
+ results: []
23
+ ---
24
+
25
+ # Passage Difficulty Scorer & Plain-Language Simplifier (Model 8)
26
+
27
+ A fine-tuned **google/flan-t5-small** (80M parameters) for dual-task Bible passage processing: (1) reading difficulty scoring and (2) archaic-to-modern English simplification. Both tasks are learned jointly through multi-task training on the same model.
28
+
29
+ ## Model Description
30
+
31
+ This model takes Bible passages as input and performs one of two tasks, selected by a natural language prefix:
32
+
33
+ ### Task 1: Difficulty Scoring
34
+
35
+ Analyzes a Bible passage and produces a structured difficulty assessment.
36
+
37
+ - **Prefix**: `rate difficulty:`
38
+ - **Output format**: `reading_level: [1-12] | vocab_complexity: [low/medium/high] | archaic_forms: [count] | difficulty: [easy/medium/hard]`
39
+
40
+ ### Task 2: Simplification
41
+
42
+ Converts archaic or complex Bible passages into plain modern English.
43
+
44
+ - **Prefix**: `simplify:`
45
+ - **Output**: Plain-language paraphrase of the input verse
46
+
47
+ ## Training Details
48
+
49
+ | Parameter | Value |
50
+ |---|---|
51
+ | **Base model** | `google/flan-t5-small` (80M params) |
52
+ | **Architecture** | Encoder-Decoder (T5) |
53
+ | **Training approach** | Full fine-tuning, multi-task |
54
+ | **Trainer** | `Seq2SeqTrainer` with `DataCollatorForSeq2Seq` |
55
+ | **Epochs** | 5 |
56
+ | **Batch size** | 32 (A100 GPU) |
57
+ | **Effective batch size** | 32 (gradient accumulation = 1 on A100) |
58
+ | **Learning rate** | 3e-4 |
59
+ | **LR scheduler** | Cosine with 10% warmup |
60
+ | **Weight decay** | 0.01 |
61
+ | **Label smoothing** | 0.1 |
62
+ | **Mixed precision** | bf16 (A100) |
63
+ | **Max input length** | 256 tokens |
64
+ | **Max target length** | 256 tokens |
65
+ | **Early stopping** | Patience = 2, monitoring `eval_loss` |
66
+ | **Best model selection** | Lowest `eval_loss` |
67
+ | **Generation (eval)** | `predict_with_generate=True`, beam search |
68
+
69
+ ### Dataset
70
+
71
+ Trained on approximately **120K+ examples** combining both tasks, split by Bible book to prevent verse-level leakage (80/10/10 by book):
72
+
73
+ | Task | Target Count | Description |
74
+ |---|---|---|
75
+ | Difficulty scoring | ~64K | Verses from 6 translations with algorithmically computed labels |
76
+ | Simplification | ~96K | Cross-translation pairs mapping complex to simple English |
77
+
78
+ #### Translations Used
79
+
80
+ | Translation | Style | Role |
81
+ |---|---|---|
82
+ | KJV (King James Version) | Formal, archaic | Complex source |
83
+ | ASV (American Standard Version) | Formal, dated | Complex source |
84
+ | YLT (Young's Literal Translation) | Ultra-literal | Complex source |
85
+ | Darby Bible | Literal, dated | Complex source / Difficulty scoring |
86
+ | BBE (Bible in Basic English) | 850-word vocabulary, ~Grade 4 | Simple target |
87
+ | OEB (Open English Bible) | Modern, public domain | Simple target |
88
+
89
+ #### Simplification Pairs
90
+
91
+ | Complex Source | Simple Target |
92
+ |---|---|
93
+ | KJV | BBE |
94
+ | KJV | OEB |
95
+ | ASV | BBE |
96
+ | YLT | OEB |
97
+
98
+ #### Data Source
99
+
100
+ Bible text sourced from **ScrollMapper Bible Databases** (public domain translations on GitHub).
101
+
102
+ #### Difficulty Scoring Labels
103
+
104
+ Labels are computed algorithmically from textual features:
105
+
106
+ - **Reading level** (1-12): Approximate Flesch-Kincaid grade level analog, adjusted for archaic vocabulary and uncommon word ratio
107
+ - **Vocabulary complexity** (low/medium/high): Ratio of words outside a ~3,000-word common English vocabulary
108
+ - **Archaic forms** (count): Number of archaic English words detected (thee, thou, hath, doth, -eth/-est verb endings, etc.)
109
+ - **Difficulty** (easy/medium/hard): Composite score from reading level, vocabulary complexity, and archaic form count
110
+
111
+ ## Usage
112
+
113
+ ### Quick Start: Simplification
114
+
115
+ ```python
116
+ # For God so loved the world that he gave his only begotten Son,
117
+ # that whoever believes in him should not perish but have eternal life. - John 3:16
118
+
119
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
120
+
121
+ tokenizer_chirho = AutoTokenizer.from_pretrained("LoveJesus/passage-difficulty-simplifier-chirho")
122
+ model_chirho = AutoModelForSeq2SeqLM.from_pretrained("LoveJesus/passage-difficulty-simplifier-chirho")
123
+
124
+ input_text_chirho = "simplify: And the LORD God formed man of the dust of the ground, and breathed into his nostrils the breath of life; and man became a living soul."
125
+
126
+ inputs_chirho = tokenizer_chirho(input_text_chirho, return_tensors="pt", max_length=256, truncation=True)
127
+ outputs_chirho = model_chirho.generate(**inputs_chirho, max_length=256, num_beams=4, early_stopping=True)
128
+ result_chirho = tokenizer_chirho.decode(outputs_chirho[0], skip_special_tokens=True)
129
+
130
+ print(result_chirho)
131
+ # Expected: A simplified, modern English version of the verse
132
+ ```
133
+
134
+ ### Quick Start: Difficulty Scoring
135
+
136
+ ```python
137
+ # For God so loved the world that he gave his only begotten Son,
138
+ # that whoever believes in him should not perish but have eternal life. - John 3:16
139
+
140
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
141
+ import re
142
+
143
+ tokenizer_chirho = AutoTokenizer.from_pretrained("LoveJesus/passage-difficulty-simplifier-chirho")
144
+ model_chirho = AutoModelForSeq2SeqLM.from_pretrained("LoveJesus/passage-difficulty-simplifier-chirho")
145
+
146
+ input_text_chirho = "rate difficulty: For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
147
+
148
+ inputs_chirho = tokenizer_chirho(input_text_chirho, return_tensors="pt", max_length=256, truncation=True)
149
+ outputs_chirho = model_chirho.generate(**inputs_chirho, max_length=256, num_beams=4, early_stopping=True)
150
+ raw_output_chirho = tokenizer_chirho.decode(outputs_chirho[0], skip_special_tokens=True)
151
+
152
+ print(raw_output_chirho)
153
+ # Expected: "reading_level: X | vocab_complexity: Y | archaic_forms: Z | difficulty: W"
154
+
155
+ # Parse structured output
156
+ reading_level_chirho = re.search(r"reading_level:\s*(\d+)", raw_output_chirho)
157
+ difficulty_chirho = re.search(r"difficulty:\s*(\w+)", raw_output_chirho)
158
+ vocab_chirho = re.search(r"vocab_complexity:\s*(\w+)", raw_output_chirho)
159
+ archaic_chirho = re.search(r"archaic_forms:\s*(\d+)", raw_output_chirho)
160
+
161
+ if reading_level_chirho:
162
+ print(f"Reading Level: Grade {reading_level_chirho.group(1)}")
163
+ if difficulty_chirho:
164
+ print(f"Difficulty: {difficulty_chirho.group(1)}")
165
+ if vocab_chirho:
166
+ print(f"Vocabulary Complexity: {vocab_chirho.group(1)}")
167
+ if archaic_chirho:
168
+ print(f"Archaic Forms: {archaic_chirho.group(1)}")
169
+ ```
170
+
171
+ ### Batch Inference
172
+
173
+ ```python
174
+ # For God so loved the world that he gave his only begotten Son,
175
+ # that whoever believes in him should not perish but have eternal life. - John 3:16
176
+
177
+ import torch
178
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
179
+
180
+ tokenizer_chirho = AutoTokenizer.from_pretrained("LoveJesus/passage-difficulty-simplifier-chirho")
181
+ model_chirho = AutoModelForSeq2SeqLM.from_pretrained("LoveJesus/passage-difficulty-simplifier-chirho")
182
+ model_chirho.eval()
183
+
184
+ verses_chirho = [
185
+ "simplify: Verily, verily, I say unto thee, Except a man be born again, he cannot see the kingdom of God.",
186
+ "simplify: Wherefore, as by one man sin entered into the world, and death by sin; and so death passed upon all men, for that all have sinned:",
187
+ "rate difficulty: In the beginning God created the heaven and the earth.",
188
+ "rate difficulty: Jesus wept.",
189
+ ]
190
+
191
+ inputs_chirho = tokenizer_chirho(verses_chirho, return_tensors="pt", max_length=256, truncation=True, padding=True)
192
+
193
+ with torch.no_grad():
194
+ outputs_chirho = model_chirho.generate(**inputs_chirho, max_length=256, num_beams=4, early_stopping=True)
195
+
196
+ results_chirho = tokenizer_chirho.batch_decode(outputs_chirho, skip_special_tokens=True)
197
+
198
+ for verse_chirho, result_chirho in zip(verses_chirho, results_chirho):
199
+ print(f"Input: {verse_chirho}")
200
+ print(f"Output: {result_chirho}\n")
201
+ ```
202
+
203
+ ## Evaluation
204
+
205
+ ### Metrics
206
+
207
+ | Task | Metric | Description |
208
+ |---|---|---|
209
+ | Difficulty Scoring | `difficulty_accuracy_chirho` | Exact match on easy/medium/hard label |
210
+ | Difficulty Scoring | Reading level MAE | Mean absolute error on grade level (1-12) |
211
+ | Difficulty Scoring | Vocab complexity accuracy | Exact match on low/medium/high |
212
+ | Simplification | BLEU | Corpus-level BLEU score (sacrebleu) |
213
+ | Simplification | BERTScore F1 | Semantic similarity to reference simplifications |
214
+ | Simplification | Exact match | Proportion of predictions matching reference exactly |
215
+ | Combined | `combined_score_chirho` | 0.4 * difficulty_accuracy + 0.6 * simplification_exact_match |
216
+
217
+ ### Results
218
+
219
+ > **Note**: This model is currently training. Evaluation metrics will be updated once training completes.
220
+
221
+ | Metric | Score |
222
+ |---|---|
223
+ | Eval loss | TBD |
224
+ | Difficulty accuracy | TBD |
225
+ | Simplification BLEU | TBD |
226
+ | BERTScore F1 | TBD |
227
+ | Combined score | TBD |
228
+
229
+ **Targets** (from config):
230
+ - BLEU >= 30
231
+ - BERTScore F1 >= 0.85
232
+
233
+ ## Try It Live
234
+
235
+ **[Interactive Demo on HuggingFace Spaces](https://huggingface.co/spaces/LoveJesus/passage-difficulty-simplifier-chirho)**
236
+
237
+ The Gradio-powered demo provides two tabs:
238
+ - **Simplify**: Enter any Bible verse and receive a plain-language version
239
+ - **Difficulty**: Enter a verse and get reading level, vocabulary complexity, archaic form count, and overall difficulty
240
+
241
+ ## Limitations
242
+
243
+ - Trained exclusively on Bible text; does not generalize to other literary or domain-specific texts
244
+ - Simplification quality varies by verse length and complexity; very long passages may be truncated
245
+ - Difficulty scoring labels are algorithmically generated (not human-annotated), which introduces systematic biases
246
+ - Small model (80M params) trades accuracy for speed and accessibility
247
+ - Simplification targets (BBE, OEB) have their own translation biases; outputs reflect those stylistic choices
248
+ - Archaic form detection relies on a fixed word list and may miss uncommon archaic constructions
249
+ - The model does not preserve verse references or theological nuance; it is a readability tool, not a study Bible
250
+
251
+ ## Intended Use
252
+
253
+ - Bible study tools that need plain-language paraphrasing of archaic translations
254
+ - Reading level assessment for curriculum planning or children's ministry materials
255
+ - Accessibility applications that present Bible text at appropriate reading levels
256
+ - Research into text simplification for historical English
257
+
258
+ ## Out-of-Scope Use
259
+
260
+ - Replacing authoritative Bible translations for doctrinal study
261
+ - General-purpose text simplification outside of biblical literature
262
+ - Machine translation between languages (this model operates only in English)
263
+
264
+ ## Model Architecture
265
+
266
+ ```
267
+ google/flan-t5-small (Encoder-Decoder)
268
+ Encoder: 6 layers, 8 heads, d_model=512
269
+ Decoder: 6 layers, 8 heads, d_model=512
270
+ Total parameters: ~80M (all trainable, full fine-tuning)
271
+ Vocabulary: SentencePiece, 32,128 tokens
272
+ ```
273
+
274
+ ## Repository Structure
275
+
276
+ ```
277
+ passage-difficulty-simplifier-chirho/
278
+ src-chirho/
279
+ train-chirho/train-simplifier-chirho.py # Training script
280
+ eval-chirho/evaluate-chirho.py # Evaluation script
281
+ data-chirho/build-simplifier-dataset-chirho.ts # Dataset builder (Bun/TS)
282
+ data-chirho/download-translations-chirho.ts # Translation downloader
283
+ upload-hf-chirho.py # HuggingFace upload script
284
+ space-chirho/
285
+ app.py # Gradio demo application
286
+ data-chirho/
287
+ raw-chirho/ # Raw Bible CSVs
288
+ processed-chirho/ # JSONL train/val/test splits
289
+ models-chirho/
290
+ simplifier-chirho/best-chirho/ # Best checkpoint
291
+ cards-chirho/
292
+ simplifier-card-chirho.md # This model card
293
+ config-chirho.yaml # Training configuration
294
+ spec-chirho/
295
+ progress-chirho.sqlite # Agent progress log
296
+ ```
297
+
298
+ ## Training Reproducibility
299
+
300
+ ```bash
301
+ # 1. Download Bible translations
302
+ cd passage-difficulty-simplifier-chirho
303
+ bun run src-chirho/data-chirho/download-translations-chirho.ts
304
+
305
+ # 2. Build dual-task dataset
306
+ bun run src-chirho/data-chirho/build-simplifier-dataset-chirho.ts
307
+
308
+ # 3. Train model
309
+ python src-chirho/train-chirho/train-simplifier-chirho.py
310
+
311
+ # 4. Evaluate
312
+ python src-chirho/eval-chirho/evaluate-chirho.py
313
+
314
+ # 5. Upload to HuggingFace
315
+ python src-chirho/upload-hf-chirho.py
316
+ ```
317
+
318
+ ## License
319
+
320
+ MIT
321
+
322
+ ## Citation
323
+
324
+ ```bibtex
325
+ @misc{lovejesus2026passagedifficultysimplifier,
326
+ title={Passage Difficulty Scorer & Plain-Language Simplifier: Multi-Task Flan-T5 for Bible Readability},
327
+ author={loveJesus},
328
+ year={2026},
329
+ publisher={HuggingFace},
330
+ url={https://huggingface.co/LoveJesus/passage-difficulty-simplifier-chirho}
331
+ }
332
+ ```
333
+
334
+ ---
335
+
336
+ Built with love for Jesus. Published by [loveJesus](https://huggingface.co/LoveJesus).