Skip to content

ShushantaTUD/Explain_AI_Generated_Text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Detect and explain AI generated text

A library to detect and explain whether text is AI-generated or human-written using SHAP (SHapley Additive exPlanations).

Features

  • AI vs Human Text Classification: Distinguish between AI-generated and human-written text
  • Explainability: Uses SHAP to provide detailed feature importance explanations
  • Multiple Models: Includes XGBoost and Random Forest models for robust predictions
  • Comprehensive Feature Analysis: Analyzes 40+ linguistic features including:
    • Readability metrics
    • Sentiment analysis
    • Syntactic complexity
    • Stylistic patterns
    • And more

Installation

pip install explain_ai_generated_text

Or install from source:

git clone <repository-url>
cd explain_ai_generated_text
pip install -e .

Usage

from explain_ai_generated_text import shap_explainer

# Analyze text
text = "Your text here..."
result = shap_explainer(text)

# Returns:
# {
#     "prediction": 0 or 1,  # 0 = Human, 1 = AI
#     "features": {
#         "feature_name": {
#             "value": feature_value,
#             "shap_value": shap_contribution,
#             "importance": relative_importance
#         },
#         ...
#     }
# }

Requirements

  • Python >= 3.8
  • joblib
  • shap
  • xgboost
  • spacy
  • language-tool-python
  • textblob
  • pandas
  • numpy
  • scikit-learn
  • nltk
  • textstat
  • matplotlib
  • scipy

Development

Install development dependencies:

pip install -e ".[dev]"

Run tests:

pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use this library in your research, please cite:

@software{explain_ai_generated_text,
  title={Explainable AI Generated Text Detection},
  year={2025},
  url={<repository-url>}
}

About

Repo for explainable AI for AI generated text detection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors