Skip to main content

Explainable AI Text Risk Analyzer

KpihX-Labs distribution

This MIT-licensed adaptation preserves the upstream contributors and history: https://github.com/lynote-ai/ai-text-detector. The distribution and executable are lynote-ai; the internal Python package is aidetect. Install with uv tool install lynote-ai, or use make uv-link from this checkout. Run lynote-ai document.txt --json; results go to stdout, not a persistent database. Use make check, make uv-build, make uv-publish, and make push. make puhsb aliases make push for both SSH remotes (github and gitlab). The local analyzer uses heuristics, not Lynote's hosted model. A low score is not proof of human authorship, and an insufficient-text result is an abstention. This is not a plagiarism or source-matching service.

Current CLI (0.2.0)

lynote-ai --help
lynote-ai --help-all                 # every command, parameters and examples
lynote-ai scan document.txt --json
lynote-ai compare first.txt second.txt --json
lynote-ai info --json                # engine and language limitations, no analysis

The CLI uses Typer and Rich: command groups, per-command examples, compact summary tables and all six evidence signals. JSON stays clean on stdout and retains the original core fields with additional timings.analysis_seconds and engine metadata. Historical lynote-ai document.txt --json and stdin invocations remain supported. Input errors are concise; files must be UTF-8, and literal text is passed explicitly through --text rather than silently treating a missing path as prose.

This release does not change the heuristic scores or claim new language support. English-only marker/transition lists and ASCII Latin word matching break accented French words; the CJK branch alone does not establish multilingual calibration. The multilingual neural training pipeline described below is a separate component and does not supply pretrained detector weights to the installed lynote-ai CLI.

The remaining upstream documentation is retained for provenance, with operational examples updated from the historical ai-detect command to uv run lynote-ai.

AI Detector Skill hero

CI Python 3.9+ MIT License No Network

An explainable, cautious AI-generated text risk analyzer for coding agents and local workflows.

简体中文 · Install · Evaluation · Use Cases · Detector API

🚀 New: the Lynote AI Detector API is live. Need AI-text detection inside your own app, LMS, or moderation pipeline? Call Lynote's production detector with one REST request — no model to train or host. Get an API key → lynote.ai/ai-detector-api

Other Quality Projects
AI Humanize Text:https://github.com/lynote-ai/humanize-text
AI Image Detector:https://github.com/lynote-ai/ai-image-detector

Two tiers in this repo. This page documents the lightweight local analyzer — an explainable, no-network CLI/skill for fast triage. The production two-level model (trained, multilingual, served) lives in detection-model-pipeline/; see How the production model works.

Why This Exists

Most AI text detectors are either overconfident, opaque, or awkward to embed inside agent workflows.

ai-detector-skill takes the opposite approach:

  • explainable weighted signals instead of hidden model claims
  • a local CLI and Python API that are easy to script
  • a short-text guardrail that refuses to overstate weak evidence
  • skill-ready packaging for Codex, Claude Code, and other repo-aware agents
  • reproducible benchmark and dataset evaluation scripts

If you want a triage tool that stays cautious and leaves room for human review, this repo is built for that.

How the production model works

The heavyweight detector behind Lynote is a two-level model that, in one forward pass, labels a document (human / ai / mixed) and every sentence (human / ai / paraphrased). It is trained, not rule-based — the full pipeline (data prep → train → calibrate → eval → serve) lives in detection-model-pipeline/.

flowchart LR
    csv["detection-log export (CSV)"] --> prep["prepare · dedup + soft labels"]
    prep --> train["train · joint doc + sentence heads"]
    hub["public backbone · XLM-R / ModernBERT"] --> train
    train --> cal["calibrate · temperature scaling"]
    train --> eval["eval · two-level metrics"]
    cal --> serve["serve · FastAPI, {code,msg,data}"]
  • One model, two levels. Document and sentence heads share a backbone; L = L_doc + α·L_sent. Differentiable sentence-probability statistics feed the document head — which is what makes the mixed class trainable.
  • Multilingual backbones. XLM-R-large (default) or ModernBERT-base, optimized for en / zh / pt / es.
  • Calibrated, not overconfident. Temperature scaling softens probabilities without changing predictions; confidence bands reject < 0.33 ≤ low < 0.6 ≤ medium < 0.8 ≤ high.
  • Deterministic & bounded. Hash-pinned splits, synthetic demo data, and make check gates (manifest / demo / docs / tests). No weights, datasets, or service logs are shipped, and no accuracy claims are made.

Full method: MODEL.md · ARCHITECTURE.md · DATA_CONSTRUCTION.md · API.md

Lynote AI Detector API — for developers

The local analyzer here is built for cautious, offline triage, and the production model above ships as a pipeline, not weights. If you need production-grade detection inside your own product, the Lynote AI Detector API serves Lynote's production detector through a single endpoint:

  • One synchronous REST call — send text, get structured JSON back with an overall classification, confidence, and sentence-level signals.
  • Covers major models — detects patterns associated with ChatGPT, Gemini, Claude, DeepSeek, and more.
  • Multilingual — the same endpoint handles multiple languages.
  • Server-side keys — Bearer-token auth, with separate credentials per environment.
  • Simple billing — 1 credit per input word (Chinese is counted per character: 1 character = 1 word).
curl https://api.lynote.ai/v1/detect \
  -H "Authorization: Bearer $LYNOTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "The rapid adoption of large language models has reshaped how teams write."}'

Get your Lynote AI Detector API key

Plans, rate limits, and full docs: lynote.ai/ai-detector-api. As with any detector, treat results as a signal for human review, not proof of authorship.

Install

uv sync
uv run lynote-ai examples/sample_ai_like.txt --json

Or bootstrap a local environment:

bash scripts/setup.sh

Example output:

Conclusion: AI-like signals are present, but this medium-confidence score is a risk estimate rather than proof.
Score: 84/100
Confidence: medium
Verdict: high_ai_likelihood
Words analyzed: 256

What You Get

  • score: 0-100 AI-like writing risk estimate
  • verdict: insufficient_text, low_ai_likelihood, mixed_or_uncertain, or high_ai_likelihood
  • confidence: currently low or medium
  • signals: strongest weighted evidence signals
  • caveats: warnings that stay attached to the result
  • next_steps: practical follow-up actions when useful

This is designed to help an agent say:

  • "AI-like signals are present."
  • "The sample is too short for a meaningful estimate."
  • "This should be reviewed against known writing samples."

Not:

  • "This was definitely written by AI."
  • "The detector proves misconduct."

Usage

CLI

uv run lynote-ai examples/sample_ai_like.txt
cat essay.txt | uv run lynote-ai --json
uv run python scripts/detect.py examples/sample_human_like.txt --json

Python API

from aidetect import analyze_text

text = open("essay.txt", encoding="utf-8").read()
result = analyze_text(text)

print(result.score, result.confidence, result.verdict)
for signal in result.strongest_signals():
    print(signal.name, signal.note)

Local Skill Install

cp -R ai-detector-skill "$CODEX_HOME/skills/"

Use the root SKILL.md as the portable skill definition, and keep AGENTS.md at the repo root for repo-aware agents.

Evaluation

We ran a reproducible evaluation on the public HC3 dataset, using the English finance, medicine, and open_qa subsets with the first 100 rows from each subset.

Snapshot of the lightweight local analyzer on that slice (not the production two-level model):

  • Human mean score: 5.4
  • AI mean score: 18.4
  • Mean separation: 13.0 points
  • Human coverage: 0.427
  • AI coverage: 0.920
  • Covered accuracy at score >= 45: 0.317

What that means in practice:

  • the detector separates human and AI answers on average, but only weakly on HC3
  • the short-text guardrail is doing useful work, especially on shorter human answers
  • the current thresholds are conservative, which keeps false confidence down but also lowers recall
  • this tool works better as triage + explanation than as a stand-alone classifier

See the full report in docs/HC3_EVALUATION.md.

Reproduce it with:

make eval-hc3

Use Cases

Teacher Triage

A teacher receives a polished 400-word reflection and wants a cautious signal before doing manual review.

Suggested workflow:

  1. Run uv run lynote-ai submission.txt --json.
  2. Read the strongest signals and caveats.
  3. Compare the passage with known writing samples before making any judgment.

Editorial Review

An editor wants to spot formulaic product reviews or guest posts before spending time on manual edits.

Why it fits:

  • medium-length prose works better than short snippets
  • explainable signals help justify why a draft feels templated

Trust And Safety Queueing

A moderation team wants to sort suspicious long-form posts into a manual review queue, not auto-remove them.

Why it fits:

  • the tool is conservative by design
  • it helps with prioritization more than enforcement

Internal Content QA

A team compares human drafts and AI-assisted drafts to see where language starts sounding too generic.

Why it fits:

  • the score is useful as a relative signal across versions
  • strongest signals can guide rewriting

Not For

  • disciplinary decisions about a named student or employee
  • treating a single score as proof of cheating or fraud
  • very short samples under about 80 words
  • high-stakes authorship disputes without known-sample comparison

Project Structure

detection-model-pipeline/   # production two-level model — prepare → train → calibrate → eval → serve
├── code/                    # pipeline stages (i..m) + harness validators
├── model_entity/            # joint model: ModernBERT + XLM-R backbones
├── data/demos/              # synthetic demo data (hash-pinned)
└── docs/                    # ARCHITECTURE / MODEL / DATA_CONSTRUCTION / API

ai-detector-skill/           # lightweight local analyzer (this page)
├── SKILL.md
├── scripts/
│   ├── detect.py
│   ├── setup.sh
│   ├── benchmark.py
│   └── evaluate_hc3.py
├── references/
│   └── api-reference.md
├── assets/
│   ├── hero.svg
│   ├── score-bands.svg
│   ├── workflow.svg
│   └── templates/
│       └── report.md
├── src/aidetect/
├── tests/
├── AGENTS.md
└── README.md

Dev Commands

make test
make demo
make benchmark
make eval-hc3

CI

GitHub Actions automatically runs:

  • make test on Python 3.9, 3.11, and 3.13
  • make benchmark to regenerate the synthetic benchmark report
  • make eval-hc3 to regenerate the HC3 evaluation report
  • upload of docs/BENCHMARK.md and docs/HC3_EVALUATION.md as workflow artifacts

Contributing

See CONTRIBUTING.md.

Good contributions usually improve one of these:

  • clearer evidence signals
  • safer wording and UX
  • multilingual handling that stays explainable
  • reproducible evaluation coverage
  • agent integration ergonomics

Need an API?

🔌 Visit lynote.ai/ai-detector-api to get your AI Detector API key.

License

MIT

Metadata

Release files for lynote-ai 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lynote-ai 0.2.0
File Size Uploaded Provenance Actions
lynote_ai-0.2.0.tar.gz 243.3 kB Without provenance Details for lynote_ai-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lynote-ai 0.2.0
File Interpreter ABI Platform Actions
lynote_ai-0.2.0-py3-none-any.whl Python 3 none any Details for lynote_ai-0.2.0-py3-none-any.whl

Total release size: 257.6 kB

Release files / lynote_ai-0.2.0.tar.gz

Download URL lynote_ai-0.2.0.tar.gz
Size 243.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cc3843f1e70018d9a97321f319aa62b811d9390e5bac71b517a2539c4bcb7621
BLAKE2b-256 checksum
How to use checksums
fa64c742ad2d69a14b37cc54b03c4868d2ecf76846ab8618f0211a262843b2aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lynote_ai-0.2.0-py3-none-any.whl

Download URL lynote_ai-0.2.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54bf938b9873cfef615f647c7fa11dcd0990868f6c58853ca10f9f0d114dfb71
BLAKE2b-256 checksum
How to use checksums
bb67f254af95cd2c268e60e15f5a3c6710319edb6dc7425e62b3c617fe6667ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for lynote-ai 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page