Defakto
An open-source toolkit from Forensiqa for detecting AI-generated and unreliable content: deepfake media, and hallucinated or unsafe LLM responses.
Status: early development. Text analysis (LLM response safety) works today. Image, audio and video support is planned.
Defakto uses one method for every media type: an encoder turns the input into a trajectory of embeddings, and a Koopman dynamics model scores how that trajectory evolves. Inputs whose dynamics don't match the reliable class get flagged, and the score is broken down so you can see where: which tokens and sentences, and later which frames or seconds.
Install
pip install "defakto[text]"
Requires Python 3.12 or later. The text extra installs PyTorch and Transformers for text analysis.
Usage
Detection runs with artifacts: fitted models for one media type and one task, for example unsafe generated content. Each artifact names the encoder it was fitted with, and defakto builds that encoder for you. The first run downloads the artifact and its embedding model; both are cached afterwards.
From Python
import defakto
results = defakto.analyze(
"An LLM response you want to check...",
artifacts=["Forensiqa/text-safety-jina-v2-base"],
)
for r in results:
print(r.artifact_id, r.label, round(r.score, 3))
for sentence in r.segments_of("sentence"):
if sentence.flagged:
print(" flagged:", sentence.text)
To analyze many inputs, create an Analyzer once and reuse it, so models load only once:
analyzer = defakto.Analyzer(["Forensiqa/text-safety-jina-v2-base"])
results = analyzer.analyze("response.txt")
From the command line
defakto analyze --text "An LLM response..." -a Forensiqa/text-safety-jina-v2-base
defakto analyze response.txt -a Forensiqa/text-safety-jina-v2-base --json
cat response.txt | defakto analyze - -a Forensiqa/text-safety-jina-v2-base
To choose artifacts per media type, use a config file:
# defakto.yaml
detectors:
text:
- Forensiqa/text-safety-jina-v2-base
- Forensiqa/text-safety-qwen3-embedding-0.6b
defakto analyze response.txt --config defakto.yaml
Artifacts that share an encoder share one encoding, so adding a second text artifact doesn't embed the text twice. Each artifact's score is on its own scale: compare a score with its artifact's threshold, not with another artifact's score.
Artifacts
An artifact is a folder with two files:
weights.safetensors: the model's arrays (lift_modes,observable_modes,operator_negative,operator_positive).manifest.yaml: what the artifact detects, the exact encoder it needs, its dimensions, threshold, and a checksum of the weights.
Defakto checks the checksum and dimensions before using an artifact. Official artifacts are published on the Hugging Face Hub under the Forensiqa organization:
| Artifact | Task | Encoder |
|---|---|---|
Forensiqa/text-safety-jina-v2-base |
unsafe content in text | jinaai/jina-embeddings-v2-base-en |
Forensiqa/text-safety-qwen3-embedding-0.6b |
unsafe content in text | Qwen/Qwen3-Embedding-0.6B |
Add @revision (a tag or commit) to pin an exact version, for example Forensiqa/text-safety-jina-v2-base@v0.1.0. Local artifact folders work too: pass the folder's path instead of a Hub id.
Development
uv sync --all-extras
uv run pre-commit install
uv run pytest
License
Apache License 2.0. See LICENSE.
Metadata
Release files for defakto 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| defakto-0.1.0.tar.gz | 22.3 kB | With provenance | Details for defakto-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| defakto-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for defakto-0.1.0-py3-none-any.whl |
Total release size: 51.7 kB
Release files / defakto-0.1.0.tar.gz
| Download URL | defakto-0.1.0.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3f6d1f6ab467e594a07c551d72f415bd24ee58e0dec55e62c2c825bf12df705
|
|
BLAKE2b-256 checksum How to use checksums |
f4d4334d7c94cc1f5694f63ca802cd65497f5ebf9802d8f58c0d7953270819e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logRelease files / defakto-0.1.0-py3-none-any.whl
| Download URL | defakto-0.1.0-py3-none-any.whl |
|---|---|
| Size | 29.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
997f0c57b8dcd2706be72e4a3ac82d2d4b2007e021782907df764a9cdc0311f7
|
|
BLAKE2b-256 checksum How to use checksums |
a90313d24c652c94c714d00c4e0e50dc312f1c5d632b7a809751a9a419879bd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logSecurity for defakto 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for defakto-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.