Text Classification
Transformers
ONNX
Safetensors
fela-moderation
fela
fourier-neural-operator
fno
gated-linear-attention
cpu
on-device
content-moderation
toxicity
pii
byte-level
custom_code
Instructions to use lowdown-labs/fela-moderator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lowdown-labs/fela-moderator with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="lowdown-labs/fela-moderator", trust_remote_code=True)# Load model directly from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained("lowdown-labs/fela-moderator", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
| from __future__ import annotations | |
| from .taxonomy import IDENTITY_LABELS | |
| _MHS_COL = { | |
| "race": "target_race", | |
| "religion": "target_religion", | |
| "gender": "target_gender", | |
| "sexuality": "target_sexuality", | |
| "disability": "target_disability", | |
| "origin": "target_origin", | |
| "age": "target_age", | |
| } | |
| def _truthy(v) -> float: | |
| if v is None: | |
| return -1.0 | |
| try: | |
| return 1.0 if float(v) >= 0.5 else 0.0 | |
| except (TypeError, ValueError): | |
| return 1.0 if bool(v) else 0.0 | |
| def load_identity_examples(max_rows=None, streaming=True): | |
| from datasets import load_dataset | |
| try: | |
| ds = load_dataset( | |
| "ucberkeley-dlab/measuring-hate-speech", split="train", streaming=streaming | |
| ) | |
| except Exception as e: | |
| print(f"[identity] measuring-hate-speech unavailable ({e!r}); skipping") | |
| return | |
| n = 0 | |
| for ex in ds: | |
| text = ex.get("text") | |
| if not text: | |
| continue | |
| labels, mask = ([], []) | |
| for lab in IDENTITY_LABELS: | |
| v = _truthy(ex.get(_MHS_COL[lab])) | |
| if v < 0: | |
| labels.append(0.0) | |
| mask.append(0.0) | |
| else: | |
| labels.append(v) | |
| mask.append(1.0) | |
| yield {"text": text, "labels": labels, "mask": mask} | |
| n += 1 | |
| if max_rows and n >= max_rows: | |
| return | |
| def licenses(): | |
| return [("ucberkeley-dlab/measuring-hate-speech", "CC-BY-4.0", True)] | |