All Toolsโ€บBatch LLM Text Auditor
๐Ÿ’ฌ Detecting LLM-Generated TextJuly 17, 2026โœ… Tests passing

Batch LLM Text Auditor

An automation tool for auditing large datasets of text documents, identifying which ones are likely generated by LLMs. It preprocesses the text, applies traditional ML classifiers, and outputs a detailed report with classification results and feature statistics for each document.

What It Does

  • Preprocesses text by removing punctuation, converting to lowercase, and removing stop words.
  • Uses a TF-IDF vectorizer and a Random Forest Classifier to classify text.
  • Outputs a CSV report with filenames, text content, LLM probabilities, and predictions.

Installation

1. Clone the repository:

git clone <repository_url>
   cd batch_llm_text_auditor

2. Install the required dependencies:

pip install -r requirements.txt

Usage

python batch_llm_text_auditor.py --input_dir ./texts --output ./audit_report.csv

Source Code

import os
import argparse
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
import nltk
from nltk.corpus import stopwords
import string
import json

nltk.download('stopwords', quiet=True)

class BatchLLMTextAuditor:
    def __init__(self, input_dir, output_file, threshold=0.5):
        self.input_dir = input_dir
        self.output_file = output_file
        self.threshold = threshold
        self.stop_words = set(stopwords.words('english'))
        self.model = RandomForestClassifier()
        self.vectorizer = TfidfVectorizer()

    def preprocess_text(self, text):
        text = text.lower()
        text = ''.join([char for char in text if char not in string.punctuation])
        words = text.split()
        words = [word for word in words if word not in self.stop_words]
        return ' '.join(words)

    def load_data(self):
        texts = []
        filenames = []
        for root, _, files in os.walk(self.input_dir):
            for file in files:
                if file.endswith('.txt'):
                    file_path = os.path.join(root, file)
                    with open(file_path, 'r', encoding='utf-8') as f:
                        texts.append(f.read())
                        filenames.append(file)
        return filenames, texts

    def train_model(self):
        # Simulating a pre-trained model for demonstration purposes
        dummy_texts = ["This is a human-generated text.", "This text is generated by an AI."]
        dummy_labels = [0, 1]  # 0: Human, 1: LLM
        preprocessed_dummy_texts = [self.preprocess_text(text) for text in dummy_texts]
        features = self.vectorizer.fit_transform(preprocessed_dummy_texts)
        self.model.fit(features, dummy_labels)

    def classify_texts(self, texts):
        preprocessed_texts = [self.preprocess_text(text) for text in texts]
        features = self.vectorizer.transform(preprocessed_texts)
        probabilities = self.model.predict_proba(features)[:, 1]
        return probabilities

    def generate_report(self, filenames, texts, probabilities):
        data = {
            'Filename': filenames,
            'Text': texts,
            'LLM_Probability': probabilities
        }
        df = pd.DataFrame(data)
        df['LLM_Prediction'] = df['LLM_Probability'] > self.threshold
        df.to_csv(self.output_file, index=False)

    def run(self):
        filenames, texts = self.load_data()
        if not texts:
            print("No text files found in the input directory.")
            return

        self.train_model()

        probabilities = self.classify_texts(texts)

        self.generate_report(filenames, texts, probabilities)
        print(f"Report generated: {self.output_file}")

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Batch LLM Text Auditor")
    parser.add_argument("--input_dir", required=True, help="Directory containing text files to audit")
    parser.add_argument("--output", required=True, help="Output CSV file for the results")
    args = parser.parse_args()

    auditor = BatchLLMTextAuditor(input_dir=args.input_dir, output_file=args.output)
    auditor.run()

Community

Downloads

ยทยทยท

Rate this tool

No ratings yet โ€” be the first!

Details

Tool Name
batch_llm_text_auditor
Category
Detecting LLM-Generated Text
Generated
July 17, 2026
Tests
Passing โœ…
Fix Loops
3

Quick Install

Clone just this tool:

git clone --depth 1 --filter=blob:none --sparse \
  https://github.com/ptulin/autoaiforge.git
cd autoaiforge
git sparse-checkout set generated_tools/2026-07-17/batch_llm_text_auditor
cd generated_tools/2026-07-17/batch_llm_text_auditor
pip install -r requirements.txt 2>/dev/null || true
python batch_llm_text_auditor.py
Batch LLM Text Auditor โ€” AI Tools by AutoAIForge