PyDetectGPT
Python package for AI-generated text detection. Provides a high level api for easy adoption and more granular customization for advanced use cases.
Quick Start
Implement an AI Plagarism detector in 4 lines of Python:
from pydetectgpt import detect_ai_text
text = "text you want to check here"
result = detect_ai_text(text)
print("AI Generated" if result else "Human Written")
On the first run it may some time to load the model from Hugging Face. After that it will be relatively fast.
Usage
You can also chose different Detection Methods, decision thresholds and use any transformers model for the logits:
from pydetectgpt import detect_ai_text
text = "text you want to check here"
result = detect_ai_text(text, method="fastdetectgpt", threshold=1.9, model="Qwen/Qwen2.5-1.5B")
print("AI Generated" if result else "Human Written")
The default thresholds are:
"loglikelihood": -1.8,
"logrank": -0.8,
"detectllm": 2.14,
"fastdetectgpt": 1.9,
These were selected to minimize false positives (minimize saying its AI text when its not).
CLI
There is also a CLI wrapper:
pydetectgpt "Your text here"
"Detection Result: AI Generated" or "Detection Result: Human Written"
If you want just the 0/1 result (ex for scripting) use the -q flag:
pydetectgpt "Your text here" -q
0 or 1
For a full list of args see cli.py
Methods
PyDetectGPT supports four detection methods, in order of effectiveness:
- FastDetectGPT (default): Implementation of Fast-DetectGPT: Efficient Zero-Shot Detection of Machine-Generated Text
- DetectLLM: Implementation of DetectLLM: Leveraging Log Rank Information for Zero-Shot Detection of Machine-Generated Text
- LogRank: Average log token rank
- LogLikelihood: Basic log likelihood of the text
Acknowledgements
- Fast-DetectGPT: Efficient Zero-Shot Detection of Machine-Generated Text (Bao et al., ICLR 2024)
- DetectLLM: Leveraging Log Rank Information for Zero-Shot Detection of Machine-Generated Text (Su et al., 2023)
License
MIT
Metadata
Release files for pydetectgpt 0.1.1
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 | |
|---|---|---|---|---|
| pydetectgpt-0.1.1.tar.gz | 9.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydetectgpt-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.3 kB
Release files / pydetectgpt-0.1.1.tar.gz
| Download URL | pydetectgpt-0.1.1.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f630d8e6e94e51f12a83beb80677bd32c6b896e40c92a4c121d8ded360395f0
|
|
BLAKE2b-256 checksum How to use checksums |
a6b2c24bc4765a6dd80ac821d7bcd93f8b6f9e11c9860dc2dda44837928e50ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / pydetectgpt-0.1.1-py3-none-any.whl
| Download URL | pydetectgpt-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
282e7c70885714e6b3c7fa9bc6ac54d6d669a07500f09a7d93aba4e8296543bb
|
|
BLAKE2b-256 checksum How to use checksums |
27e17f6a7c5f026e2687b3eb5a0337241dbcffadc98f14943cb0b144deb53fe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for pydetectgpt 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.