MusicLIME and Multimodal MLP Framework For Explainable Classification Of AI-Generated And Human-Composed Music
Explore the paper »
View Demo
·
Report Bug
·
Request Feature
A multimodal machine learning system that classifies music as human-composed or AI-generated using both audio features and lyrics analysis. This project implements a comprehensive pipeline combining state-of-the-art audio processing, spectro-temporal audio analysis, natural language processing, and explainable AI techniques to provide accurate and interpretable music classification.
Bach or Bot addresses the growing challenge of distinguishing between human-composed and AI-generated music in an era where artificial intelligence can create increasingly sophisticated musical content. The system employs a multimodal approach that analyzes both audio characteristics and lyrical content to make classification decisions, which provides explanations for its predictions through advanced explainability techniques.
The system follows a multimodal fusion architecture:
This project builds upon several state-of-the-art research contributions:
SpecTTTra: Spectro-Temporal Tokens Transformer for audio representation learning
LLM2Vec: Large Language Model to Vector conversion for text embeddings
MusicLIME: Local Interpretable Model-agnostic Explanations for music classification
bach-or-bot/
├── app/ # FastAPI application
│ ├── schemas.py # Pydantic response models
│ ├── server.py # API endpoints and server configuration
│ ├── utils.py # Server utility functions
│ └── validators.py # Input validation functions
├── config/ # Configuration files
│ ├── data_config.yml # Data processing parameters
│ ├── model_config.yml # Model hyperparameters
│ └── server_config.yml # Server configuration
├── data/
│ ├── external/ # External data and test samples
│ ├── processed/ # Preprocessed datasets
│ └── raw/ # Original datasets
├── docs/ # Documentation
├── models/ # Trained model artifacts
│ ├── fusion/ # Fusion layer models and scalers
│ ├── mlp/ # MLP classifier checkpoints
│ ├── musiclime/ # MusicLIME model artifacts
│ └── spectttra/ # SpecTTTra model checkpoints
├── notebooks/
│ ├── exploratory/ # Data exploration and MusicLIME research
│ ├── inference/ # Model inference notebooks
│ └── modeling/ # Model development notebooks
├── scripts/ # Execution scripts
│ ├── evaluate.py # Model evaluation
│ ├── explain.py # Explanation generation (multimodal, unimodal, combined)
│ ├── explain_runner.py # Explanation testing script
│ ├── explain_combined_runner.py # Combined explanation testing
│ ├── predict.py # Prediction pipeline (multimodal, unimodal, combined)
│ ├── predict_runner.py # Prediction testing script
│ └── train.py # Training pipeline
├── src/ # Source code modules
│ ├── llm2vectrain/ # LLM2Vec training and inference
│ │ ├── model.py
│ │ ├── llm2vec_trainer.py
│ │ └── config.py
│ ├── models/ # Model definitions
│ │ └── mlp.py # MLP classifier
│ ├── musiclime/ # MusicLIME implementation
│ │ ├── explainer.py # Core MusicLIME explainer
│ │ ├── factorization.py # Audio source separation
│ │ ├── text_utils.py # Text processing utilities
│ │ └── wrapper.py # Prediction wrappers
│ ├── preprocessing/ # Data preprocessing modules
│ │ ├── audio_preprocessor.py
│ │ ├── lyrics_preprocessor.py
│ │ └── preprocessor.py
│ ├── spectttra/ # SpecTTTra implementation
│ │ ├── spectttra.py
│ │ ├── spectttra_trainer.py
│ │ ├── feature.py
│ │ ├── embedding.py
│ │ ├── tokenizer.py
│ │ └── transformer.py
│ └── utils/ # Utility functions
├── tests/ # Unit and integration tests
│ ├── test_preprocessing.py
│ ├── test_features.py
│ ├── test_mlp.py
│ ├── test_spectttra.py
│ └── test_musiclime.py
├── Dockerfile # Container configuration
├── Dockerfile.hf # Hugging Face deployment configuration
├── pyproject.toml # Project dependencies and metadata
└── README.md # This file!
Clone the repository:
git clone https://github.com/krislette/bach-or-bot.git
cd bach-or-bot
Install dependencies using Poetry:
poetry install
Activate the virtual environment:
poetry env activate
MUSICLIME_NUM_SAMPLES: Number of perturbation samples for LIME (default: 1000)MUSICLIME_NUM_FEATURES: Number of top features to return (default: 10)HF_TOKEN: Huggingface token for LLM2Vec accessEdit config/model_config.yml to adjust model hyperparameters:
Edit config/server_config.yml to adjust server settings:
Start the FastAPI server:
poetry run uvicorn app.server:app --reload --host 0.0.0.0 --port 8000
The API will be available at http://localhost:8000 with interactive documentation at http://localhost:8000/docs.
Multimodal Prediction
POST /api/v1/predict/multimodal - Prediction using both audio and lyricsPOST /api/v1/predict - Legacy endpoint (same as multimodal)Audio-Only Prediction
POST /api/v1/predict/audio - Prediction using only audio featuresCombined Prediction
POST /api/v1/predict/combined - Both predictions in one call (convenience wrapper)Multimodal Explanation
POST /api/v1/explain/multimodal - MusicLIME explanation using both modalitiesPOST /api/v1/explain - Legacy endpoint (same as multimodal)Audio-Only Explanation
POST /api/v1/explain/audio - MusicLIME explanation using only audioCombined Explanation (Optimized
POST /api/v1/explain/combined - Both explanations with shared source separation (~50% faster)GET / - API welcome message and endpoint listingGET /api/v1/model/info - Model information and capabilitiescurl -X POST "http://localhost:8000/api/v1/predict/multimodal" \
-H "Content-Type: multipart/form-data" \
-F "audio_file=@path/to/song.mp3" \
-F "lyrics=Your song lyrics here"
Response Format:
{
"status": "success",
"lyrics": "Your song lyrics here",
"audio_file_name": "song.mp3",
"audio_content_type": "audio/mpeg",
"audio_file_size": 1234567,
"results": {
"confidence": 0.8542,
"prediction": "Human-Composed",
"label": 1,
"probability": 0.8542
}
}
curl -X POST "http://localhost:8000/api/v1/predict/audio" \
-H "Content-Type: multimodal/form-data" \
-F "audio_file=@path/to/song.mp3"
curl -X POST "http://localhost:8000/api/v1/explain/multimodal" \
-H "Content-Type: multipart/form-data" \
-F "audio_file=@path/to/song.mp3" \
-F "lyrics=Your song lyrics here"
Response Format:
{
"status": "success",
"lyrics": "Your song lyrics here",
"audio_file_name": "song.mp3",
"results": {
"prediction": {
"class": 1,
"class_name": "Human-Composed",
"confidence": 0.8542,
"probabilities": [0.1458, 0.8542]
},
"explanations": [
{
"rank": 1,
"modality": "audio",
"feature_text": "vocals",
"weight": 0.2341,
"importance": 0.2341
},
{
"rank": 2,
"modality": "lyrics",
"feature_text": "Line 1: Your song lyrics here",
"weight": 0.1876,
"importance": 0.1876
}
],
"summary": {
"total_features_analyzed": 10,
"audio_features_count": 6,
"lyrics_features_count": 4,
"runtime_seconds": 45.23,
"samples_generated": 1000,
"timestamp": "2024-10-26T09:15:30"
}
}
}
curl -X POST "http://localhost:8000/api/v1/explain/combined" \
-H "Content-Type: multipart/form-data" \
-F "audio_file=@path/to/song.mp3" \
-F "lyrics=Your song lyrics here"
Response Format:
{
"status": "success",
"results": {
"multimodal": {
"prediction": { /_ multimodal prediction results / },
"explanations": [ / multimodal explanations / ],
"summary": { / multimodal processing summary / }
},
"audioonly": {
"prediction": { /_ audio-only prediction results / },
"explanations": [ / audio-only explanations / ],
"summary": { / audio-only processing summary / }
},
"combinedsummary": {
"total_runtime_seconds": 67.45,
"factorization_time_seconds": 42.1,
"source_separation_reused": true,
"timestamp": "2024-10-26T09:15:30"
}
}
}
Test multimodal and audio-only predictions:
poetry run python -m scripts.predict_runner
Test explanation generation:
poetry run python -m scripts.explain_runner
poetry run python -m scripts.predict_combined_runner
poetry run python -m scripts.explain_combined_runner
Train the complete pipeline:
poetry run python -m scripts.train.py
Build and run using Docker:
# Build the container
docker build -t bach-or-bot .
# Run the container
docker run -p 8000:8000 bach-or-bot
The project includes a Hugging Face deployment configuration:
docker build -f Dockerfile.hf -t bach-or-bot-hf .
The system provides classification confidence scores and detailed explanations for each prediction. The multimodal approach typically achieves higher accuracy than audio-only classification by leveraging complementary information from both modalities.
/explain/combined endpoint performs source separation once and reuses it for both multimodal and audio-only explanations which reduces processing time by approximately 50%Add runtime dependencies:
poetry add package-name
Add development dependencies:
poetry add --group dev package-name
Run the test suite:
poetry run pytest tests/
Run specific test modules:
poetry run pytest -m tests.test_musiclime
poetry run pytest -m tests.test_spectttra
poetry run pytest -m tests.test_mlp
The project follows Python best practices:
This project was developed by a collaborative team of researchers and developers:
If you use this work in your research, please cite:
@software{bach_or_bot_2025,
title = {Bach or Bot: MusicLIME and Multimodal MLP Framework For Explainable Classification Of AI-Generated And Human-Composed Music},
author = {Bonifacio, Regina and Domingo, Syruz Ken and Queja, Hans Christian and Rosales, Acelle Krislette},
year = {2025},
url = {https://github.com/krislette/bach-or-bot}
}
We acknowledge the research contributions that made this project possible, particularly the authors of SpecTTTra, LLM2Vec, and MusicLIME. This work builds upon their foundational research and provided source code/notebooks in audio processing, natural language processing, and explainable AI for music understanding.
Special thanks to the open-source community for providing the tools and libraries that enabled this research, including OpenUnmix for source separation, LIME for explainability frameworks, and the broader PyTorch ecosystem for deep learning infrastructure.
For questions or collaboration inquiries, please contact the development team through the repository issues page.
Distributed under the Apache 2.0 License. See LICENSE for more information.
Python
63.4%
Jupyter Notebook
36.3%
MusicLIME and Multimodal MLP Framework For Explainable Classification Of AI-Generated And Human-Composed Music
Explore the paper »
View Demo
·
Report Bug
·
Request Feature
A multimodal machine learning system that classifies music as human-composed or AI-generated using both audio features and lyrics analysis. This project implements a comprehensive pipeline combining state-of-the-art audio processing, spectro-temporal audio analysis, natural language processing, and explainable AI techniques to provide accurate and interpretable music classification.
Bach or Bot addresses the growing challenge of distinguishing between human-composed and AI-generated music in an era where artificial intelligence can create increasingly sophisticated musical content. The system employs a multimodal approach that analyzes both audio characteristics and lyrical content to make classification decisions, which provides explanations for its predictions through advanced explainability techniques.
The system follows a multimodal fusion architecture:
This project builds upon several state-of-the-art research contributions:
SpecTTTra: Spectro-Temporal Tokens Transformer for audio representation learning
LLM2Vec: Large Language Model to Vector conversion for text embeddings
MusicLIME: Local Interpretable Model-agnostic Explanations for music classification
bach-or-bot/
├── app/ # FastAPI application
│ ├── schemas.py # Pydantic response models
│ ├── server.py # API endpoints and server configuration
│ ├── utils.py # Server utility functions
│ └── validators.py # Input validation functions
├── config/ # Configuration files
│ ├── data_config.yml # Data processing parameters
│ ├── model_config.yml # Model hyperparameters
│ └── server_config.yml # Server configuration
├── data/
│ ├── external/ # External data and test samples
│ ├── processed/ # Preprocessed datasets
│ └── raw/ # Original datasets
├── docs/ # Documentation
├── models/ # Trained model artifacts
│ ├── fusion/ # Fusion layer models and scalers
│ ├── mlp/ # MLP classifier checkpoints
│ ├── musiclime/ # MusicLIME model artifacts
│ └── spectttra/ # SpecTTTra model checkpoints
├── notebooks/
│ ├── exploratory/ # Data exploration and MusicLIME research
│ ├── inference/ # Model inference notebooks
│ └── modeling/ # Model development notebooks
├── scripts/ # Execution scripts
│ ├── evaluate.py # Model evaluation
│ ├── explain.py # Explanation generation (multimodal, unimodal, combined)
│ ├── explain_runner.py # Explanation testing script
│ ├── explain_combined_runner.py # Combined explanation testing
│ ├── predict.py # Prediction pipeline (multimodal, unimodal, combined)
│ ├── predict_runner.py # Prediction testing script
│ └── train.py # Training pipeline
├── src/ # Source code modules
│ ├── llm2vectrain/ # LLM2Vec training and inference
│ │ ├── model.py
│ │ ├── llm2vec_trainer.py
│ │ └── config.py
│ ├── models/ # Model definitions
│ │ └── mlp.py # MLP classifier
│ ├── musiclime/ # MusicLIME implementation
│ │ ├── explainer.py # Core MusicLIME explainer
│ │ ├── factorization.py # Audio source separation
│ │ ├── text_utils.py # Text processing utilities
│ │ └── wrapper.py # Prediction wrappers
│ ├── preprocessing/ # Data preprocessing modules
│ │ ├── audio_preprocessor.py
│ │ ├── lyrics_preprocessor.py
│ │ └── preprocessor.py
│ ├── spectttra/ # SpecTTTra implementation
│ │ ├── spectttra.py
│ │ ├── spectttra_trainer.py
│ │ ├── feature.py
│ │ ├── embedding.py
│ │ ├── tokenizer.py
│ │ └── transformer.py
│ └── utils/ # Utility functions
├── tests/ # Unit and integration tests
│ ├── test_preprocessing.py
│ ├── test_features.py
│ ├── test_mlp.py
│ ├── test_spectttra.py
│ └── test_musiclime.py
├── Dockerfile # Container configuration
├── Dockerfile.hf # Hugging Face deployment configuration
├── pyproject.toml # Project dependencies and metadata
└── README.md # This file!
Clone the repository:
git clone https://github.com/krislette/bach-or-bot.git
cd bach-or-bot
Install dependencies using Poetry:
poetry install
Activate the virtual environment:
poetry env activate
MUSICLIME_NUM_SAMPLES: Number of perturbation samples for LIME (default: 1000)MUSICLIME_NUM_FEATURES: Number of top features to return (default: 10)HF_TOKEN: Huggingface token for LLM2Vec accessEdit config/model_config.yml to adjust model hyperparameters:
Edit config/server_config.yml to adjust server settings:
Start the FastAPI server:
poetry run uvicorn app.server:app --reload --host 0.0.0.0 --port 8000
The API will be available at http://localhost:8000 with interactive documentation at http://localhost:8000/docs.
Multimodal Prediction
POST /api/v1/predict/multimodal - Prediction using both audio and lyricsPOST /api/v1/predict - Legacy endpoint (same as multimodal)Audio-Only Prediction
POST /api/v1/predict/audio - Prediction using only audio featuresCombined Prediction
POST /api/v1/predict/combined - Both predictions in one call (convenience wrapper)Multimodal Explanation
POST /api/v1/explain/multimodal - MusicLIME explanation using both modalitiesPOST /api/v1/explain - Legacy endpoint (same as multimodal)Audio-Only Explanation
POST /api/v1/explain/audio - MusicLIME explanation using only audioCombined Explanation (Optimized
POST /api/v1/explain/combined - Both explanations with shared source separation (~50% faster)GET / - API welcome message and endpoint listingGET /api/v1/model/info - Model information and capabilitiescurl -X POST "http://localhost:8000/api/v1/predict/multimodal" \
-H "Content-Type: multipart/form-data" \
-F "audio_file=@path/to/song.mp3" \
-F "lyrics=Your song lyrics here"
Response Format:
{
"status": "success",
"lyrics": "Your song lyrics here",
"audio_file_name": "song.mp3",
"audio_content_type": "audio/mpeg",
"audio_file_size": 1234567,
"results": {
"confidence": 0.8542,
"prediction": "Human-Composed",
"label": 1,
"probability": 0.8542
}
}
curl -X POST "http://localhost:8000/api/v1/predict/audio" \
-H "Content-Type: multimodal/form-data" \
-F "audio_file=@path/to/song.mp3"
curl -X POST "http://localhost:8000/api/v1/explain/multimodal" \
-H "Content-Type: multipart/form-data" \
-F "audio_file=@path/to/song.mp3" \
-F "lyrics=Your song lyrics here"
Response Format:
{
"status": "success",
"lyrics": "Your song lyrics here",
"audio_file_name": "song.mp3",
"results": {
"prediction": {
"class": 1,
"class_name": "Human-Composed",
"confidence": 0.8542,
"probabilities": [0.1458, 0.8542]
},
"explanations": [
{
"rank": 1,
"modality": "audio",
"feature_text": "vocals",
"weight": 0.2341,
"importance": 0.2341
},
{
"rank": 2,
"modality": "lyrics",
"feature_text": "Line 1: Your song lyrics here",
"weight": 0.1876,
"importance": 0.1876
}
],
"summary": {
"total_features_analyzed": 10,
"audio_features_count": 6,
"lyrics_features_count": 4,
"runtime_seconds": 45.23,
"samples_generated": 1000,
"timestamp": "2024-10-26T09:15:30"
}
}
}
curl -X POST "http://localhost:8000/api/v1/explain/combined" \
-H "Content-Type: multipart/form-data" \
-F "audio_file=@path/to/song.mp3" \
-F "lyrics=Your song lyrics here"
Response Format:
{
"status": "success",
"results": {
"multimodal": {
"prediction": { /_ multimodal prediction results / },
"explanations": [ / multimodal explanations / ],
"summary": { / multimodal processing summary / }
},
"audioonly": {
"prediction": { /_ audio-only prediction results / },
"explanations": [ / audio-only explanations / ],
"summary": { / audio-only processing summary / }
},
"combinedsummary": {
"total_runtime_seconds": 67.45,
"factorization_time_seconds": 42.1,
"source_separation_reused": true,
"timestamp": "2024-10-26T09:15:30"
}
}
}
Test multimodal and audio-only predictions:
poetry run python -m scripts.predict_runner
Test explanation generation:
poetry run python -m scripts.explain_runner
poetry run python -m scripts.predict_combined_runner
poetry run python -m scripts.explain_combined_runner
Train the complete pipeline:
poetry run python -m scripts.train.py
Build and run using Docker:
# Build the container
docker build -t bach-or-bot .
# Run the container
docker run -p 8000:8000 bach-or-bot
The project includes a Hugging Face deployment configuration:
docker build -f Dockerfile.hf -t bach-or-bot-hf .
The system provides classification confidence scores and detailed explanations for each prediction. The multimodal approach typically achieves higher accuracy than audio-only classification by leveraging complementary information from both modalities.
/explain/combined endpoint performs source separation once and reuses it for both multimodal and audio-only explanations which reduces processing time by approximately 50%Add runtime dependencies:
poetry add package-name
Add development dependencies:
poetry add --group dev package-name
Run the test suite:
poetry run pytest tests/
Run specific test modules:
poetry run pytest -m tests.test_musiclime
poetry run pytest -m tests.test_spectttra
poetry run pytest -m tests.test_mlp
The project follows Python best practices:
This project was developed by a collaborative team of researchers and developers:
If you use this work in your research, please cite:
@software{bach_or_bot_2025,
title = {Bach or Bot: MusicLIME and Multimodal MLP Framework For Explainable Classification Of AI-Generated And Human-Composed Music},
author = {Bonifacio, Regina and Domingo, Syruz Ken and Queja, Hans Christian and Rosales, Acelle Krislette},
year = {2025},
url = {https://github.com/krislette/bach-or-bot}
}
We acknowledge the research contributions that made this project possible, particularly the authors of SpecTTTra, LLM2Vec, and MusicLIME. This work builds upon their foundational research and provided source code/notebooks in audio processing, natural language processing, and explainable AI for music understanding.
Special thanks to the open-source community for providing the tools and libraries that enabled this research, including OpenUnmix for source separation, LIME for explainability frameworks, and the broader PyTorch ecosystem for deep learning infrastructure.
For questions or collaboration inquiries, please contact the development team through the repository issues page.
Distributed under the Apache 2.0 License. See LICENSE for more information.
Python
63.4%
Jupyter Notebook
36.3%