YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
AI Detector Ensemble and Mistral Rewriter
This repository backs one protected Hugging Face Dedicated Inference Endpoint:
RUBRIC13/ai-detector-ensemble. The endpoint keeps the three detectors and the
Mistral rewriter resident in one GPU process. It does not use Gradio or an
external inference API.
Requests without task remain detector requests for compatibility with the
existing Lovable integration. Set task: "rewrite" to use the resident
rewriter; both operations use the same URL, GPU, wake-up, and authentication.
Detect request
{
"inputs": "Full document text"
}
The equivalent explicit form is { "task": "detect", "inputs": "..." }.
Rewrite request
{
"task": "rewrite",
"inputs": "Text to rewrite",
"strength": "medium",
"num_candidates": 3
}
The response is:
{
"candidates": [
"candidate one",
"candidate two",
"candidate three"
]
}
All candidates are generated sequentially in one request. Long rewrites are chunked by paragraph, sentence, and finally tokenizer windows of approximately 450 source tokens. Each candidate rewrites the complete document independently; chunks from different candidates are never mixed and source text is never silently truncated.
The resident rewriter uses:
- Base:
mistralai/Mistral-7B-Instruct-v0.3, revisionc170c708c41dac9275d15a8fff4eca08d52bab71 - LoRA: public v1 tag in
txmedai/humanizer-mistral7b-lora, pinned tof4f9aab7e5e360c4b40e1d565dba486b6fe0b7d4 - Quantization: 4-bit NF4, float16 compute, double quantization,
device_map="auto"
The requested alias txmedai/humanizer-mistral7b-lora-v1 is not currently
resolvable through the Hub API; the public parent repository's immutable v1
commit is used instead. This is v1, not v2 or v3.
Run local tests with:
python -m unittest discover -s tests -v
Request
{
"inputs": "Text to analyze"
}
Response
{
"document": {
"ai_likelihood": 68.42,
"model_scores": {
"deberta": 61.2,
"vanguard": 70.31,
"qwen3": 73.75
}
},
"sentences": [
{
"index": 0,
"text": "Text to analyze.",
"start": 0,
"end": 16,
"ai_likelihood": 68.42,
"model_scores": {
"deberta": 61.2,
"vanguard": 70.31,
"qwen3": 73.75
},
"low_confidence": true
}
},
"ensemble_method": "equal_weight_average",
"calibrated": false,
"version": "1.1"
}
Internally every score is normalized from 0.0 human-like to 1.0 AI-like. The API returns percentages from 0.0 to 100.0. The document score continues to use independent tokenizer-aware document chunks and is not calculated from sentence scores. Each sentence is scored independently by all three resident models, with safe micro-batching of four sentence chunks by default. Sentence segmentation preserves source text and returns offsets. Sentences with fewer than 8 word-like information tokens are returned with low_confidence: true; they are not discarded or numerically reweighted.
Models and verified behavior
abhi099k/ai-text-detector-v-n4.0β DeBERTa-v3-large fine-tune, class 1 is AI.ShantanuT01/vanguard-ai-text-detectorβ ModernBERT-large, one output logit mapped with sigmoid as the model card'sP(AI).rasbt/ai-text-detector-qwen3-0.6b-variableβ Qwen3 sequence classifier, class 1 is AI. It uses a variable-position<|im_end|>readout and temperature scaling of1.4665638128271772before softmax.
The exact revisions, current configs, tokenizer settings, detector-specific Qwen3 metadata, scoring mappings, and licenses are recorded in MODEL_VERIFICATION.md.
Commercial licensing
The current published terms are permissive for the three selected model repositories: DeBERTa MIT metadata, Vanguard MIT metadata, and Qwen3 detector Apache-2.0. The Qwen3 base model is also published under Apache-2.0. Preserve the license files and notices when distributing a production system.
The runtime pins Transformers 4.57.3. This version supports all three verified architectures while avoiding an eager torchaudio import in the endpoint base image; the model metadata itself was independently verified from the Hub and reports Transformers 5.14.1.
Repository layout
handler.pyβ Hugging Face Custom Handler, resident detector/rewrite model loading, task routing, Qwen3 readout, chunking, sentence segmentation, batching, mappings, and response formatting.sitecustomize.pyβ disables discovery of an incompatible optional torchaudio wheel in the text-only endpoint worker before Transformers imports it.requirements.txtβ runtime dependencies installed by Inference Endpoints.tests/test_handler.pyβ automated tests for mappings, Qwen3 temperature/readout behavior, chunk coverage, sentence segmentation, offsets, confidence flags, batching, schema, failure handling, malformed input, and secret hygiene.scripts/verify_models.pyβ checks pinned Hub revisions/configs before upload or deployment.scripts/upload_repo.pyβ uploads this folder using an environment token only.scripts/create_endpoint.pyβ guarded creation of one protected endpoint, min replicas 0 and max replicas 1.scripts/wait_for_endpoint.pyβ waits for the endpoint to become ready.scripts/live_smoke_tests.pyβ authenticated document/sentence, offset, long-text, and malformed-input checks.DEPLOYMENT_REPORT.mdβ deployment status, hardware, tests, costs, revisions, and limitations.
Security
.hf-deploy-token is gitignored and must never be committed. Upload and endpoint scripts refuse to run without authentication. The endpoint is protected, so requests require a Hugging Face bearer token.