Text Classification
Transformers
Safetensors
English
distilbert
ethics
ai-ethics
education
Eval Results (legacy)
text-embeddings-inference
Instructions to use nexageapps/EthicsBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nexageapps/EthicsBERT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="nexageapps/EthicsBERT")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("nexageapps/EthicsBERT") model = AutoModelForSequenceClassification.from_pretrained("nexageapps/EthicsBERT", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload EthicsBERT fine-tuned DistilBERT model
Browse files- README.md +144 -1
- config.json +46 -0
- label_mapping.json +24 -0
- model.safetensors +3 -0
- special_tokens_map.json +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +56 -0
- vocab.txt +0 -0
README.md
CHANGED
|
@@ -1,3 +1,146 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
library_name: transformers
|
| 5 |
+
tags:
|
| 6 |
+
- text-classification
|
| 7 |
+
- ethics
|
| 8 |
+
- ai-ethics
|
| 9 |
+
- distilbert
|
| 10 |
+
- education
|
| 11 |
+
datasets:
|
| 12 |
+
- custom
|
| 13 |
+
metrics:
|
| 14 |
+
- accuracy
|
| 15 |
+
- f1
|
| 16 |
+
pipeline_tag: text-classification
|
| 17 |
+
model-index:
|
| 18 |
+
- name: EthicsBERT
|
| 19 |
+
results:
|
| 20 |
+
- task:
|
| 21 |
+
type: text-classification
|
| 22 |
+
name: Text Classification
|
| 23 |
+
metrics:
|
| 24 |
+
- type: accuracy
|
| 25 |
+
name: Accuracy
|
| 26 |
+
value: 0.7838
|
| 27 |
+
- type: f1
|
| 28 |
+
name: F1 (weighted)
|
| 29 |
+
value: 0.7810
|
| 30 |
---
|
| 31 |
+
|
| 32 |
+
# EthicsBERT
|
| 33 |
+
|
| 34 |
+
**EthicsBERT** is a fine-tuned [DistilBERT](https://huggingface.co/distilbert-base-uncased)
|
| 35 |
+
model for classifying AI ethics course content into nine topic areas. It is designed to
|
| 36 |
+
support educators, researchers, and curriculum designers working in AI ethics.
|
| 37 |
+
|
| 38 |
+
## Labels
|
| 39 |
+
|
| 40 |
+
| ID | Label | Description |
|
| 41 |
+
|----|-------|-------------|
|
| 42 |
+
| 0 | **Agency** | Human control, override rights, autonomy-preserving design, and delegated authority. |
|
| 43 |
+
| 1 | **AI Governance** | Regulation, accountability, audits, policy frameworks, and existential risk oversight. |
|
| 44 |
+
| 2 | **Bias** | Systematic errors, skewed training data, unfair representations, and proxy discrimination. |
|
| 45 |
+
| 3 | **Consciousness** | Machine sentience, subjective experience, philosophical debates, and moral patienthood. |
|
| 46 |
+
| 4 | **Ethical Reasoning** | Moral frameworks (utilitarian, deontological, virtue), dilemmas, and applied ethics. |
|
| 47 |
+
| 5 | **Explainability** | Interpretability, SHAP/LIME, attention visualization, and model transparency. |
|
| 48 |
+
| 6 | **Fairness** | Equitable outcomes, anti-discrimination, group/individual fairness metrics. |
|
| 49 |
+
| 7 | **Intelligence** | Cognitive capabilities, reasoning, transfer learning, AGI, and benchmarks. |
|
| 50 |
+
| 8 | **Privacy** | Data protection, consent, PII handling, differential privacy, and encryption. |
|
| 51 |
+
|
| 52 |
+
## Model Details
|
| 53 |
+
|
| 54 |
+
| Property | Value |
|
| 55 |
+
|----------|-------|
|
| 56 |
+
| Base model | `distilbert-base-uncased` |
|
| 57 |
+
| Architecture | DistilBERT + classification head |
|
| 58 |
+
| Task | Multi-class text classification (9 classes) |
|
| 59 |
+
| Max sequence length | 128 tokens |
|
| 60 |
+
| Training epochs | 5 (with early stopping) |
|
| 61 |
+
| Optimizer | AdamW |
|
| 62 |
+
| Learning rate | 2e-5 |
|
| 63 |
+
| Weight decay | 0.01 |
|
| 64 |
+
| Warmup ratio | 0.1 |
|
| 65 |
+
|
| 66 |
+
## Usage
|
| 67 |
+
|
| 68 |
+
### With the `pipeline` API (simplest)
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
from transformers import pipeline
|
| 72 |
+
|
| 73 |
+
classifier = pipeline(
|
| 74 |
+
"text-classification",
|
| 75 |
+
model="nexageapps/EthicsBERT",
|
| 76 |
+
top_k=3,
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
result = classifier("The hiring algorithm must produce equal outcomes across demographic groups.")
|
| 80 |
+
# [{'label': 'Fairness', 'score': 0.92}, ...]
|
| 81 |
+
print(result)
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
### Direct usage
|
| 85 |
+
|
| 86 |
+
```python
|
| 87 |
+
import torch
|
| 88 |
+
import torch.nn.functional as F
|
| 89 |
+
from transformers import DistilBertForSequenceClassification, DistilBertTokenizerFast
|
| 90 |
+
|
| 91 |
+
model_id = "nexageapps/EthicsBERT"
|
| 92 |
+
tokenizer = DistilBertTokenizerFast.from_pretrained(model_id)
|
| 93 |
+
model = DistilBertForSequenceClassification.from_pretrained(model_id)
|
| 94 |
+
model.eval()
|
| 95 |
+
|
| 96 |
+
text = "SHAP values quantify each feature's contribution to a specific model prediction."
|
| 97 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
|
| 98 |
+
|
| 99 |
+
with torch.no_grad():
|
| 100 |
+
logits = model(**inputs).logits
|
| 101 |
+
probs = F.softmax(logits, dim=-1)
|
| 102 |
+
|
| 103 |
+
id2label = model.config.id2label
|
| 104 |
+
predicted_label = id2label[int(probs.argmax())]
|
| 105 |
+
print(f"Predicted: {predicted_label} ({probs.max().item():.2%})")
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
## Training Data
|
| 109 |
+
|
| 110 |
+
The model was fine-tuned on a curated dataset of approximately 200 sentences covering
|
| 111 |
+
all nine AI ethics topic areas. Sentences were authored to reflect the vocabulary,
|
| 112 |
+
framing, and conceptual depth typical of AI ethics course materials.
|
| 113 |
+
|
| 114 |
+
**Label distribution:** roughly balanced, ~20–25 examples per class.
|
| 115 |
+
|
| 116 |
+
## Limitations
|
| 117 |
+
|
| 118 |
+
- The training dataset is small (~200 examples). Performance may degrade on highly
|
| 119 |
+
technical or domain-specific text not represented in training.
|
| 120 |
+
- The model was trained on English only.
|
| 121 |
+
- Boundary cases between semantically similar labels (e.g., *Fairness* vs *Bias*,
|
| 122 |
+
or *AI Governance* vs *Ethical Reasoning*) may be misclassified.
|
| 123 |
+
- The model should not be used as the sole arbiter in automated grading or gatekeeping systems.
|
| 124 |
+
|
| 125 |
+
## Ethical Considerations
|
| 126 |
+
|
| 127 |
+
This model is intended for research and educational purposes. Automated topic
|
| 128 |
+
classification of ethics content should always be reviewed by a human expert before
|
| 129 |
+
consequential use.
|
| 130 |
+
|
| 131 |
+
## Citation
|
| 132 |
+
|
| 133 |
+
If you use EthicsBERT in your research or course materials, please cite:
|
| 134 |
+
|
| 135 |
+
```bibtex
|
| 136 |
+
@misc{ethicsbert2024,
|
| 137 |
+
title = {EthicsBERT: A DistilBERT Model for AI Ethics Topic Classification},
|
| 138 |
+
author = {nexageapps},
|
| 139 |
+
year = {2024},
|
| 140 |
+
url = {https://huggingface.co/nexageapps/EthicsBERT}
|
| 141 |
+
}
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
## License
|
| 145 |
+
|
| 146 |
+
Apache 2.0 — see [LICENSE](LICENSE) for details.
|
config.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"dim": 768,
|
| 8 |
+
"dropout": 0.1,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"hidden_dim": 3072,
|
| 11 |
+
"id2label": {
|
| 12 |
+
"0": "Agency",
|
| 13 |
+
"1": "AI Governance",
|
| 14 |
+
"2": "Bias",
|
| 15 |
+
"3": "Consciousness",
|
| 16 |
+
"4": "Ethical Reasoning",
|
| 17 |
+
"5": "Explainability",
|
| 18 |
+
"6": "Fairness",
|
| 19 |
+
"7": "Intelligence",
|
| 20 |
+
"8": "Privacy"
|
| 21 |
+
},
|
| 22 |
+
"initializer_range": 0.02,
|
| 23 |
+
"label2id": {
|
| 24 |
+
"AI Governance": 1,
|
| 25 |
+
"Agency": 0,
|
| 26 |
+
"Bias": 2,
|
| 27 |
+
"Consciousness": 3,
|
| 28 |
+
"Ethical Reasoning": 4,
|
| 29 |
+
"Explainability": 5,
|
| 30 |
+
"Fairness": 6,
|
| 31 |
+
"Intelligence": 7,
|
| 32 |
+
"Privacy": 8
|
| 33 |
+
},
|
| 34 |
+
"max_position_embeddings": 512,
|
| 35 |
+
"model_type": "distilbert",
|
| 36 |
+
"n_heads": 12,
|
| 37 |
+
"n_layers": 6,
|
| 38 |
+
"pad_token_id": 0,
|
| 39 |
+
"problem_type": "single_label_classification",
|
| 40 |
+
"qa_dropout": 0.1,
|
| 41 |
+
"seq_classif_dropout": 0.2,
|
| 42 |
+
"sinusoidal_pos_embds": false,
|
| 43 |
+
"tie_weights_": true,
|
| 44 |
+
"transformers_version": "4.57.6",
|
| 45 |
+
"vocab_size": 30522
|
| 46 |
+
}
|
label_mapping.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id2label": {
|
| 3 |
+
"0": "Agency",
|
| 4 |
+
"1": "AI Governance",
|
| 5 |
+
"2": "Bias",
|
| 6 |
+
"3": "Consciousness",
|
| 7 |
+
"4": "Ethical Reasoning",
|
| 8 |
+
"5": "Explainability",
|
| 9 |
+
"6": "Fairness",
|
| 10 |
+
"7": "Intelligence",
|
| 11 |
+
"8": "Privacy"
|
| 12 |
+
},
|
| 13 |
+
"label2id": {
|
| 14 |
+
"Agency": 0,
|
| 15 |
+
"AI Governance": 1,
|
| 16 |
+
"Bias": 2,
|
| 17 |
+
"Consciousness": 3,
|
| 18 |
+
"Ethical Reasoning": 4,
|
| 19 |
+
"Explainability": 5,
|
| 20 |
+
"Fairness": 6,
|
| 21 |
+
"Intelligence": 7,
|
| 22 |
+
"Privacy": 8
|
| 23 |
+
}
|
| 24 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ab7d85ae8f7a86c3484e2886c5e6ed03f7430f75b829d5271f414da7f3385ed
|
| 3 |
+
size 267854100
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_lower_case": true,
|
| 47 |
+
"extra_special_tokens": {},
|
| 48 |
+
"mask_token": "[MASK]",
|
| 49 |
+
"model_max_length": 512,
|
| 50 |
+
"pad_token": "[PAD]",
|
| 51 |
+
"sep_token": "[SEP]",
|
| 52 |
+
"strip_accents": null,
|
| 53 |
+
"tokenize_chinese_chars": true,
|
| 54 |
+
"tokenizer_class": "DistilBertTokenizer",
|
| 55 |
+
"unk_token": "[UNK]"
|
| 56 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|