Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KoalaAI - Text Moderation Demo

A Python application that demonstrates real-time text content moderation using the KoalaAI/Text-Moderation model with a Gradio web interface.

Features

  • Text Classification: Real-time detection of potentially harmful content across 9 categories:

    • Sexual content (S)
    • Hate speech (H)
    • Violence (V)
    • Harassment (HR)
    • Self-harm (SH)
    • Sexual content involving minors (S3)
    • Hate with threats (H2)
    • Graphic violence (V2)
    • Safe content (OK)
  • Performance Testing: Built-in tools to measure and visualize model performance:

    • Configurable number of requests (1-1000)
    • Adjustable text length per request
    • Real-time latency metrics visualization
    • Detailed performance statistics (avg, p50, p95, p99)

Installation

  1. Install dependencies:
pip install -r requirements.txt

Usage

  1. Start the application:
python frontend.py
  1. Open your web browser (I recommend Chrome, since on Firefox I spotted that some empty fields did not properly render their predefined value) and navigate to the local address shown in the terminal.

Single Text Classification

  1. Enter text in the input box or use the "Generate Random Text" button
  2. Click "Classify Text" to analyze the content
  3. View the classification results showing confidence scores for each category

Performance Testing

  1. Navigate to the "Performance Testing" tab
  2. Adjust test parameters:
    • Number of Requests (1-1000)
    • Maximum Characters per Request (5-500)
  3. Click "Run Performance Test" to start
  4. View results in:
    • Text summary with detailed statistics
    • Interactive plot showing latency metrics across test runs

Project Structure

  • frontend.py: Gradio web interface implementation
  • backend.py: Core functionality including model integration and performance testing
  • requirements.txt: Project dependencies

Performance Metrics

The performance testing suite provides the following metrics:

  • Average latency
  • Median (P50) latency
  • 95th percentile (P95)
  • 99th percentile (P99)
  • Minimum and maximum latencies
  • Total execution time

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages