An AI/ML API that predicts whether text is human-written or AI-generated. The API offers multiple classification models (Logistic Regression, Random Forest, Neural Networks) paired with different text encoding methods (GloVe word embeddings or TF-IDF vectorization). All of the models are trained on a Kaggle dataset of human and AI-generated essays.
🌐 Live API: http://ec2-3-131-93-133.us-east-2.compute.amazonaws.com/api/v1/
-
Classification Models:
-
Logistic Regression
-
Random Forest
-
Neural Network
-
Text Encoding:
-
GloVe (Global Vectors for Word Representation)
-
TF-IDF (Term Frequency-Inverse Document Frequency)
-
Programming Language:
- Python
-
Web Framework:
- FastAPI (REST API)
-
Machine Learning:
- PyTorch (Neural Networks)
- scikit-learn (Traditional ML)
-
Data Processing:
- Pandas (Data manipulation)
-
Deployment:
- AWS EC2 (Cloud hosting)
-
Testing & Documentation:
- Postman (API testing)
POST /api/v1/classify
Request Body:
{
"text": "Text to classify",
"encoder": "glove", // Options: "glove", "tfidf"
"model": "logistic_regression" // Options: "logistic_regression", "random_forest", "neural_network"
}
Response:
{
"model": "Logistic Regression",
"encoder": "glove",
"prediction": "Human",
"confidence": {
"human": "85.50%",
"ai": "14.50%"
}
}
GET /api/v1/info
Returns model information and usage examples.
- Python 3.12+
- Pip package manager
- Clone the repository
git clone https://github.com/yourusername/ai-detect.git
cd ai-detect
- Create and activate virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Download and prepare the dataset
- Visit Kaggle AI Vs Human Text Dataset
- Download and place the CSV file in
~/Downloads
- Train the models
- Open
src/main.py
- Uncomment the
main()
function call at the bottom of the file - Run the training script:
python -m src.main
- This will train all models and save them in
src/models/saved/
- Start the API server
- Open
src/api/api.py
- Uncomment the uvicorn line at the bottom of the file
- Run the server:
python -m src.main
The API will be available at http://localhost:8000
ai-detect/
├── src/
│ ├── api/ # FastAPI application
│ ├── models/ # ML model implementations
│ ├── encoders/ # Text encoding modules
│ └── data/ # Data processing utilities
├── tests/ # Unit tests
└── requirements.txt # Project dependencies
This project is licensed under the MIT License - see the LICENSE file for details.
Jimmy Andrews
- Email: jcandrews2@icloud.com
- Trained using the Kaggle dataset AI Vs Human Text