text-safety-jina-v2-base
A defakto artifact that flags unsafe content in LLM responses, built by Forensiqa.
It doesn't classify text with a second LLM. Instead, it embeds the response token by token with jinaai/jina-embeddings-v2-base-en and follows how that sequence of embeddings evolves. Two linear Koopman operators, one fitted on safe responses and one on unsafe ones, each try to predict the next step. Whichever predicts the response better tells you which class it behaves like. Scores are also broken down per token and per sentence, so you can see where a response turned unsafe.
Usage
Install defakto with text support:
pip install "defakto[text]"
From the command line:
defakto analyze --text "An LLM response to check..." -a Forensiqa/text-safety-jina-v2-base
From Python:
import defakto
(result,) = defakto.analyze(
"An LLM response to check...",
artifacts=["Forensiqa/text-safety-jina-v2-base"],
)
print(result.label, result.score)
for sentence in result.segments_of("sentence"):
if sentence.flagged:
print("flagged:", sentence.text)
The first run downloads this artifact and the embedding model (jinaai/jina-embeddings-v2-base-en, about 0.5 GB). Both are cached afterwards.
Details
| Media type | text |
| Task | safety (unsafe vs safe) |
| Encoder | jinaai/jina-embeddings-v2-base-en, per-token embeddings, special tokens removed |
| Max length | 512 tokens (longer text is truncated, with a warning) |
| Embedding size | 768 |
| Lift modes / observable modes | 40 / 500 (quadratic lifting) |
| Default threshold | 0.0 (flagged when score > threshold) |
| Minimum length | 5 tokens; shorter inputs get a reliability warning |
| Version | 0.1.0 |
Files: manifest.yaml (what defakto needs to load and check the artifact) and weights.safetensors (float64 arrays; defakto verifies their SHA-256 before use).
Limitations
- Fitted on English responses. Other languages haven't been tested.
- A flag is a signal for review, not a verdict on its own.