Downloads · 30 days
13
16% of all-time downloads
LucasLicht/religion-bert
religion-bert is a fill-mask model from LucasLicht. Use it when you need the model to fill a missing word. It is set up for transformers. The card lists the license as apache-2.0.
ReligionBERT is a domain-adapted BERT model produced by continued masked language modelling (MLM) pre-training on the English Bible corpus. Starting from bert-base-uncased, the model was trained for 30,000 steps on 62…
Downloads · 30 days
13
16% of all-time downloads
All-time downloads
80
Public
Parameters
110M
438 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
ReligionBERT is a domain-adapted BERT model produced by continued masked language modelling (MLM) pre-training on the English Bible corpus. Starting from bert-base-uncased, the model was trained for 30,000 steps on 62,197 verses drawn from the King James Version and World English Bible translations. It is designed for downstream NLP tasks involving religious and biblical text, where general-purpose BERT models underperform due to archaic language, theological vocabulary, and long-range intertextual dependencies.
A companion multilingual model, MultiReligionBERT, covers 12 languages and supports cross-lingual zero-shot transfer for African language religious NLP.
| Field | Details |
|---|---|
| Model type | BERT (encoder-only, masked language model) |
| Base model | bert-base-uncased (109M parameters) |
| Pre-training objective | Continued MLM (15% token masking) |
| Pre-training corpus | English Bible (KJV + WEB), 62,197 verses |
| Training steps | 30,000 |
| Final validation loss | 1.164 |
| Language | English |
| License | Apache 2.0 |
| Developed by | Lucas Licht |
| Institution | Koforidua Technical University, Ghana |
ReligionBERT is intended for NLP tasks on religious and biblical text, including:
It is not recommended for general-domain NLP tasks where bert-base-uncased is likely a stronger baseline.
from transformers import AutoTokenizer, AutoModelForMaskedLM
import torch
tokenizer = AutoTokenizer.from_pretrained("LucasLicht/religion-bert")
model = AutoModelForMaskedLM.from_pretrained("LucasLicht/religion-bert")
text = "For God so loved the [MASK] that he gave his only begotten Son."
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
masked_index = (inputs["input_ids"] == tokenizer.mask_token_id).nonzero(as_tuple=True)[1]
logits = outputs.logits[0, masked_index]
predicted_token = tokenizer.decode(torch.argmax(logits, dim=-1))
print(predicted_token) # "world"
For sentence embeddings or downstream fine-tuning:
from transformers import AutoTokenizer, AutoModel
import torch
tokenizer = AutoTokenizer.from_pretrained("LucasLicht/religion-bert")
model = AutoModel.from_pretrained("LucasLicht/religion-bert")
inputs = tokenizer("The Lord is my shepherd; I shall not want.", return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
# Use CLS token as sentence representation
cls_embedding = outputs.last_hidden_state[:, 0, :]
The corpus was sourced from the christos-c/bible-corpus repository. All 66 books of the King James Version and World English Bible translations were extracted via XML parsing, yielding 62,197 verses.
| Hyperparameter | Value |
|---|---|
| Base model | bert-base-uncased |
| Training steps | 30,000 |
| Effective batch size | 32 (16 per device, 2 gradient accumulation steps) |
| Learning rate | 3e-5 (linear warmup, 500 steps) |
| Weight decay | 0.01 (AdamW) |
| MLM masking probability | 15% |
| Max sequence length | 128 tokens |
| Precision | FP16 mixed precision |
| Hardware | NVIDIA Tesla T4 / A100 (Google Colab) |
| Framework | HuggingFace Transformers 5.0.0 |
Training was conducted across multiple sessions with checkpoint recovery. A PermanentDeleteCallback retained only the two most recent checkpoints to prevent storage exhaustion. All metrics were logged to Weights and Biases.
| Step | Validation Loss |
|---|---|
| 500 | 1.806 |
| 5,000 | 1.451 |
| 10,000 | 1.339 |
| 15,000 | 1.272 |
| 20,000 | 1.204 |
| 25,000 | 1.156 |
| 28,500 | 1.129 (best) |
| 30,000 | 1.164 (final) |
Perplexity was computed on 500 held-out English Bible verses not seen during pre-training.
| Model | Perplexity (lower is better) |
|---|---|
bert-base-uncased | 15.48 |
| ReligionBERT | 3.73 |
ReligionBERT achieves a 75.9% reduction in perplexity, confirming successful domain alignment.
Three fine-tuning tasks were evaluated using three automatically constructed datasets. All results are on held-out test sets. ReligionBERT is compared to its generic baseline (bert-base-uncased).
| Model | Pearson | Spearman |
|---|---|---|
| bert-base-uncased | 0.9569 | 0.6556 |
| ReligionBERT | 0.9623 | 0.6591 |
| Model | Accuracy | Macro F1 |
|---|---|---|
| bert-base-uncased | 0.4075 | 0.3144 |
| ReligionBERT | 0.4347 | 0.3381 |
| Model | Exact Match (%) | Token F1 (%) |
|---|---|---|
| bert-base-uncased | 32.50 | 58.91 |
| ReligionBERT | 40.00 | 60.48 |
ReligionBERT outperforms bert-base-uncased on 5 of 6 metrics, with the strongest gain of +7.50 Exact Match points on extractive QA.
The three fine-tuning datasets used in this study are described below. They are derived automatically from the Bible corpus without manual annotation (except for the QA human verification step).
| Dataset | Task | Size | Notes |
|---|---|---|---|
| Verse Similarity | Semantic similarity (STS) | 21,994 pairs | Cross-translation and intra-corpus pairs; balanced subset 6,392 |
| Bible Book Classification | Text classification | 7,726 samples | 66 classes (all Bible books); 80/10/10 split |
| Bible QA | Extractive QA | 1,199 examples | LLM-assisted via Llama 3.3 70B; SQuAD v2 format; 100% human-verified quality |
bert-base-uncased and may reflect theological perspectives embedded in the King James Version.If you use this model, please cite:
@misc{licht2025religionbert,
title = {ReligionBERT: Domain-Adaptive Pre-Training of BERT on Biblical Corpora for Religious NLP Tasks},
author = {Licht, Lucas},
year = {2025},
note = {Koforidua Technical University, Ghana. Model available at https://huggingface.co/LucasLicht/religion-bert}
}
For questions or collaboration, reach out via HuggingFace or GitHub: @Licht005