llm-detector
Research WIP: Transparent, probabilistic classification of text as human-generated or LLM-generated.
Installation
pip install llm-detector
Quick Start
from llm_detector import classify_text
# Simple classification
result = classify_text("Your text here")
print(f"LLM probability: {result['p_llm']:.2%}")
print(f"Classification: {'LLM' if result['is_llm'] else 'Human'}")
Advanced Usage
Using the Runtime API
from llm_detector import DetectorRuntime
from llm_detector.assets import default_artifacts
# Initialize detector with default models
with default_artifacts() as (model_path, baseline_path):
detector = DetectorRuntime(
model_path=model_path,
baseline_path=baseline_path
)
# Single text classification
result = detector.predict("This is a sample text.")
print(f"LLM: {result.p_llm:.2%}, Human: {result.p_human:.2%}")
# Access detailed metrics
print(f"Confidence: {result.confidence:.4f}")
print(f"Document metrics:", result.details['document_metrics'])
Detailed Results with Diagnostics
from llm_detector import classify_text
result = classify_text(
"Your text here",
include_diagnostics=True
)
# Access classification
print(f"Classification: {'LLM' if result['is_llm'] else 'Human'}")
print(f"LLM probability: {result['p_llm']:.4f}")
print(f"Confidence: {result['confidence']:.4f}")
# Diagnostic metrics for analysis
if 'diagnostics' in result:
diag = result['diagnostics']
print(f"Simple mean: {diag.get('simple_mean', 0):.4f}")
print(f"Max score: {diag.get('max_score', 0):.4f}")
CLI Usage
# Classify text from command line
llm-detector --text "Your text here"
# Classify from file
llm-detector --file input.txt
# Get detailed output with diagnostics
llm-detector --text "Your text" --show-diagnostics --json
Research Notes
This is an active research project exploring transparent statistical methods for LLM detection. The approach combines:
- Statistical features: Lexical diversity, punctuation patterns, repetition metrics
- Tokenizer divergence: Cross-tokenizer efficiency and consistency metrics
- Ensemble aggregation: Logit-weighted mean with diagnostic fallbacks
Current limitations:
- Performance varies by text length (best with 3+ sentences)
- Optimized for general English text
- Continuous model updates as LLM capabilities evolve
Development
# Install with development dependencies
pip install -e ".[dev,training]"
# Run tests
pytest
# Train custom models (requires training extras)
python -m llm_detector.training.cli --help
License
MIT
Metadata
Release files for llm-detector 0.2.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 |
|---|---|---|---|---|
| llm_detector-0.2.0.tar.gz | 6.4 MB | Without provenance | Details for llm_detector-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_detector-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for llm_detector-0.2.0-py3-none-any.whl |
Total release size: 13.0 MB
Release files / llm_detector-0.2.0.tar.gz
| Download URL | llm_detector-0.2.0.tar.gz |
|---|---|
| Size | 6.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b18dc81ee1af3f6302ca876a131b5501644d88036fc472adad0cd17cd3addd9
|
|
BLAKE2b-256 checksum How to use checksums |
cabbf096f4f907b1efd0f774fb65f5fd1bee30f18d3b1fc8db89fd066523eb78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.13
|
Release files / llm_detector-0.2.0-py3-none-any.whl
| Download URL | llm_detector-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f43644c62be888d64ea238de44df6dce220f376cddca2ace879baf3044404673
|
|
BLAKE2b-256 checksum How to use checksums |
c1e84a807c6ba4fa455fb95ad9d77bd31f225a4a48fbe4b714ec5cd2e9a096e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.13
|
Security for llm-detector 0.2.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.
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.