is-it-slop-preprocessing
Fast TF-IDF text preprocessing for AI text detection models.
Note: This is primarily an internal crate used by
is-it-slop. For AI text detection, use the mainis-it-slopcrate instead.
Purpose
This crate provides the preprocessing pipeline for the is-it-slop AI text detection system:
- Text cleaning (two-stage: universal + dataset artifacts)
- Tokenization (tiktoken BPE o200k_base)
- Token-based chunking (overlapping 150-token windows)
- Token n-gram extraction (2-4 token sequences)
- TF-IDF vectorization (sklearn-compatible)
Use Cases
- Training custom AI detection models: Use this crate to preprocess training data with the same pipeline used in inference
- Python bindings: Exposes Rust preprocessing to Python via PyO3 for training workflows
- Internal use: Powers the
is-it-slopinference pipeline
Features
python(default): PyO3 bindings for Python training workflowsrkyv(default): Zero-copy serialization for vectorizersserde: Alternative JSON/bincode serializationbincode: Legacy bincode serialization supportprogress-bars: Progress indicators for long-running operationsmimalloc: Use mimalloc as the global allocator
Quick Start
use ;
// Clean and vectorize text
let cleaner = text_cleaner_for_inference;
let clean_text = cleaner.clean;
// Configure vectorizer (n-gram range is fixed at 2-4 tokens)
let params = new; // min_df, max_df, sublinear_tf
// Fit vectorizer on training data
let vectorizer = fit?;
// Transform text to TF-IDF features
let features = vectorizer.transform?;
// Save for inference
vectorizer.save_rkyv?;
Python Bindings
For model training in Python:
or using pip:
# Configure and fit vectorizer
=
, =
# Save for Rust inference
See the Python package documentation for complete API reference.
Architecture
Token N-grams: Unlike character or word n-grams, this uses sequences of tiktoken BPE tokens (2-4 consecutive tokens). This captures AI writing patterns at the subword level.
Two-stage Cleaning:
- Universal cleaner (always): HTML entities, encoding artifacts, whitespace normalization
- Dataset artifact cleaner (training only): Citations, news datelines, academic headers
Two cleaners ensure that the model learns actual patterns rather than overfitting to specific dataset quirks (which there are a lot that I could find and still likely missed many).
Chunking: Splits long texts into overlapping 150-token chunks with 15-token overlap, enabling consistent feature extraction regardless of document length.
For AI Text Detection
For end-to-end AI text detection (inference), use the main crate:
Or the CLI:
See the is-it-slop documentation for the complete detection pipeline.
Documentation
License
MIT